summaryrefslogtreecommitdiff
path: root/sql/sp.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge bb-10.2-ext into 10.3Marko Mäkelä2017-10-041-7/+7
|\
| * Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2017-10-021-7/+7
| |\
| | * MDEV-13844 : Fix Windows warnings. Fix DBUG_PRINT.Vladislav Vaintroub2017-09-281-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fix win64 pointer truncation warnings (usually coming from misusing 0x%lx and long cast in DBUG) - Also fix printf-format warnings Make the above mentioned warnings fatal. - fix pthread_join on Windows to set return value.
* | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-09-071-0/+1
|\ \ \ | |/ /
| * | Merge 10.2 into bb-10.2-extMarko Mäkelä2017-09-071-0/+1
| |\ \ | | |/
| | * Merge 10.1 into 10.2Marko Mäkelä2017-09-061-0/+1
| | |\
| | | * MDEV-10972: Insert from select / view / union -- repeatable crash in 10.1, ↵Oleksandr Byelkin2017-09-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 10.2 Linux/Mac/Windows save thd->select_number between parsing and executions (in case it was not complete executed due to errors (for example epsent table))
* | | | Added DBUG_ASSERT_AS_PRINTF compile flagMonty2017-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If compiling a non DBUG binary with -DDBUG_ASSERT_AS_PRINTF asserts will be changed to printf + stack trace (of stack trace are enabled). - Changed #ifndef DBUG_OFF to #ifdef DBUG_ASSERT_EXISTS for those DBUG_OFF that was just used to enable assert - Assert checking that could greatly impact performance where changed to DBUG_ASSERT_SLOW which is not affected by DBUG_ASSERT_AS_PRINTF - Added one extra option to my_print_stacktrace() to get more silent in case of stack trace printing as part of assert.
* | | | Enusure that my_global.h is included firstMichael Widenius2017-08-241-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added sql/mariadb.h file that should be included first by files in sql directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables that must be done before my_global.h is included) - Removed a lot of include my_global.h from include files - Removed include's of some files that my_global.h automatically includes - Removed duplicated include's of my_sys.h - Replaced include my_config.h with my_global.h
* | | MDEV-13450 Cleanup SP code for packagesAlexander Barkov2017-08-041-84/+123
| | |
* | | MDEV-13419 Cleanup for Sp_handler::show_create_spAlexander Barkov2017-08-011-21/+22
| | |
* | | MDEV-13415 Wrap the code in sp.cc into a class Sp_handlerAlexander Barkov2017-07-311-206/+192
| | |
* | | MDEV-13414 Fix the SP code to avoid excessive use of strlenAlexander Barkov2017-07-311-155/+143
| | |
* | | MDEV-13302 Avoid using LEX::spname during CREATE PROCEDURE and CREATE FUNCTIONAlexander Barkov2017-07-121-5/+6
| | |
* | | MDEV-13298 Change sp_head::m_chistics from a pointer to a structureAlexander Barkov2017-07-121-39/+33
| | |
* | | MDEV-13245 Add struct AUTHIDAlexander Barkov2017-07-051-1/+1
| | |
* | | Adding the "const" qualifier to st_sp_chistics parameters in a few functions.Alexander Barkov2017-06-301-4/+4
| | |
* | | Merge tag 'mariadb-10.2.6' into bb-10.2-extAlexander Barkov2017-05-261-2/+2
|\ \ \ | |/ /
| * | Merge branch '10.1' into 10.2Sergei Golubchik2017-05-091-2/+2
| |\ \ | | |/ | | | | | | | | | Revert commit db0917f68f, because the fix for MDEV-12696 is coming from 5.5 and 10.1 in this merge.
| | * Merge branch '10.0' 10.1Sergei Golubchik2017-04-281-2/+2
| | |\
| | | * Merge branch '5.5' into 10.0Sergei Golubchik2017-04-211-2/+2
| | | |\
| | | | * Merge remote-tracking branch 'mysql/5.5' into 5.5mariadb-5.5.55Sergei Golubchik2017-04-111-3/+3
| | | | |\
| | | | | * (no commit message)Arun Kuruvila2016-11-281-2/+2
| | | | | |
| | | | * | Fix for bug#11759114 - '51401: GRANT TREATS NONEXISTENTDmitry Lenev2017-02-271-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FUNCTIONS/PRIVILEGES DIFFERENTLY'. The problem was that attempt to grant EXECUTE or ALTER ROUTINE privilege on stored procedure which didn't exist succeed instead of returning an appropriate error like it happens in similar situation for stored functions or tables. The code which handles granting of privileges on individual routine calls sp_exist_routines() function to check if routine exists and assumes that the 3rd parameter of the latter specifies whether it should check for existence of stored procedure or function. In practice, this parameter had completely different meaning and, as result, this check was not done properly for stored procedures. This fix addresses this problem by bringing sp_exist_routines() signature and code in line with expectation of its caller.
| | * | | | Followup for 2783fc7: return an error to the caller if mysql.proc cannot be ↵mariadb-10.1.13Oleksandr Byelkin2016-03-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | opened
* | | | | | Changing field::field_name and Item::name to LEX_CSTRINGMonty2017-04-231-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benefits of this patch: - Removed a lot of calls to strlen(), especially for field_string - Strings generated by parser are now const strings, less chance of accidently changing a string - Removed a lot of calls with LEX_STRING as parameter (changed to pointer) - More uniform code - Item::name_length was not kept up to date. Now fixed - Several bugs found and fixed (Access to null pointers, access of freed memory, wrong arguments to printf like functions) - Removed a lot of casts from (const char*) to (char*) Changes: - This caused some ABI changes - lex_string_set now uses LEX_CSTRING - Some fucntions are now taking const char* instead of char* - Create_field::change and after changed to LEX_CSTRING - handler::connect_string, comment and engine_name() changed to LEX_CSTRING - Checked printf() related calls to find bugs. Found and fixed several errors in old code. - A lot of changes from LEX_STRING to LEX_CSTRING, especially related to parsing and events. - Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING* - Some changes for char* to const char* - Added printf argument checking for my_snprintf() - Introduced null_clex_str, star_clex_string, temp_lex_str to simplify code - Added item_empty_name and item_used_name to be able to distingush between items that was given an empty name and items that was not given a name This is used in sql_yacc.yy to know when to give an item a name. - select table_name."*' is not anymore same as table_name.* - removed not used function Item::rename() - Added comparision of item->name_length before some calls to my_strcasecmp() to speed up comparison - Moved Item_sp_variable::make_field() from item.h to item.cc - Some minimal code changes to avoid copying to const char * - Fixed wrong error message in wsrep_mysql_parse() - Fixed wrong code in find_field_in_natural_join() where real_item() was set when it shouldn't - ER_ERROR_ON_RENAME was used with extra arguments. - Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already give the error. TODO: - Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c - Change code to not modify LEX_CSTRING for database name (as part of lower_case_table_names)
* | | | | | Adding the const quafilier to "sp_name *" parameters in a few routine.Alexander Barkov2017-04-111-11/+13
| | | | | |
* | | | | | MDEV-10411 Providing compatibility for basic PL/SQL constructsAlexander Barkov2017-04-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part 13: RETURN vs RETURNS in function definition: CREATE FUNCTION f1(a INT) RETURN INT ... Part 12: No parentheses if no arguments: CREATE FUNCTION f1 RETURN INT ...
* | | | | | Reusing code: Adding LEX::make_sp_head() and LEX::make_sp_head_no_recursive()Alexander Barkov2017-04-051-4/+2
| | | | | |
* | | | | | MDEV-12415 Remove sp_name::m_qnameAlexander Barkov2017-03-311-16/+2
|/ / / / /
* | | | | MDEV-11597 Assertion when doing select from virtual column with impossible valueMonty2017-01-111-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Changed error handlers interface so that they can change error level in the handler - Give warnings and errors when calculating virtual columns - On insert/update error is fatal in strict mode. - SELECT and DELETE will only give a warning if a virtual field generates an error - Added VCOL_UPDATE_FOR_DELETE and VCOL_UPDATE_INDEX_FOR_REPLACE to be able to easily detect in update_virtual_fields() if we should use an error handler to mask errors or not.
* | | | | Use sql_mode_t for sql_mode.Monty2016-10-051-9/+10
| | | | | | | | | | | | | | | | | | | | This fixed several cases where we where using just ulong for sql_mode
* | | | | after merge fixesSergei Golubchik2016-03-231-0/+1
|/ / / /
* | | | MDEV-717 LP:1003679 - Wrong binlog order on concurrent DROP schema and ↵Alexey Botchkov2016-03-231-27/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CREATE function. The cause of the issue is when DROP DATABASE takes metadata lock and is in progress through it's execution, a concurrently running CREATE FUNCTION checks for the existence of database which it succeeds and then it waits on the metadata lock. Once DROP DATABASE writes to BINLOG and finally releases the metadata lock on schema object, the CREATE FUNCTION waiting on metadata lock gets in it's code path and succeeds and writes to binlog.
* | | | Merge branch '10.0' into 10.1Sergei Golubchik2015-09-031-12/+10
|\ \ \ \ | |/ / / | | | | | | | | | | | | referenced_by_foreign_key2(), needed for InnoDB to compile, was taken from 10.0-galera
| * | | MDEV-5997 - MySQL bug#11759114 - '51401: GRANT TREATS NONEXISTENTDmitry Lenev2015-07-231-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FUNCTIONS/PRIVILEGES DIFFERENTLY' Fix for bug#11759114 - '51401: GRANT TREATS NONEXISTENT FUNCTIONS/PRIVILEGES DIFFERENTLY'. The problem was that attempt to grant EXECUTE or ALTER ROUTINE privilege on stored procedure which didn't exist succeed instead of returning an appropriate error like it happens in similar situation for stored functions or tables. The code which handles granting of privileges on individual routine calls sp_exist_routines() function to check if routine exists and assumes that the 3rd parameter of the latter specifies whether it should check for existence of stored procedure or function. In practice, this parameter had completely different meaning and, as result, this check was not done properly for stored procedures. This fix addresses this problem by bringing sp_exist_routines() signature and code in line with expectation of its caller. Conflicts: mysql-test/r/grant.result mysql-test/t/grant.test sql/sp.cc
* | | | - Renaming variables so that they don't shadow others (After this patch one ↵Monty2015-07-061-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | can compile with -Wshadow and get much fewer warnings) - Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function. - Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined. - Removing calls to current_thd when we have access to thd Part of this is optimization (not calling current_thd when not needed), but part is bug fixing for error condition when current_thd is not defined (For example on startup and end of mysqld) Notable renames done as otherwise a lot of functions would have to be changed: - In JOIN structure renamed: examined_rows -> join_examined_rows record_count -> join_record_count - In Field, renamed new_field() to make_new_field() Other things: - Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe. - Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly - Added 'thd' as argument to a few functions to avoid calling current_thd.
* | | | Merge tag 'mariadb-10.0.19' into 10.1Sergei Golubchik2015-06-011-1/+5
|\ \ \ \ | |/ / /
| * | | Merge branch '5.5' into 10.0Sergei Golubchik2015-05-041-1/+5
| |\ \ \ | | |/ /
| | * | post-merge changes, fixes, and testsSergei Golubchik2015-04-281-7/+2
| | | |
| | * | Merge remote-tracking branch 'mysql/5.5' into 5.5Sergei Golubchik2015-04-271-1/+10
| | |\ \ | | | |/
| | | * BUG#19875331 - HANDLE_FATAL_SIGNAL 11 IN STRMAKEThayumanavar2015-01-191-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem Description And Fix: Inserting a fudged record in mysql.proc with the dbname column value as test and the name column as empty, will cause a crash in mysqld when we run the command DROP DATABASE test. During DROP DATABASE test, mysql_rm_db subsequently calls lock_db_routines. In the routine we fetch the field 'name' from mysql.proc by calling the underlying storage engine API in lock_db_routines. This cause NULL value as the field column of mysql.proc and subsequent dereference MDL_request::init leads to crash. Modifying mysql.proc using SQL command by user is not supported, but in principle, there is a possibility of mysql.proc getting corrupted which can also lead to empty fields and arbitary values. The patch fixes the crash by checking NULL and propagating the appopriate error code to the user.
| | | * Bug #14036214 MYSQLD CRASHES WHEN EXECUTING UPDATE IN TRX WITHAnnamalai Gurusami2012-10-081-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CONSISTENT SNAPSHOT OPTION A transaction is started with a consistent snapshot. After the transaction is started new indexes are added to the table. Now when we issue an update statement, the optimizer chooses an index. When the index scan is being initialized via ha_innobase::change_active_index(), InnoDB reports the error code HA_ERR_TABLE_DEF_CHANGED, with message stating that "insufficient history for index". This error message is propagated up to the SQL layer. But the my_error() api is never called. The statement level diagnostics area is not updated with the correct error status (it remains in Diagnostics_area::DA_EMPTY). Hence the following check in the Protocol::end_statement() fails. 516 case Diagnostics_area::DA_EMPTY: 517 default: 518 DBUG_ASSERT(0); 519 error= send_ok(thd->server_status, 0, 0, 0, NULL); 520 break; The fix is to backport the fix of bugs 14365043, 11761652 and 11746399. 14365043 PROTOCOL::END_STATEMENT(): ASSERTION `0' FAILED 11761652 HA_RND_INIT() RESULT CODE NOT CHECKED 11746399 RETURN VALUES OF HA_INDEX_INIT() AND INDEX_INIT() IGNORED rb://1227 approved by guilhem and mattiasj.
| | | * Updated/added copyright headersKent Boortz2011-07-041-2/+50
| | | |\
| | | | * Manual merge of patch for bug#11756013 from mysql-5.1 tree.Dmitry Shulga2011-06-241-1/+48
| | | | |\
| | | | | * Fixed Bug#11756013 (formerly known as bug#47870):Dmitry Shulga2011-06-231-1/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BOGUS "THE TABLE MYSQL.PROC IS MISSING,..." There was a race condition between loading a stored routine (function/procedure/trigger) specified by fully qualified name SCHEMA_NAME.PROC_NAME and dropping the stored routine database. The problem was that there is a window for race condition when one server thread tries to load a stored routine being executed and the other thread tries to drop the stored routine schema. This condition race window exists in implementation of function mysql_change_db() called by db_load_routine() during loading of stored routine to cache. Function mysql_change_db() calls check_db_dir_existence() that might failed because specified database was dropped during concurrent execution of DROP SCHEMA statement. db_load_routine() calls mysql_change_db() with flag 'force_switch' set to 'true' value so when referenced db is not found then my_error() is not called and function mysql_change_db() returns ok. This shadows information about schema opening error in db_load_routine(). Then db_load_routine() makes attempt to parse stored routine that is failed. This makes to return error to sp_cache_routines_and_add_tables_aux() but since during error generation a call to my_error wasn't made and hence THD::main_da wasn't set we set the generic "mysql.proc table corrupt" error when running sp_cache_routines_and_add_tables_aux(). The fix is to install an error handler inside db_load_routine() for the mysql_op_change_db() call, and check later if the ER_BAD_DB_ERROR was caught.
| | | * | | Updated/added copyright headersKent Boortz2011-06-301-2/+2
| | | |\ \ \ | | | | |/ / | | | |/| |
| | | | * | Updated/added copyright headersKent Boortz2011-06-301-2/+4
| | | | |\ \ | | | | | |/ | | | | |/|
| | | | | * Updated/added copyright headersKent Boortz2011-06-301-2/+3
| | | | | |
| | | | | * Bug #45287: phase 2 : 5.0 64 bit compilation warningsGeorgi Kodinov2009-07-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed various compilation warnings when compiling on a 64 bit windows.