summaryrefslogtreecommitdiff
path: root/mysql-test/r/sp-error.result
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-8466 CAST works differently for DECIMAL/INT vs DOUBLE for empty stringsAlexander Barkov2015-09-171-12/+12
| | | | MDEV-8468 CAST and INSERT work differently for DECIMAL/INT vs DOUBLE for a string with trailing spaces
* MDEV-7283 UDF: CREATE OR REPLACE, CREATE IF NOT EXISTS, DROP IF EXISTSAlexander Barkov2014-12-151-3/+1
| | | | MDEV-7282 SP: CREATE OR REPLACE, CREATE IF NOT EXISTS
* parser cleanup: don't store field properties in LEX, use Create_field directlySergei Golubchik2014-12-041-1/+1
| | | | | | | | | | | length/dec/charset are still in LEX, because they're also used for CAST and dynamic columns. also 1. fix "MDEV-7041 COLLATION(CAST('a' AS CHAR BINARY)) returns a wrong result" 2. allow BINARY modifier in stored function RETURN clause 3. allow "COLLATION without CHARSET" in SP/SF (parameters, RETURN, DECLARE) 4. print correct variable name in error messages for stored routine parameters
* merge bugfuxes for sp-error.testSergei Golubchik2013-07-121-0/+875
|
* known results differencesunknown2013-07-051-18/+3
|
* after merge changes:Sergei Golubchik2011-12-121-12/+12
| | | | | | | | | | | * rename all debugging related command-line options and variables to start from "debug-", and made them all OFF by default. * replace "MySQL" with "MariaDB" in error messages * "Cast ... converted ... integer to it's ... complement" is now a note, not a warning * @@query_cache_strip_comments now has a session scope, not global.
* merge 5.1-security->5.5-securityGeorgi Kodinov2011-06-161-0/+16
|\
| * Fixed bug#11840395 (formerly known as bug#60347: THE STRING "VERSIONDATA"Dmitry Shulga2011-06-091-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SEEMS TO BE 'LEAKING' INTO THE SCHEMA NAME SPACE) and bug#12428824 (Parser stack overflow and crash in sp_add_used_routine with obscure query). The first problem was that attempts to call a stored function by its fully qualified name ended up with unwarranted error "ERROR 1305 (42000): FUNCTION someMixedCaseDb.my_function_name does not exist" if this function belonged to a schema that had uppercase letters in its name AND --lower_case_table_names was equal to either 1 or 2. The second problem was that 5.5 version of MySQL server might have crashed when a user tried to call stored function with too long name or too long database name (i.e if a function and database name combined occupied more than 2*3*64 bytes in utf8). This issue didn't affect versions of server < 5.5. The first problem was caused by the fact that in cases when a stored function was called by its fully qualified name we didn't lowercase name of its schema before performing look up of the function in mysql.proc table even although lower_case_table_names mode was on. As result we were unable to find this function since during its creation we store lowercased version of schema name in the system table in this mode and field for schema name uses binary collation. Calls to stored functions were unaffected by this problem since for them schema name is converted to lowercase as necessary. The reason for the second bug was that MySQL Server didn't check length of function name and database name before proceeding with execution of stored function. As a consequence too long database name or function name caused buffer overruns in places where the code assumes that their length is within fixed limits, like mdl_key_init() in 5.5. Again this issue didn't affect calls to stored procedures as for them length of schema name and procedure name are properly checked. This patch fixes both these bugs by adding calls to check_db_name() and check_routine_name() to grammar rule which corresponds to a call to a stored function. These functions ensure that length of database name and function name for routine called is within standard limit. Moreover call to check_db_name() handles conversion of database name to lowercase if --lower_case_table_names mode is on. Note that even although the second issue seems to be only reproducible in 5.5 we still add code fixing it to 5.1 to be on the safe side (and make code a bit more robust against possible future changes). mysql-test/r/sp-error.result: Added testcase results for bug#12428824. mysql-test/r/sp.result: Added testcase result for bug#11840395. mysql-test/t/sp-error.test: Added testcase for bug#12428824. mysql-test/t/sp.test: Added testcase for bug#11840395. sql/sql_yacc.yy: Modified 'function_call_generic' rule to call check_db_name() and check_routine_name() in order to ensure that lengths of database name and function name are within limits. check_db_name() is also responsible for normalizing function's database name for lookup in cases when lowercase_table_names mode is on.
| * Bug#47974 'TYPE=storage_engine' is deprecated and will be Magne Mahre2010-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | removed in MySQL 6.0 CREATE TABLE... TYPE= returns the warning "The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0. Please use 'ENGINE=storage_engine' instead" This syntax is deprecated already from version 5.4.4, so the message has been changed. In addition, the deprecation macro was changed to reflect the ServerPT decision not to include version number in the warning message. A number of test result files have been changed as a consequence of the change in the deprecation macro.
* | Patch for Bug#55850 (Trigger warnings not cleared).Alexander Nozdrin2010-10-261-30/+61
| | | | | | | | | | | | | | | | The problem was that the warnings risen by a trigger were not cleared upon successful completion. The warnings should be cleared if the trigger completes successfully. The fix is to skip merging warnings into caller's Warning Info for triggers.
* | Auto-merge from mysql-trunk-bugfixing.Alexander Nozdrin2010-07-301-0/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ****** This patch fixes the following bugs: - Bug#5889: Exit handler for a warning doesn't hide the warning in trigger - Bug#9857: Stored procedures: handler for sqlwarning ignored - Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP - Bug#36185: Incorrect precedence for warning and exception handlers The problem was in the way warnings/errors during stored routine execution were handled. Prior to this patch the logic was as follows: - when a warning/an error happens: if we're executing a stored routine, and there is a handler for that warning/error, remember the handler, ignore the warning/error and continue execution. - after a stored routine instruction is executed: check for a remembered handler and activate one (if any). This logic caused several problems: - if one instruction generates several warnings (errors) it's impossible to choose the right handler -- a handler for the first generated condition was chosen and remembered for activation. - mess with handling conditions in scopes different from the current one. - not putting generated warnings/errors into Warning Info (Diagnostic Area) is against The Standard. The patch changes the logic as follows: - Diagnostic Area is cleared on the beginning of each statement that either is able to generate warnings, or is able to work with tables. - at the end of a stored routine instruction, Diagnostic Area is left intact. - Diagnostic Area is checked after each stored routine instruction. If an instruction generates several condition, it's now possible to take a look at all of them and determine an appropriate handler. mysql-test/r/signal.result: Update result file: 1. handled conditions are not cleared any more; 2. reflect changes in signal.test mysql-test/r/signal_demo3.result: Update result file: handled conditions are not cleared any more. Due to playing with max_error_count, resulting warning lists have changed. mysql-test/r/sp-big.result: Update result file: handled conditions are not cleared any more. mysql-test/r/sp-bugs.result: Update result file: handled conditions are not cleared any more. mysql-test/r/sp-code.result: Update result file: 1. handled conditions are not cleared any more. 2. add result for a new test case in sp-code.test. mysql-test/r/sp-error.result: Update result file: 1. handled conditions are not cleared any more. 2. add result for a new test case in sp-error.test. mysql-test/r/sp.result: Update result file: handled conditions are not cleared any more. mysql-test/r/sp_trans.result: Update result file: handled conditions are not cleared any more. mysql-test/r/strict.result: Update result file: handled conditions are not cleared any more. mysql-test/r/view.result: Update result file: handled conditions are not cleared any more. mysql-test/suite/funcs_1/r/innodb_storedproc_02.result: Update result file: handled conditions are not cleared any more. mysql-test/suite/funcs_1/r/memory_storedproc_02.result: Update result file: handled conditions are not cleared any more. mysql-test/suite/funcs_1/r/myisam_storedproc_02.result: Update result file: handled conditions are not cleared any more. mysql-test/suite/funcs_1/r/storedproc.result: Update result file: handled conditions are not cleared any more. mysql-test/suite/rpl/r/rpl_row_sp005.result: Update result file: handled conditions are not cleared any more. mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result: Update result file: handled conditions are not cleared any more. mysql-test/suite/rpl/r/rpl_row_trig003.result: Update result file: handled conditions are not cleared any more. mysql-test/t/signal.test: Make a test case more readable in the result file. mysql-test/t/sp-code.test: Add a test case for Bug#23032 checking that No Data takes precedence on Warning. mysql-test/t/sp-error.test: Adding test cases for: - Bug#23032 - Bug#36185 - Bug#5889 - Bug#9857 mysql-test/t/sp.test: Fixing test case to reflect behavioral changes made by the patch. sql/sp_head.cc: Reset the per-statement warning count before executing a stored procedure instruction. Move to a separate function code which checks the completion status of the executed statement and searches for a handler. Remove redundant code now that search for a handler is done after execution, errors are always pushed. sql/sp_pcontext.h: Remove unused code. sql/sp_rcontext.cc: - Polish sp_rcontext::find_handler(): use sp_rcontext::m_hfound instead of an extra local variable; - Remove sp_rcontext::handle_condition(); - Introduce sp_rcontext::activate_handler(), which prepares previously found handler for execution. - Move sp_rcontext::enter_handler() code into activate_handler(), because enter_handler() is used only from there; - Cleanups; - Introduce DBUG_EXECUTE_IF() for a test case in sp-code.test sql/sp_rcontext.h: - Remove unused code - Cleanups sql/sql_class.cc: Merge THD::raise_condition_no_handler() into THD::raise_condition(). After the patch raise_condition_no_handler() was called in raise_condition() only. sql/sql_class.h: Remove raise_condition_no_handler(). sql/sql_error.cc: Remove Warning_info::reserve_space() -- handled conditions are not cleared any more, so there is no need for RESIGNAL to re-push them. sql/sql_error.h: Remove Warning_info::reserve_space(). sql/sql_signal.cc: Handled conditions are not cleared any more, so there is no need for RESIGNAL to re-push them.
* | Bug#31767 DROP FUNCTION name resolutionMarc Alff2010-02-231-2/+2
| | | | | | | | | | Backport to 5.5.99
* | Apply and review:Konstantin Osipov2009-12-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3655 Jon Olav Hauglid 2009-10-19 Bug #30977 Concurrent statement using stored function and DROP FUNCTION breaks SBR Bug #48246 assert in close_thread_table Implement a fix for: Bug #41804 purge stored procedure cache causes mysterious hang for many minutes Bug #49972 Crash in prepared statements The problem was that concurrent execution of DML statements that use stored functions and DDL statements that drop/modify the same function might result in incorrect binary log in statement (and mixed) mode and therefore break replication. This patch fixes the problem by introducing metadata locking for stored procedures and functions. This is similar to what is done in Bug#25144 for views. Procedures and functions now are locked using metadata locks until the transaction is either committed or rolled back. This prevents other statements from modifying the procedure/function while it is being executed. This provides commit ordering - guaranteeing serializability across multiple transactions and thus fixes the reported binlog problem. Note that we do not take locks for top-level CALLs. This means that procedures called directly are not protected from changes by simultaneous DDL operations so they are executed at the state they had at the time of the CALL. By not taking locks for top-level CALLs, we still allow transactions to be started inside procedures. This patch also changes stored procedure cache invalidation. Upon a change of cache version, we no longer invalidate the entire cache, but only those routines which we use, only when a statement is executed that uses them. This patch also changes the logic of prepared statement validation. A stored procedure used by a prepared statement is now validated only once a metadata lock has been acquired. A version mismatch causes a flush of the obsolete routine from the cache and statement reprepare. Incompatible changes: 1) ER_LOCK_DEADLOCK is reported for a transaction trying to access a procedure/function that is locked by a DDL operation in another connection. 2) Procedure/function DDL operations are now prohibited in LOCK TABLES mode as exclusive locks must be taken all at once and LOCK TABLES provides no way to specifiy procedures/functions to be locked. Test cases have been added to sp-lock.test and rpl_sp.test. Work on this bug has very much been a team effort and this patch includes and is based on contributions from Davi Arnaut, Dmitry Lenev, Magne Mæhre and Konstantin Osipov. mysql-test/r/ps_ddl.result: Update results (Bug#30977). mysql-test/r/ps_ddl1.result: Update results (Bug#30977). mysql-test/r/sp-error.result: Update results (Bug#30977). mysql-test/r/sp-lock.result: Update results (Bug#30977). mysql-test/suite/rpl/r/rpl_sp.result: Update results (Bug#30977). mysql-test/suite/rpl/t/rpl_sp.test: Add a test case for Bug#30977. mysql-test/t/ps_ddl.test: Update comments. We no longer re-prepare a prepared statement when a stored procedure used in top-level CALL is changed. mysql-test/t/ps_ddl1.test: Modifying stored procedure p1 no longer invalidates prepared statement "call p1" -- we can re-use the prepared statement without invalidation. mysql-test/t/sp-error.test: Use a constant for an error value. mysql-test/t/sp-lock.test: Add test coverage for Bug#30977. sql/lock.cc: Implement lock_routine_name() - a way to acquire an exclusive metadata lock (ex- name-lock) on stored procedure/function. sql/sp.cc: Change semantics of sp_cache_routine() -- now it has an option to make sure that the routine that is cached is up to date (has the latest sp cache version). Add sp_cache_invalidate() to sp_drop_routine(), where it was missing (a bug!). Acquire metadata locks for SP DDL (ALTER/CREATE/DROP). This is the core of the fix for Bug#30977. Since caching and cache invalidation scheme was changed, make sure we don't invalidate the SP cache in the middle of a stored routine execution. At the same time, make sure we don't access stale data due to lack of invalidation. For that, change ALTER FUNCTION/PROCEDURE to not use the cache, and SHOW PROCEDURE CODE/SHOW CREATE PROCEDURE/FUNCTION to always read an up to date version of the routine from the cache. sql/sp.h: Add a helper wrapper around sp_cache_routine(). sql/sp_cache.cc: Implement new sp_cache_version() and sp_cache_flush_obsolete(). Now we flush stale routines individually, rather than all at once. sql/sp_cache.h: Update signatures of sp_cache_version() and sp_cache_flush_obsolete(). sql/sp_head.cc: Add a default initialization of sp_head::m_sp_cache_version. Remove a redundant sp_head::create(). sql/sp_head.h: Add m_sp_cache_version to sp_head class - we now keep track of every routine in the stored procedure cache, rather than of the entire cache. sql/sql_base.cc: Implement prelocking for stored routines. Validate stored routines after they were locked. Flush obsolete routines upon next access, one by one, not all at once (Bug#41804). Style fixes. sql/sql_class.h: Rename a Open_table_context method. sql/sql_parse.cc: Make sure stored procedures DDL commits the active transaction (issues an implicit commit before and after). Remove sp_head::create(), a pure redundancy. Move the semantical check during alter routine inside sp_update_routine() code in order to: - avoid using SP cache during update, it may be obsolete. - speed up and simplify the update procedure. Remove sp_cache_flush_obsolete() calls, we no longer flush the entire cache, ever, stale routines are flushed before next use, one at a time. sql/sql_prepare.cc: Move routine metadata validation to open_and_process_routine(). Fix Bug#49972 (don't swap flags at reprepare). Reset Sroutine_hash_entries in reinit_stmt_before_use(). Remove SP cache invalidation, it's now done by open_tables(). sql/sql_show.cc: Fix a warning: remove an unused label. sql/sql_table.cc: Reset mdl_request.ticket for tickets acquired for routines inlined through a view, in CHECK TABLE statement, to satisfy an MDL assert. sql/sql_update.cc: Move the cleanup of "translation items" to close_tables_for_reopen(), since it's needed in all cases when we back off, not just the back-off in multi-update. This fixes a bug when the server would crash on attempt to back off when opening tables for a statement that uses information_schema tables.
* | Bug#46374 crash, INSERT INTO t1 uses function, function modifies t1Magne Mahre2009-12-101-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | An error occuring in the execution of a stored procedure, called from do_select is masked, since the error condition is not propagated back to the caller (join->conds->val_int() returns a result value, and not an error code) An explicit check was added to see if the thd error code has been set, and if so, the loop status is set to the error state. Backport from 6.0-codebase (revid: 2617.68.31)
* | Manual resolving for the following filesAndrei Elkin2009-12-011-19/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Text conflict in mysql-test/collections/default.experimental Text conflict in mysql-test/r/show_check.result Text conflict in mysql-test/r/sp-code.result Text conflict in mysql-test/suite/binlog/r/binlog_tmp_table.result Text conflict in mysql-test/suite/rpl/t/disabled.def Text conflict in mysql-test/t/show_check.test Text conflict in mysys/my_delete.c Text conflict in sql/item.h Text conflict in sql/item_cmpfunc.h Text conflict in sql/log.cc Text conflict in sql/mysqld.cc Text conflict in sql/repl_failsafe.cc Text conflict in sql/slave.cc Text conflict in sql/sql_parse.cc Text conflict in sql/sql_table.cc Text conflict in sql/sql_yacc.yy Text conflict in storage/myisam/ha_myisam.cc Corrected results for stm_auto_increment_bug33029.reject 2009-12-01 20:01:49.000000000 +0300 <andrei> @@ -42,9 +42,6 @@ <andrei> RETURN i; <andrei> END// <andrei> CALL p1(); <andrei> -Warnings: <andrei> -Note 1592 Statement may not be safe to log in statement format. <andrei> -Note 1592 Statement may not be safe to log in statement format. There should be indeed no Note present because there is in fact autoincrement top-level query in sp() that triggers inserting in yet another auto-inc table. (todo: alert DaoGang to improve the test).
| * \ merging from 5.1 to rep+2 starting at gca(5.1, next-mr) == ↵Andrei Elkin2009-11-301-0/+16
| |\ \ | | |/ | | | | | | build@mysql.com-20091104182209-iui387z35159aoyw
| * | BUG#48048: Deprecated constructs need removal in BetonyLuis Soares2009-11-041-19/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NOTE: Backport of: bzr log -r revid:sp1r-serg@sergbook.mysql.com-20070505200319-38337 ------------------------------------------------------------ revno: 2469.263.4 committer: serg@sergbook.mysql.com timestamp: Sat 2007-05-05 13:03:19 -0700 message: Removing deprecated features: --master-XXX command-line options log_bin_trust_routine_creators table_type BACKUP TABLE ... RESTORE TABLE ... SHOW PLUGIN LOAD TABLE ... FROM MASTER LOAD DATA FROM MASTER SHOW INNODB STATUS SHOW MUTEX STATUS SHOW TABLE TYPES ... TIMESTAMP(N) ... TYPE=engine RESET SLAVE don't reset connection parameters anymore LOAD DATA: check opt_secure_file_priv before access(filename) improved WARN_DEPRECATED macro
* | | Backport the test caes for Bug#36510 from 6.0-codebase.Konstantin Osipov2009-11-211-0/+23
| | | | | | | | | | | | | | | | | | mysql-test/t/sp-error.test: Backport test of Bug#36510 (the bug itself is fixed by other backports, inc. SINGAL code).
* | | Manual merge of mysql-next-mr-runtime upstream.Davi Arnaut2009-11-191-0/+12
|\ \ \ | |_|/ |/| |
| * | Post-merge fixes for backports.Davi Arnaut2009-11-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mysql-test/r/sp-error.result: Update test case result. mysql-test/t/dirty_close.test: Dirty close does not work under embedded. mysql-test/t/sp-error.test: Use the specific error number so it won't catch other non-fatal errors.
| * | Backport of Bug#15192 to mysql-next-mrDavi Arnaut2009-11-101-0/+11
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------ revno: 2597.4.17 revision-id: sp1r-davi@mysql.com/endora.local-20080328174753-24337 parent: sp1r-anozdrin/alik@quad.opbmk-20080328140038-16479 committer: davi@mysql.com/endora.local timestamp: Fri 2008-03-28 14:47:53 -0300 message: Bug#15192 "fatal errors" are caught by handlers in stored procedures The problem is that fatal errors (e.g.: out of memory) were being caught by stored procedure exception handlers which could cause the execution to not be stopped due to a continue handler. The solution is to not call any exception handler if the error is fatal and send the fatal error to the client. mysql-test/r/sp-error.result: Add test case result for Bug#15192 mysql-test/t/sp-error.test: Add test case for Bug#15192 mysys/my_alloc.c: Pass flag to signal fatal error in memory root allocations. sql/event_data_objects.cc: Use init_sql_alloc to initialize memory roots, which uses the sql error handler to push errors. sql/ha_partition.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/item_func.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/item_subselect.cc: Remove redundant fatal error, memory root already pushes error. sql/opt_sum.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/sp_head.cc: Allocator already sets fatal error. sql/sql_class.h: A error must exist for it to be fatal. Pass flag to signal fatal error instead of calling fatal_error. sql/sql_insert.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/sql_list.h: Pass flag to signal fatal error instead of calling fatal_error. sql/sql_parse.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/sql_partition.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/sql_select.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/sql_servers.cc: Use init_sql_alloc to initialize memory roots, which uses the sql error handler to push errors. sql/sql_show.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/sql_trigger.cc: Use init_sql_alloc to initialize memory roots, which uses the sql error handler to push errors. sql/sql_update.cc: Pass flag to signal fatal error instead of calling fatal_error. sql/tztime.cc: Use init_sql_alloc to initialize memory roots, which uses the sql error handler to push errors.
* | Bug #47788: Crash in TABLE_LIST::hide_view_error on Georgi Kodinov2009-10-191-0/+16
|/ | | | | | | | | | | | | | | UPDATE + VIEW + SP + MERGE + ALTER When cleaning up the stored procedure's internal structures the flag to ignore the errors for INSERT/UPDATE IGNORE was not cleaned up. As a result error ignoring was on during name resolution. And this is an abnormal situation : the SELECT_LEX flag can be on only during query execution. Fixed by correctly cleaning up the SELECT_LEX flag when reusing the SELECT_LEX in a second execution.
* merged 5.0-bugteam to 5.1-bugteamGeorgi Kodinov2009-05-271-0/+10
|\
| * Bug #38159: Function parsing problem generates misleading error messageGeorgi Kodinov2009-05-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a more detailed error message on calling an ambiguous missing function. mysql-test/r/ps.result: Bug #38159: fixed existing tests mysql-test/r/sp-error.result: Bug #38159: test case mysql-test/t/ps.test: Bug #38159: fixed existing tests mysql-test/t/sp-error.test: Bug #38159: test case sql/item_func.cc: Bug #38159: generate more detailed error message sql/share/errmsg.txt: Bug #38159: add a more detailed error message sql/sql_derived.cc: Bug #38159: treat the detailed error message the same way as the generic one sql/sql_lex.cc: Bug #38159: - detect if the token is ambiguous and print the appropriate error. - backport is_lex_native_function() from 5.1 sql/sql_lex.h: Bug #38159: detect if the token is ambiguous and print the appropriate error. sql/sql_yacc.yy: Bug #38159: generate more detailed error message sql/table.cc: Bug #38159: treat the detailed error message the same way as the generic one
* | Bug#41077: Warning contains wrong future versionDavi Arnaut2009-02-161-1/+1
| | | | | | | | | | | | Substitute all references of MySQL version "5.2" to "6.0" in deprecation warning messages.Deprecated constructs are being removed in the 6.0 tree.
* | Merging 5.1 main into 5.1-rplMats Kindahl2008-10-231-0/+7
|\ \
| * \ mergingAlexey Botchkov2008-09-301-0/+7
| |\ \ | | |/
| | * Bug#37949 Crash if argument to SP is a subquery that returns more than one row Alexey Botchkov2008-09-291-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JOIN for the subselect wasn't cleaned if we came upon an error during sub_select() execution. That leads to the assertion failure in close_thread_tables() part of the 6.0 code backported per-file comments: mysql-test/r/sp-error.result Bug#37949 Crash if argument to SP is a subquery that returns more than one row test result mysql-test/t/sp-error.test Bug#37949 Crash if argument to SP is a subquery that returns more than one row test case sql/sp_head.cc Bug#37949 Crash if argument to SP is a subquery that returns more than one row lex->unit.cleanup() call added if not substatement
| | * Bug#33618 (Crash in sp_rcontext)unknown2008-01-231-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug 33983 (Stored Procedures: wrong end <label> syntax is accepted) The server used to crash when REPEAT or another control instruction was used in conjunction with labels and a LEAVE instruction. The crash was caused by a missing "pop" of handlers or cursors in the code representing the stored program. When executing the code in a loop, this missing "pop" would result in a stack overflow, corrupting memory. Code generation has been fixed to produce the missing h_pop/c_pop instructions. Also, the logic checking that labels at the beginning and the end of a statement are matched was incorrect, causing Bug 33983. End labels, when used, must match the label used at the beginning of a block. mysql-test/r/sp-code.result: Bug#33618 (Crash in sp_rcontext) mysql-test/r/sp-error.result: Bug 33983 (Stored Procedures: wrong end <label> syntax is accepted) mysql-test/r/sp.result: Bug#33618 (Crash in sp_rcontext) mysql-test/t/sp-code.test: Bug#33618 (Crash in sp_rcontext) mysql-test/t/sp-error.test: Bug 33983 (Stored Procedures: wrong end <label> syntax is accepted) mysql-test/t/sp.test: Bug#33618 (Crash in sp_rcontext) sql/sp_head.cc: Bug#33618 (Crash in sp_rcontext) sql/sp_head.h: Bug#33618 (Crash in sp_rcontext) sql/sp_rcontext.cc: Bug#33618 (Crash in sp_rcontext) sql/sp_rcontext.h: Bug#33618 (Crash in sp_rcontext) sql/sql_yacc.yy: Bug#33618 (Crash in sp_rcontext)
| | * Bug#28318 (CREATE FUNCTION (UDF) requires a schema) -- part IIunknown2007-10-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The root cause of the issue was that the CREATE FUNCTION grammar, for User Defined Functions, was using the sp_name rule. The sp_name rule is intended for fully qualified stored procedure names, like either ident.ident, or just ident but with a default database implicitly selected. A UDF does not have a fully qualified name, only a name (ident), and should not use the sp_name grammar fragment during parsing. The fix is to re-organize the CREATE FUNCTION grammar, to better separate: - creating UDF (no definer, can have AGGREGATE, simple ident) - creating Stored Functions (definer, no AGGREGATE, fully qualified name) With the test case provided, another issue was exposed which is also fixed: the DROP FUNCTION statement was using sp_name and also failing when no database is implicitly selected, when droping UDF functions. The fix is also to change the grammar so that DROP FUNCTION works with both the ident.ident syntax (to drop a stored function), or just the ident syntax (to drop either a UDF or a Stored Function, in the current database) mysql-test/r/sp-error.result: Adjust test results mysql-test/r/udf.result: Adjust test results mysql-test/t/sp-error.test: Adjust test results mysql-test/t/udf.test: Adjust test results sql/sql_parse.cc: CREATE UDF FUNCTION does not use a fully qualified name. sql/sql_yacc.yy: Fix grammar for CREATE / DROP FUNCTION, FOR udf Improve error messages for select no_such_function()
| | * Bug#28318 CREATE FUNCTION (UDF) requires a schemaunknown2007-10-091-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug#29816 Syntactically wrong query fails with misleading error message The core problem is that an SQL-invoked function name can be a <schema qualified routine name> that contains no <schema name>, but the mysql parser insists that all stored procedures (function, procedures and triggers) must have a <schema name>, which is not true for functions. This problem is especially visible when trying to create a function or when a query contains a syntax error after a function call (in the same query), both will fail with a "No database selected" message if the session is not attached to a particular schema, but the first one should succeed and the second fail with a "syntax error" message. Part of the fix is to revamp the sp name handling so that a schema name may be omitted for functions -- this means that the internal function name representation may not have a dot, which represents that the function doesn't have a schema name. The other part is to place schema checks after the type (function, trigger or procedure) of the routine is known. mysql-test/r/sp-error.result: Add test case result for Bug#29816 mysql-test/r/udf.result: Add test case result for Bug#28318 mysql-test/t/sp-error.test: Add test case for Bug#29816 mysql-test/t/udf.test: Add test case for Bug#28318 sql/sp.cc: Copy the (last) nul byte of the stored routine key and move name parsing code to the sp_name class constructor. sql/sp_head.cc: Revamp routine name parsing for when no schema is specified and omit dot from the qualified name if the routine is not associated with a scheme name. sql/sp_head.h: Name parsing got bigger, uninline by moving to a single unit -- the sp_head.cc file. sql/sql_yacc.yy: Only copy the schema name if one is actually set and check for schema name presence only where it's necessary.
* | | merged 5.1 main to 5.1-rplSven Sandberg2008-08-041-0/+2
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | manually resolved conflicts: Text conflict in client/mysqltest.c Contents conflict in mysql-test/include/have_bug25714.inc Text conflict in mysql-test/include/have_ndbapi_examples.inc Text conflict in mysql-test/mysql-test-run.pl Text conflict in mysql-test/suite/parts/inc/partition_check_drop.inc Text conflict in mysql-test/suite/parts/inc/partition_layout.inc Text conflict in mysql-test/suite/parts/inc/partition_layout_check1.inc Text conflict in mysql-test/suite/parts/inc/partition_layout_check2.inc Text conflict in mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result Text conflict in mysql-test/suite/parts/r/partition_alter1_1_myisam.result Text conflict in mysql-test/suite/parts/r/partition_alter1_2_myisam.result Text conflict in mysql-test/suite/parts/r/partition_alter2_myisam.result Text conflict in mysql-test/suite/parts/r/partition_alter3_innodb.result Text conflict in mysql-test/suite/parts/r/partition_alter3_myisam.result Text conflict in mysql-test/suite/parts/r/partition_basic_innodb.result Text conflict in mysql-test/suite/parts/r/partition_basic_myisam.result Text conflict in mysql-test/suite/parts/r/partition_basic_symlink_myisam.result Text conflict in mysql-test/suite/parts/r/partition_engine_myisam.result Text conflict in mysql-test/suite/parts/r/partition_syntax_myisam.result Text conflict in mysql-test/suite/rpl_ndb/t/disabled.def Text conflict in mysql-test/t/disabled.def
| * | Check warnings in servers error log as part of test caseunknown2008-04-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BitKeeper/deleted/.del-rpl_bug33931-slave.opt: Delete: mysql-test/suite/rpl/t/rpl_bug33931-slave.opt mysql-test/include/default_mysqld.cnf: Set a default name for "log-bin" mysql-test/mysql-test-run.pl: Check for warnings in mysqld error log files after each testcase, using SQL mysql-test/lib/mtr_cases.pm: Make mtr_match into a perl module mysql-test/lib/mtr_match.pm: Make mtr_match into a perl module mysql-test/lib/mtr_report.pm: Make mtr_match into a perl module Print warnings if testcase failed from warnings mysql-test/r/information_schema.result: Be more selective which databases and tables are select in the queries mysql-test/r/mysql_upgrade.result: Update result, mysql_upgrade will check _all_ databases mysql-test/r/mysqlcheck.result: Update result, mysql_upgrade should check _all_ databases mysql-test/r/sp-destruct.result: Be more selective which databases and tables are select in the queries mysql-test/r/sp-error.result: Backup and restore mysql.proc table mysql-test/r/sp-security.result: Be more selective which databases and tables are select in the queries mysql-test/r/sp.result: Be more selective which databases and tables are select in the queries mysql-test/suite/rpl/r/rpl_bug33931.result: Move the setting of debug flag into the test file instead of in -slave.opt Add supression mysql-test/suite/rpl/r/rpl_idempotency.result: Add supression Add master-slave-end.inc mysql-test/suite/rpl/t/rpl_bug33931.test: Move the setting of debug flag into the test file instead of in -slave.opt Add supression mysql-test/suite/rpl/t/rpl_idempotency.test: Add supression Add master-slave-end.inc mysql-test/t/information_schema.test: Be more selective which databases and tables are select in the queries mysql-test/t/sp-destruct.test: Be more selective which databases and tables are select in the queries mysql-test/t/sp-error.test: Backup and restore mysql.proc table mysql-test/t/sp-security.test: Be more selective which databases and tables are select in the queries mysql-test/t/sp.test: Be more selective which databases and tables are select in the queries mysql-test/include/check-warnings.test: New BitKeeper file ``mysql-test/include/check-warnings.test'' mysql-test/include/mtr_warnings.sql: New BitKeeper file ``mysql-test/include/mtr_warnings.sql''
* | | A fix for Konstantin Osipov2008-07-031-2/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug#12093 "SP not found on second PS execution if another thread drops other SP in between" and Bug#21294 "executing a prepared statement that executes a stored function which was recreat" Stored functions are resolved at prepared statement prepare only. If someone flushes the stored functions cache between prepare and execute, execution fails. The fix is to detect the situation of the cache flush and automatically reprepare the prepared statement after it. mysql-test/r/ps_ddl.result: Update results (Bug#12093 and Bug#21294, the test cases are already in the source tree). mysql-test/r/ps_ddl1.result: Update results (Bug#12093 and Bug#21294, the test cases are already in the source tree). mysql-test/r/sp-error.result: Update results (Bug#12093 and Bug#21294, the test cases are already in the source tree). mysql-test/t/ps_ddl.test: Modify the test to not expect an error where there is no error any more (Bug#12093, Bug#21294). mysql-test/t/ps_ddl1.test: Modify the test to not expect an error where there is no error any more (Bug#12093, Bug#21294). mysql-test/t/sp-error.test: Modify the test to not expect an error where there is no error any more (Bug#12093, Bug#21294). sql/sp_cache.cc: Implement sp_cache_version() -- returns the current version of a stored routines cache. sql/sp_cache.h: Declare sp_cache_version(). sql/sql_prepare.cc: Keep track of stored functions cache version, and invalidate the statement if it changed between prepared statement prepare and execute (and the statement actually uses stored routines).
* | Bug#8759 (Stored Procedures: SQLSTATE '00000' should be illegal)unknown2008-03-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed the parser to reject SQLSTATE '00000', since '00000' is the successful completion condition, and can not be caught by an exception handler in SQL. mysql-test/r/sp-error.result: Bug#8759 (Stored Procedures: SQLSTATE '00000' should be illegal) mysql-test/t/sp-error.test: Bug#8759 (Stored Procedures: SQLSTATE '00000' should be illegal) sql/sp_pcontext.cc: Bug#8759 (Stored Procedures: SQLSTATE '00000' should be illegal)
* | Bug#21801 SQL exception handlers and warningsunknown2008-02-041-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that deprecated syntax warnings were not being suppressed when the stored routine is being parsed for the first execution. It's doesn't make sense to print out deprecated syntax warnings when the routine is being executed because this kind of warning only matters when the routine is being created. The solution is to suppress deprecated syntax warnings when parsing the stored routine for loading into the cache (might mean that the routine is being executed for the first time). mysql-test/r/sp-error.result: Add test case result for Bug#21801 mysql-test/t/sp-error.test: Add test case for Bug#21801 sql/sp.cc: Implement a internal error handler to catch deprecated syntax warnings when loading a stored procedure into the cache.
* | Manual mergeunknown2008-01-231-0/+48
| |
* | Bug#30882 Dropping a temporary table inside a stored function may cause a ↵unknown2007-11-011-3/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | server crash If a stored function that contains a drop temporary table statement is invoked by a create temporary table of the same name may cause a server crash. The problem is that when dropping a table no check is done to ensure that table is not being used by some outer query (or outer statement), potentially leaving the outer query with a reference to a stale (freed) table. The solution is when dropping a temporary table, always check if the table is being used by some outer statement as a temporary table can be dropped inside stored procedures. The check is performed by looking at the TABLE::query_id value for temporary tables. To simplify this check and to solve a bug related to handling of temporary tables in prelocked mode, this patch changes the way in which this member is used to track the fact that table is used/unused. Now we ensure that TABLE::query_id is zero for unused temporary tables (which means that all temporary tables which were used by a statement should be marked as free for reuse after it's execution has been completed). mysql-test/include/handler.inc: Add test case for side effect of Bug#30882 mysql-test/r/handler_innodb.result: Add test case result for side effect of Bug#30882 mysql-test/r/handler_myisam.result: Add test case result for side effect of Bug#30882 mysql-test/r/sp-error.result: Add test case result for Bug#30882 mysql-test/t/sp-error.test: Add test case for Bug#30882 sql/event_db_repository.cc: Update close_thread_tables call, no more default values. sql/mysql_priv.h: Remove implicit default parameters values of the close_thread_tables function as no callers are using it. sql/slave.cc: Update close_thread_tables call, no more default values sql/sp_head.cc: Update close_thread_tables call, no more default values sql/sql_base.cc: Changed the approach to distinguishing currently unused temporary tables. Now we ensure that such tables always have TABLE::query_id set to 0 and use this fact to perform checks during opening and dropping of temporary tables. This means that we have to call close_thread_tables() even for statements which use only temporary tables. To make this call cheaper, we re-factored close_thread_tables() to not take LOCK_open unless there are open base tables. sql/sql_handler.cc: Properly close temporary tables associated with a handler. sql/sql_insert.cc: close_temporary_table is now merged into drop_temporary_table. sql/sql_parse.cc: Now the condition doesn't cover all cases because close_thread_tables() must be called even for statements that use only temporary tables. sql/sql_table.cc: Use drop_temporary_table which perform checks to verify if the table is not being used. Error path problem is due to a handler tables issue and is going to be addressed in bug 31397. sql/table.h: Rename previously unused clear_query_id and document the usage of query_id and open_by_handler.
* | Bug#30904 SET PASSWORD statement is non-transactionalunknown2007-10-301-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The SET PASSWORD statement is non-transactional (no explicit transaction boundaries) in nature and hence is forbidden inside stored functions and triggers, but it weren't being effectively forbidden. The implemented fix is to issue a implicit commit with every SET PASSWORD statement, effectively prohibiting these statements in stored functions and triggers. mysql-test/r/sp-error.result: Add test case result for Bug#30904 mysql-test/t/sp-error.test: Add test case for Bug#30904 sql/sql_lex.h: Add variable to set that a statement with SET PASSWORD causes a implicit commit. sql/sql_parse.cc: End active transaction in SET PASSWORD. sql/sql_yacc.yy: Set the correct flag on SET PASSWORD if inside a SP, thus effectively prohibiting SET PASSWORD statements in stored functions and triggers.
* | Manual merge of 5.0-runtime to 5.1-runtimeunknown2007-10-161-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mysql-test/r/sp-error.result: Manual merge mysql-test/r/sp.result: Manual merge mysql-test/r/udf.result: Manual merge mysql-test/t/sp.test: Manual merge mysql-test/t/udf.test: Manual merge sql/item_create.cc: Manual merge sql/sp_head.cc: Manual merge sql/sql_yacc.yy: Manual merge
* | Bug#29223 declare cursor c for SHOW .....unknown2007-10-111-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "DECLARE CURSOR FOR SHOW ..." is a syntax that currently appears to work, but is untested for some SHOW commands and does not work for other SHOW commands. Since this is an un-intended feature that leaked as a result of a coding bug (in the parser grammar), the correct fix is to fix the grammar to not accept this construct. In other words, "DECLARE CURSOR FOR SHOW <other commands that don't work>" is not considered a bug, and we will not implement other features to make all the SHOW commands usable inside a cursor just because someone exploited a bug. mysql-test/r/sp-error.result: Only allow declaring cursors for SELECT statements to avoid possible further confusion/problems. mysql-test/t/information_schema.test: Only SELECT statements are allowed in cursors. mysql-test/t/sp-error.test: Add test case for Bug#29223. Non-SELECT statements in cursors now yields a parser error. sql/sql_yacc.yy: Rework DECLARE CURSOR statement to not allow non-SELECT statements.
* | WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE <name>unknown2007-09-101-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UPGRADE) Bug 17565 (RENAME DATABASE destroys events) Bug#28360 (RENAME DATABASE destroys routines) Removed the RENAME DATABASE db1 TO db2 statement. Implemented the ALTER DATABASE db UPGRADE DATA DIRECTORY NAME statement, which has the same function. client/mysqlcheck.c: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/create.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/query_cache.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/renamedb.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/sp-code.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/sp-error.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/upgrade.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/create.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/query_cache.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/renamedb.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/sp-error.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/upgrade.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/mysql_priv.h: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_lex.h: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_parse.cc: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_prepare.cc: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_yacc.yy: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_db.cc: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
* | Bug#21975 Grant and revoke statements are non-transactionalunknown2007-08-291-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug#21422 GRANT/REVOKE possible inside stored function, probably in a trigger Bug#17244 GRANT gives strange error message when used in a stored function GRANT/REVOKE statements are non-transactional (no explicit transaction boundaries) in nature and hence are forbidden inside stored functions and triggers, but they weren't being effectively forbidden. Furthermore, the absence of implict commits makes changes made by GRANT/REVOKE statements to not be rolled back. The implemented fix is to issue a implicit commit with every GRANT/REVOKE statement, effectively prohibiting these statements in stored functions and triggers. The implicit commit also fixes the replication bug, and looks like being in concert with the behavior of DDL and administrative statements. Since this is a incompatible change, the following sentence should be added to the Manual in the very end of the 3rd paragraph, subclause 13.4.3 "Statements That Cause an Implicit Commit": "Beginning with MySQL 5.0.??, the GRANT and REVOKE statements cause an implicit commit." Patch contributed by Vladimir Shebordaev mysql-test/r/sp-error.result: Test case result for Bug#17244 mysql-test/t/sp-error.test: Test case for Bug#17244 sql/sp_head.cc: Set that a procedure with GRANT/REVOKE command has a (implicit or explicit) commit. sql/sql_parse.cc: End active transaction in SQLCOM_GRANT and SQLCOM_REVOKE, and thus effectively prohibit these statements in stored functions and triggers. An implicit commit also fixes a bug in replication, when GRANT or REVOKE would disappear from the binary log in case of a subsequent ROLLBACK, since they were considered transactional statements. mysql-test/suite/rpl/r/rpl_binlog_grant.result: Add test case result for Bug#21975 mysql-test/suite/rpl/t/rpl_binlog_grant.test: Add test case for Bug#21975
* | Patch for the following bugs:unknown2007-06-281-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - BUG#11986: Stored routines and triggers can fail if the code has a non-ascii symbol - BUG#16291: mysqldump corrupts string-constants with non-ascii-chars - BUG#19443: INFORMATION_SCHEMA does not support charsets properly - BUG#21249: Character set of SP-var can be ignored - BUG#25212: Character set of string constant is ignored (stored routines) - BUG#25221: Character set of string constant is ignored (triggers) There were a few general problems that caused these bugs: 1. Character set information of the original (definition) query for views, triggers, stored routines and events was lost. 2. mysqldump output query in client character set, which can be inappropriate to encode definition-query. 3. INFORMATION_SCHEMA used strings with mixed encodings to display object definition; 1. No query-definition-character set. In order to compile query into execution code, some extra data (such as environment variables or the database character set) is used. The problem here was that this context was not preserved. So, on the next load it can differ from the original one, thus the result will be different. The context contains the following data: - client character set; - connection collation (character set and collation); - collation of the owner database; The fix is to store this context and use it each time we parse (compile) and execute the object (stored routine, trigger, ...). 2. Wrong mysqldump-output. The original query can contain several encodings (by means of character set introducers). The problem here was that we tried to convert original query to the mysqldump-client character set. Moreover, we stored queries in different character sets for different objects (views, for one, used UTF8, triggers used original character set). The solution is - to store definition queries in the original character set; - to change SHOW CREATE statement to output definition query in the binary character set (i.e. without any conversion); - introduce SHOW CREATE TRIGGER statement; - to dump special statements to switch the context to the original one before dumping and restore it afterwards. Note, in order to preserve the database collation at the creation time, additional ALTER DATABASE might be used (to temporary switch the database collation back to the original value). In this case, ALTER DATABASE privilege will be required. This is a backward-incompatible change. 3. INFORMATION_SCHEMA showed non-UTF8 strings The fix is to generate UTF8-query during the parsing, store it in the object and show it in the INFORMATION_SCHEMA. Basically, the idea is to create a copy of the original query convert it to UTF8. Character set introducers are removed and all text literals are converted to UTF8. This UTF8 query is intended to provide user-readable output. It must not be used to recreate the object. Specialized SHOW CREATE statements should be used for this. The reason for this limitation is the following: the original query can contain symbols from several character sets (by means of character set introducers). Example: - original query: CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1; - UTF8 query (for INFORMATION_SCHEMA): CREATE VIEW v1 AS SELECT 'Hello' AS c1; client/mysqldump.c: Set original character set and collation before dumping definition query. include/my_sys.h: Move out-parameter to the end of list. mysql-test/lib/mtr_report.pl: Ignore server-warnings during the test case. mysql-test/r/create.result: Update result file. mysql-test/r/ctype_cp932_binlog_stm.result: Update result file. mysql-test/r/events.result: Update result file. mysql-test/r/events_bugs.result: Update result file. mysql-test/r/events_grant.result: Update result file. mysql-test/r/func_in.result: Update result file. mysql-test/r/gis.result: Update result file. mysql-test/r/grant.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/lowercase_view.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/ndb_sp.result: Update result file. mysql-test/r/ps.result: Update result file. mysql-test/r/rpl_replicate_do.result: Update result file. mysql-test/r/rpl_sp.result: Update result file. mysql-test/r/rpl_trigger.result: Update result file. mysql-test/r/rpl_view.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/r/skip_grants.result: Update result file. mysql-test/r/sp-destruct.result: Update result file. mysql-test/r/sp-error.result: Update result file. mysql-test/r/sp-security.result: Update result file. mysql-test/r/sp.result: Update result file. mysql-test/r/sql_mode.result: Update result file. mysql-test/r/system_mysql_db.result: Update result file. mysql-test/r/temp_table.result: Update result file. mysql-test/r/trigger-compat.result: Update result file. mysql-test/r/trigger-grant.result: Update result file. mysql-test/r/trigger.result: Update result file. mysql-test/r/view.result: Update result file. mysql-test/r/view_grant.result: Update result file. mysql-test/t/events.test: Update test case (new columns added). mysql-test/t/information_schema.test: Update test case (new columns added). mysql-test/t/show_check.test: Test case for SHOW CREATE TRIGGER in prepared statements and stored routines. mysql-test/t/sp-destruct.test: Update test case (new columns added). mysql-test/t/sp.test: Update test case (new columns added). mysql-test/t/view.test: Update test. mysys/charset.c: Move out-parameter to the end of list. scripts/mysql_system_tables.sql: Add new columns to mysql.proc and mysql.event. scripts/mysql_system_tables_fix.sql: Add new columns to mysql.proc and mysql.event. sql/event_data_objects.cc: Support new attributes for events. sql/event_data_objects.h: Support new attributes for events. sql/event_db_repository.cc: Support new attributes for events. sql/event_db_repository.h: Support new attributes for events. sql/events.cc: Add new columns to SHOW CREATE event resultset. sql/mysql_priv.h: 1. Introduce Object_creation_ctx; 2. Introduce SHOW CREATE TRIGGER; 3. Introduce auxilary functions. sql/sp.cc: Add support for new store routines attributes. sql/sp_head.cc: Add support for new store routines attributes. sql/sp_head.h: Add support for new store routines attributes. sql/sql_lex.cc: Generate UTF8-body on parsing/lexing. sql/sql_lex.h: 1. Generate UTF8-body on parsing/lexing. 2. Introduce SHOW CREATE TRIGGER. sql/sql_parse.cc: Introduce SHOW CREATE TRIGGER. sql/sql_partition.cc: Update parse_sql(). sql/sql_prepare.cc: Update parse_sql(). sql/sql_show.cc: Support new attributes for views sql/sql_trigger.cc: Support new attributes for views sql/sql_trigger.h: Support new attributes for views sql/sql_view.cc: Support new attributes for views sql/sql_yacc.yy: 1. Add SHOW CREATE TRIGGER statement. 2. Generate UTF8-body for views, stored routines, triggers and events. sql/table.cc: Introduce Object_creation_ctx. sql/table.h: Introduce Object_creation_ctx. sql/share/errmsg.txt: Add new errors. mysql-test/include/ddl_i18n.check_events.inc: Aux file for test suite. mysql-test/include/ddl_i18n.check_sp.inc: Aux file for test suite. mysql-test/include/ddl_i18n.check_triggers.inc: Aux file for test suite. mysql-test/include/ddl_i18n.check_views.inc: Aux file for test suite. mysql-test/include/have_cp1251.inc: Aux file for test suite. mysql-test/include/have_cp866.inc: Aux file for test suite. mysql-test/include/have_koi8r.inc: Aux file for test suite. mysql-test/include/have_utf8.inc: Aux file for test suite. mysql-test/r/ddl_i18n_koi8r.result: Result file. mysql-test/r/ddl_i18n_utf8.result: Result file. mysql-test/r/have_cp1251.require: Aux file for test suite. mysql-test/r/have_cp866.require: Aux file for test suite. mysql-test/r/have_koi8r.require: Aux file for test suite. mysql-test/r/have_utf8.require: Aux file for test suite. mysql-test/t/ddl_i18n_koi8r.test: Complete koi8r test case for the CS patch. mysql-test/t/ddl_i18n_utf8.test: Complete utf8 test case for the CS patch.
* | Merge adventure.(none):/home/thek/Development/cpp/bug28846/my50-bug28846unknown2007-06-221-2/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into adventure.(none):/home/thek/Development/cpp/bug28846/my51-bug28846 mysql-test/r/ps_1general.result: Auto merged mysql-test/r/sp-dynamic.result: Auto merged mysql-test/r/sp-error.result: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/sp-error.test: Auto merged sql/sql_class.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_view.cc: Auto merged sql/sql_yacc.yy: Manual merge 5.0->5.1
| * Bug#28846 Use of undocumented Prepared Statements crashes serverunknown2007-06-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ALTER VIEW is currently not supported as a prepared statement and should be disabled as such as they otherwise could cause server crashes. ALTER VIEW is currently not supported when called from stored procedures or functions for related reasons and should also be disabled. This patch disables these DDL statements and adjusts the appropriate test cases accordingly. Additional tests has been added to reflect on the fact that we do support CREATE/ALTER/DROP TABLE for Prepared Statements (PS), Stored Procedures (SP) and PS within SP. mysql-test/r/ps_1general.result: - Updated test to reflect on the new policy to disallow ALTER VIEW within SP. mysql-test/r/sp-dynamic.result: - Added PS ALTER TABLE test from within SP-context to demonstrate that CREATE/ALTER/DROP TABLE statements is working. - Added PS CREATE/ALTER/DROP VIEW tests from within SP-context to show that ALTER VIEW is not supported, CREATE VIEW/DROP VIEW are supported. mysql-test/r/sp-error.result: - Updated test to reflect on the new policy to disallow VIEW DDL within SP. mysql-test/t/ps_1general.test: - Updated test to reflect on the new policy to disallow VIEW DDL within SP. mysql-test/t/sp-dynamic.test: - Add PS ALTER TABLE test from within SP to demonstrate that CREATE/ALTER/DROP TABLE statements are supported. mysql-test/t/sp-error.test: - Updated test to reflect on the new policy to disallow ALTER VIEW within SP-context. - Changed error code 1314 to the more abstract ER_SP_BADSTATEMENT. sql/sql_class.h: - Added comment for clarity sql/sql_parse.cc: - Added comment for clarity sql/sql_prepare.cc: - Disallow ALTER VIEW as prepared statements until they are properly supported. Note that SQLCOM_CREATE_VIEW also handles ALTER VIEW statements. sql/sql_view.cc: - converted to doxygen comments - Added comment for clarity sql/sql_yacc.yy: - Disallow ALTER VIEW statements within a SP. If the parser is operating within the SP context, this is shown on the sp->sphead pointer. If this flag is set for view DDL operations we stop parsing with the error 'ER_SP_BAD_STATEMENT'.
* | Merge vajra.(none):/opt/local/work/mysql-5.0-runtimeunknown2007-05-181-3/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into vajra.(none):/opt/local/work/mysql-5.1-runtime mysql-test/r/sp-error.result: Auto merged mysql-test/r/sp-prelocking.result: Auto merged mysql-test/r/trigger.result: Auto merged mysql-test/t/sp-error.test: Auto merged mysql-test/t/sp-prelocking.test: Auto merged mysql-test/t/trigger.test: Auto merged sql/sql_base.cc: Auto merged
| * Bug #27907 "Misleading error message when opening/locking tables"unknown2007-05-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjust the check that defines the error message to be returned. mysql-test/r/sp-error.result: Update results (more accurate error code) mysql-test/r/sp-prelocking.result: Update results (more accurate error code) mysql-test/r/trigger.result: Update results (more accurate error code) mysql-test/t/sp-error.test: ER_NOT_LOCKED -> ER_NO_SUCH_TABLE mysql-test/t/sp-prelocking.test: Add a test case for Bug#27907 mysql-test/t/trigger.test: ER_NOT_LOCKED -> ER_NO_SUCH_TABLE sql/sql_base.cc: Adjust the check for where-we-are for a better error message.
| * Bug#26503 (Illegal SQL exception handler code causes the server to crash)unknown2007-03-141-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this fix, the parser would accept illegal code in SQL exceptions handlers, that later causes the runtime to crash when executing the code, due to memory violations in the exception handler stack. The root cause of the problem is instructions within an exception handler that jumps to code located outside of the handler. This is illegal according to the SQL 2003 standard, since labels located outside the handler are not supposed to be visible (they are "out of scope"), so any instruction that jumps to these labels, like ITERATE or LEAVE, should not parse. The section of the standard that is relevant for this is : SQL:2003 SQL/PSM (ISO/IEC 9075-4:2003) section 13.1 <compound statement>, syntax rule 4 <quote> The scope of the <beginning label> is CS excluding every <SQL schema statement> contained in CS and excluding every <local handler declaration list> contained in CS. <beginning label> shall not be equivalent to any other <beginning label>s within that scope. </quote> With this fix, the C++ class sp_pcontext, which represent the "parsing context" tree (a.k.a symbol table) of a stored procedure, has been changed as follows: - constructors have been cleaned up, so that only building a root node for the tree is public; building nodes inside a tree is not public. - a new member, m_label_scope, indicates if a given syntactic context belongs to a DECLARE HANDLER block, - label resolution, in the method find_label(), has been changed to implement the restriction of scope regarding labels used in a compound statement. The actions in the parser, when parsing the body of a SQL exception handler, have been changed as follows: - the implementation of an exception handler (DECLARE HANDLER) now creates explicitly a new sp_pcontext, to isolate the code inside the handler from the containing compound statement context. - registering exception handlers as a result occurs in the parent context, see the rule sp_hcond_element - the code in sp_hcond_list has been cleaned up, to avoid code duplication In addition, the flags IN_SIMPLE_CASE and IN_HANDLER, declared in sp_head.h have been removed, since they are unused and broken by design (as seen with Bug 19194 (Right recursion in parser for CASE causes excessive stack usage, limitation), representing a stack in a single flag is not possible. Tests in sp-error have been added to show that illegal constructs are now rejected. Tests in sp have been added for code coverage, to show that ITERATE or LEAVE statements are legal when jumping to a label in scope, inside the body of an exception handler. mysql-test/r/sp-error.result: SQL Exception handlers define a parsing context for label resolution. mysql-test/r/sp.result: SQL Exception handlers define a parsing context for label resolution. mysql-test/t/sp-error.test: SQL Exception handlers define a parsing context for label resolution. mysql-test/t/sp.test: SQL Exception handlers define a parsing context for label resolution. sql/sp_head.cc: Minor cleanup sql/sp_head.h: Minor cleanup sql/sp_pcontext.cc: SQL Exception handlers define a parsing context for label resolution. sql/sp_pcontext.h: SQL Exception handlers define a parsing context for label resolution. sql/sql_yacc.yy: SQL Exception handlers define a parsing context for label resolution.
| * Bug#8407 (Stored functions/triggers ignore exception handler)unknown2007-03-051-6/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug 18914 (Calling certain SPs from triggers fail) Bug 20713 (Functions will not not continue for SQLSTATE VALUE '42S02') Bug 21825 (Incorrect message error deleting records in a table with a trigger for inserting) Bug 22580 (DROP TABLE in nested stored procedure causes strange dependency error) Bug 25345 (Cursors from Functions) This fix resolves a long standing issue originally reported with bug 8407, which affect the behavior of Stored Procedures, Stored Functions and Trigger in many different ways, causing symptoms reported by all the bugs listed. In all cases, the root cause of the problem traces back to 8407 and how the server locks tables involved with sub statements. Prior to this fix, the implementation of stored routines would: - compute the transitive closure of all the tables referenced by a top level statement - open and lock all the tables involved - execute the top level statement "transitive closure of tables" means collecting: - all the tables, - all the stored functions, - all the views, - all the table triggers - all the stored procedures involved, and recursively inspect these objects definition to find more references to more objects, until the list of every object referenced does not grow any more. This mechanism is known as "pre-locking" tables before execution. The motivation for locking all the tables (possibly) used at once is to prevent dead locks. One problem with this approach is that, if the execution path the code really takes during runtime does not use a given table, and if the table is missing, the server would not execute the statement. This in particular has a major impact on triggers, since a missing table referenced by an update/delete trigger would prevent an insert trigger to run. Another problem is that stored routines might define SQL exception handlers to deal with missing tables, but the server implementation would never give user code a chance to execute this logic, since the routine is never executed when a missing table cause the pre-locking code to fail. With this fix, the internal implementation of the pre-locking code has been relaxed of some constraints, so that failure to open a table does not necessarily prevent execution of a stored routine. In particular, the pre-locking mechanism is now behaving as follows: 1) the first step, to compute the transitive closure of all the tables possibly referenced by a statement, is unchanged. 2) the next step, which is to open all the tables involved, only attempts to open the tables added by the pre-locking code, but silently fails without reporting any error or invoking any exception handler is the table is not present. This is achieved by trapping internal errors with Prelock_error_handler 3) the locking step only locks tables that were successfully opened. 4) when executing sub statements, the list of tables used by each statements is evaluated as before. The tables needed by the sub statement are expected to be already opened and locked. Statement referencing tables that were not opened in step 2) will fail to find the table in the open list, and only at this point will execution of the user code fail. 5) when a runtime exception is raised at 4), the instruction continuation destination (the next instruction to execute in case of SQL continue handlers) is evaluated. This is achieved with sp_instr::exec_open_and_lock_tables() 6) if a user exception handler is present in the stored routine, that handler is invoked as usual, so that ER_NO_SUCH_TABLE exceptions can be trapped by stored routines. If no handler exists, then the runtime execution will fail as expected. With all these changes, a side effect is that view security is impacted, in two different ways. First, a view defined as "select stored_function()", where the stored function references a table that may not exist, is considered valid. The rationale is that, because the stored function might trap exceptions during execution and still return a valid result, there is no way to decide when the view is created if a missing table really cause the view to be invalid. Secondly, testing for existence of tables is now done later during execution. View security, which consist of trapping errors and return a generic ER_VIEW_INVALID (to prevent disclosing information) was only implemented at very specific phases covering *opening* tables, but not covering the runtime execution. Because of this existing limitation, errors that were previously trapped and converted into ER_VIEW_INVALID are not trapped, causing table names to be reported to the user. This change is exposing an existing problem, which is independent and will be resolved separately. mysql-test/r/information_schema_db.result: Revised the pre-locking code implementation, aligned the tests. mysql-test/r/sp-error.result: Revised the pre-locking code implementation, aligned the tests. mysql-test/r/sp.result: Revised the pre-locking code implementation, aligned the tests. mysql-test/r/trigger.result: Revised the pre-locking code implementation, aligned the tests. mysql-test/r/view.result: Revised the pre-locking code implementation, aligned the tests. mysql-test/t/sp-error.test: Revised the pre-locking code implementation, aligned the tests. mysql-test/t/sp.test: Revised the pre-locking code implementation, aligned the tests. mysql-test/t/trigger.test: Revised the pre-locking code implementation, aligned the tests. sql/lock.cc: table->placeholder now checks for schema_table sql/mysqld.cc: my_message_sql(): invoke internal exception handlers sql/sp_head.cc: exec_open_and_lock_tables(): open and lock tables, or return the continuation destination of this instruction sql/sp_head.h: exec_open_and_lock_tables(): open and lock tables, or return the continuation destination of this instruction sql/sql_base.cc: Prelock_error_handler: delay open table errors until execution sql/sql_class.cc: THD: add internal error handler, as an exception mechanism. sql/sql_class.h: THD: add internal error handler, as an exception mechanism. sql/sql_update.cc: table->placeholder now checks for schema_table sql/table.cc: st_table_list::hide_view_error(): masked more errors for view security sql/table.h: table->placeholder now checks for schema_table, and unopened tables