summaryrefslogtreecommitdiff
path: root/sql/sp.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.5 into 10.6Marko Mäkelä2021-09-301-8/+14
|\
| * Merge 10.4 into 10.5Marko Mäkelä2021-09-301-8/+14
| |\ | | | | | | | | | | | | FIXME: Part of the MDEV-20699 test is disabled due to nonderterministic result.
| | * Merge 10.3 into 10.4Marko Mäkelä2021-09-301-0/+8
| | |\
| | | * MDEV-20699 followup.Vladislav Vaintroub2021-09-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Normally we disable caching of routines in "SHOW CREATE". Introduce an exception, if debug_dbug="+d,cache_sp_in_show_create". lock_sync.test needs a way to populate the cache without side effects, or else it runs into debug_sync timeouts. So, this possibility to cache will be remain only for very special tests.
| | * | Merge 10.3 into 10.4Marko Mäkelä2021-09-291-9/+7
| | |\ \ | | | |/
| | | * MDEV-20699 mysqldump of routines causes MariaDB to get killed by oom-killerbb-10.3-wlad-MDEV-20699Vladislav Vaintroub2021-09-271-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason for this behavior is that SP get cached, per connection. The stored_program_cache is size of this cache, which amounts to 256 routines by default. A compiled stored procedure can easily be several megabytes in size. Thus calling SHOW CREATE PROCEDURE for all stored procedures, like mysqldump does, can require significant amount of memory. Fixed by bypassing the cache for "SHOW CREATE". This should normally be fine also perfomance-wise, as cache is meant to be used for repeated execution, not repeated SHOW CREATEs. Added a test to verify that CREATE PROCEDURE + SHOW CREATE PROCEURE do not cache, i.e amount of allocated memory does not change. Note, there is a change in existing behavior in an edge case : If "SHOW CREATE PROCEDURE p1" called from p1, after p1 was altered, now this will now return altered code. Previour behavior - relied on caching and would return old code. The previous behavior might was not necessarily correct.
* | | | Remove some usage of Check_level_instant_set and Sql_mode_saveMonty2021-05-191-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason for the removal are: - Generates more code - Storing and retreving THD - Causes extra code and daata to be generated to handle possible throw exceptions (which never happens in MariaDB code) - Uses more stack space Other things: - Changed convert_const_to_int() to use item->save_in_field_no_warnings(), which made the code shorter and simpler. - Removed not needed code in Sp_handler::sp_create_routine() - Added thd as argument to store_key.copy() to make function simpler - Added thd as argument to some subselect* constructor that inherites from Item_subselect.
* | | | Don't reset StringBuffers in loops when not neededMonty2021-05-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Moved out creating StringBuffers in loops and instead create them outside and just reset the buffer if it was not allocated (to avoid a possible malloc/free for every entry) Other things related to set_buffer_if_not_allocated() - Changed Valuebuffer to not call set_buffer_if_not_allocated() when it is created. - Fixed geometry functions to reset string length before calling String::reserve(). This is because one should not access length() of an undefined. - Added Item_func_conv_charset::save_in_field() as the item is using str_value to store cached values, which conflicts with Item::save_str_in_field(). - Changed Item_proc_string to not store the string value in sql_string as this clashes with Item::save_str_in_field(). - Locally store value of full_name_cstring() in analyse::end_of_records() as Item::save_str_in_field() may overwrite it. - Marked some strings as set_thread_specific() - Added String::free_buffer() to be used internally in String functions to just free the buffer but not reset other String values. - Fixed uses_buffer_owned_by() to check for allocated length instead of strlength, which could be marked MEM_UNDEFINED().
* | | | Change CHARSET_INFO character set and collaction names to LEX_CSTRINGMonty2021-05-191-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change removed 68 explict strlen() calls from the code. The following renames was done to ensure we don't use the old names when merging code from earlier releases, as using the new variables for print function could result in crashes: - charset->csname renamed to charset->cs_name - charset->name renamed to charset->coll_name Almost everything where mechanical changes except: - Changed to use the new Protocol::store(LEX_CSTRING..) when possible - Changed to use field->store(LEX_CSTRING*, CHARSET_INFO*) when possible - Changed to use String->append(LEX_CSTRING&) when possible Other things: - There where compiler issues with ensuring that all character set names points to the same string: gcc doesn't allow one to use integer constants when defining global structures (constant char * pointers works fine). To get around this, I declared defines for each character set name length.
* | | | Reduce usage of strlen()Monty2021-05-191-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes: - To detect automatic strlen() I removed the methods in String that uses 'const char *' without a length: - String::append(const char*) - Binary_string(const char *str) - String(const char *str, CHARSET_INFO *cs) - append_for_single_quote(const char *) All usage of append(const char*) is changed to either use String::append(char), String::append(const char*, size_t length) or String::append(LEX_CSTRING) - Added STRING_WITH_LEN() around constant string arguments to String::append() - Added overflow argument to escape_string_for_mysql() and escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow. This was needed as most usage of the above functions never tested the result for -1 and would have given wrong results or crashes in case of overflows. - Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING. Changed all Item_func::func_name()'s to func_name_cstring()'s. The old Item_func_or_sum::func_name() is now an inline function that returns func_name_cstring().str. - Changed Item::mode_name() and Item::func_name_ext() to return LEX_CSTRING. - Changed for some functions the name argument from const char * to to const LEX_CSTRING &: - Item::Item_func_fix_attributes() - Item::check_type_...() - Type_std_attributes::agg_item_collations() - Type_std_attributes::agg_item_set_converter() - Type_std_attributes::agg_arg_charsets...() - Type_handler_hybrid_field_type::aggregate_for_result() - Type_handler_geometry::check_type_geom_or_binary() - Type_handler::Item_func_or_sum_illegal_param() - Predicant_to_list_comparator::add_value_skip_null() - Predicant_to_list_comparator::add_value() - cmp_item_row::prepare_comparators() - cmp_item_row::aggregate_row_elements_for_comparison() - Cursor_ref::print_func() - Removes String_space() as it was only used in one cases and that could be simplified to not use String_space(), thanks to the fixed my_vsnprintf(). - Added some const LEX_CSTRING's for common strings: - NULL_clex_str, DATA_clex_str, INDEX_clex_str. - Changed primary_key_name to a LEX_CSTRING - Renamed String::set_quick() to String::set_buffer_if_not_allocated() to clarify what the function really does. - Rename of protocol function: bool store(const char *from, CHARSET_INFO *cs) to bool store_string_or_null(const char *from, CHARSET_INFO *cs). This was done to both clarify the difference between this 'store' function and also to make it easier to find unoptimal usage of store() calls. - Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*) - Changed some 'const char*' arrays to instead be of type LEX_CSTRING. - class Item_func_units now used LEX_CSTRING for name. Other things: - Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character in the prompt would cause some part of the prompt to be duplicated. - Fixed a lot of instances where the length of the argument to append is known or easily obtain but was not used. - Removed some not needed 'virtual' definition for functions that was inherited from the parent. I added override to these. - Fixed Ordered_key::print() to preallocate needed buffer. Old code could case memory overruns. - Simplified some loops when adding char * to a String with delimiters.
* | | | MDEV-8334: Rename utf8 to utf8mb3Rucha Deodhar2021-05-191-15/+18
| | | | | | | | | | | | | | | | | | | | | | | | This patch changes the main name of 3 byte character set from utf8 to utf8mb3. New old_mode UTF8_IS_UTF8MB3 is added and set TRUE by default, so that utf8 would mean utf8mb3. If not set, utf8 would mean utf8mb4.
* | | | MDEV-24312 master_host has 60 character limit, increase to 255 bytesbb-10.6-MDEV-24312Oleksandr Byelkin2021-04-201-1/+1
|/ / / | | | | | | | | | | | | | | | | | | Also increase user name up to 128. The work was started by Rucha Deodhar <rucha.deodhar@mariadb.com>, contains audit plugin fixes by Alexey Botchkov <holyfoot@askmonty.org>.
* | | Merge 10.4 into 10.5Marko Mäkelä2021-01-251-1/+1
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2021-01-251-1/+1
| |\ \ | | |/
| | * MDEV-24524 Assertion `ls->length < 0xFFFFFFFFL && ((ls->length == 0 && ↵Sergei Golubchik2021-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | !ls->str) || ls->length == strlen(ls->str))' failed in String::append on SELECT from I_S don't expect return type of a stored function to be valid. it's read from a table, so can be messed with. it even can contain \0 bytes in the middle of the type name
* | | Merge 10.4 into 10.5Marko Mäkelä2020-12-021-5/+1
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-12-011-5/+1
| |\ \ | | |/
| | * cleanup: RAII helper for changing thd->count_cuted_rowsSergei Golubchik2020-11-251-5/+1
| | |
* | | Remove String::lex_string() and String::lex_cstring()Monty2020-07-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Better to use 'String *' directly. - Added String::get_value(LEX_STRING*) for the few cases where we want to convert a String to LEX_CSTRING. Other things: - Use StringBuffer for some functions to avoid mallocs
* | | Merge 10.4 into 10.5Marko Mäkelä2020-07-151-4/+4
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-07-151-5/+5
| |\ \ | | |/
| | * Merge 10.2 into 10.3Marko Mäkelä2020-07-141-5/+5
| | |\
| | | * Merge 10.1 into 10.2Marko Mäkelä2020-07-141-1/+1
| | | |\
| | | | * MDEV-22654: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())'Rucha Deodhar2020-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | failed in Diagnostics_area::set_ok_status on FUNCTION replace When there is REPLACE in the statement, sp_drop_routine_internal() returns 0 (SP_OK) on success which is then assigned to ret. So ret becomes false and the error state is lost. The expression inside DBUG_ASSERT() evaluates to false and thus the assertion failure.
| | | * | Merge branch '10.1' into 10.2Sergei Petrunia2020-01-171-1/+1
| | | |\ \ | | | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # sql/sp_head.cc # sql/sql_select.cc # sql/sql_trigger.cc
| | | | * MDEV-21341: Fix UBSAN failures: Issue SixSergei Petrunia2020-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Variant #2 of the patch, which keeps the sp_head object inside the MEM_ROOT that sp_head object owns) (10.3 requires extra work due to sp_package, will commit a separate patch for it) sp_head::operator new() and operator delete() were dereferencing sp_head* pointers to memory that didn't hold a valid sp_head object (it was not created/already destroyed). This caused UBSan to crash when looking up type information. Fixed by providing static sp_head::create() and sp_head::destroy() methods.
* | | | | Aria will now register it's transactionsMonty2020-05-231-23/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-22531 Remove maria::implicit_commit() MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in MYSQL_BIN_LOG::unlog_xa_prepare From the handler point of view, Aria now looks like a transactional engine. One effect of this is that we don't need to call maria::implicit_commit() anymore. This change also forces the server to call trans_commit_stmt() after doing any read or writes to system tables. This work will also make it easier to later allow users to have system tables in other engines than Aria. To handle the case that Aria doesn't support rollback, a new handlerton flag, HTON_NO_ROLLBACK, was added to engines that has transactions without rollback (for the moment only binlog and Aria). Other things - Moved freeing of MARIA_SHARE to a separate function as the MARIA_SHARE can be still part of a transaction even if the table has closed. - Changed Aria checkpoint to use the new MARIA_SHARE free function. This fixes a possible memory leak when using S3 tables - Changed testing of binlog_hton to instead test for HTON_NO_ROLLBACK - Removed checking of has_transaction_manager() in handler.cc as we can assume that as the transaction was started by the engine, it does support transactions. - Added new class 'start_new_trans' that can be used to start indepdendent sub transactions, for example while reading mysql.proc, using help or status tables etc. - open_system_tables...() and open_proc_table_for_Read() doesn't anymore take a Open_tables_backup list. This is now handled by 'start_new_trans'. - Split thd::has_transactions() to thd::has_transactions() and thd::has_transactions_and_rollback() - Added handlerton code to free cached transactions objects. Needed by InnoDB. squash! 2ed35999f2a2d84f1c786a21ade5db716b6f1bbc
* | | | | Fix various spelling errorsOtto Kekäläinen2020-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | e.g. - dont -> don't - occurence -> occurrence - succesfully -> successfully - easyly -> easily Also remove trailing space in selected files. These changes span: - server core - Connect and Innobase storage engine code - OQgraph, Sphinx and TokuDB storage engines Related to MDEV-21769.
* | | | | MDEV-21743 Split up SUPER privilege to smaller privilegesAlexander Barkov2020-03-101-2/+1
| | | | |
* | | | | cleanup: PSI key is *always* the first argumentSergei Golubchik2020-03-101-2/+2
| | | | |
* | | | | perfschema compilation, test and misc fixesSergei Golubchik2020-03-101-3/+3
| | | | |
* | | | | perfschema sp instrumentation related changesSergei Golubchik2020-03-101-19/+39
| | | | |
* | | | | perfschema mdl related instrumentation changesSergei Golubchik2020-03-101-2/+2
| | | | |
* | | | | perfschema memory related instrumentation changesSergei Golubchik2020-03-101-1/+1
| | | | |
* | | | | cleanup: remove TYPE_ENUM_PROXY from enum stored_procedure_typeSergei Golubchik2020-03-101-1/+0
| | | | | | | | | | | | | | | | | | | | because it is not
* | | | | MDEV-21581 Helper functions and methods for CHARSET_INFOAlexander Barkov2020-01-281-4/+3
| | | | |
* | | | | Merge 10.4 into 10.5Marko Mäkelä2020-01-201-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-01-201-1/+1
| |\ \ \ \ | | |/ / / | | | | | | | | | | | | | | | The MDEV-17062 fix in commit c4195305b2a8431f39a4c75cc1c66ba43685f7a0 was omitted.
| | * | | MDEV-21341: Fix UBSAN failures: Issue Sixbb-10.3-mdev21341-issueSixSergei Petrunia2020-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Variant #2 of the patch, which keeps the sp_head object inside the MEM_ROOT that sp_head object owns) (10.3 version of the fix, with handling for class sp_package) sp_head::operator new() and operator delete() were dereferencing sp_head* pointers to memory that didn't hold a valid sp_head object (it was not created/already destroyed). This caused UBSan to crash when looking up type information. Fixed by providing static sp_head::create() and sp_head::destroy() methods.
* | | | | MDEV-21497 Make Field_time, Field_datetime, Field_timestamp abstractAlexander Barkov2020-01-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Making classes Field_time, Field_datetime, Field_timestamp abstract - Adding instantiable Field_time0, Field_datetime0, Field_timestamp0 classes - Removing redundant cast in field_conv.cc, item_timefunc.cc, sp.cc in calls for set_time() and get_timestamp() - Replacing store_TIME() to store_timestamp() in log.cc and removing redundant cast
* | | | | Merge 10.4 into 10.5Oleksandr Byelkin2019-11-071-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2019-11-011-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Fixes for binary logging --read-only modeMonty2019-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Any temporary tables created under read-only mode will never be logged to binary log. Any usage of these tables to update normal tables, even after read-only has been disabled, will use row base logging (as the temporary table will not be on the slave). - Analyze, check and repair table will not be logged in read-only mode. Other things: - Removed not used varaibles in MYSQL_BIN_LOG::flush_and_set_pending_rows_event. - Set table_share->table_creation_was_logged for all normal tables. - THD::binlog_query() now returns -1 if statement was not logged., This is used to update table_share->table_creation_was_logged. - Don't log admin statements in opt_readonly is set. - Table's that doesn't have table_creation_was_logged will set binlog format to row logging. - Removed not needed/wrong setting of table->s->table_creation_was_logged in create_table_from_items()
* | | | | Using more of Sql_mode_save. Adding a similar class for THD::abort_on_warnings.Alexander Barkov2019-05-281-9/+4
|/ / / /
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ | | |/ /
| | * | Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\ \ | | | |/
| | | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\
| | | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | * Update wrong zip-code
* | | | | Added new MDL_BACKUP locks for all backup stagesMonty2018-12-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of MDEV-5336 Implement LOCK FOR BACKUP - Added new locks to MDL_BACKUP for all stages of backup locks and a new MDL lock needed for backup stages. - Renamed MDL_BACKUP_STMT to MDL_BACKUP_DDL - flush_tables() takes a new parameter that decides what should be flushed. - InnoDB, Aria (transactional tables with checksums), Blackhole, Federated and Federatedx tables are marked to be safe for online backup. We are using MDL_BACKUP_TRANS_DML instead of MDL_BACKUP_DML locks for these which allows any DML's to proceed for these tables during the whole backup process until BACKUP STAGE COMMIT which will block the final commit.