From a63dde5a5b9a519ad2e4343c1d0b27de5bf41fc0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Apr 2008 20:01:20 +0400 Subject: Tentative implementation of WL#4165 Prepared statements: validation WL#4166 Prepared statements: automatic re-prepare Fixes Bug#27430 Crash in subquery code when in PS and table DDL changed after PREPARE Bug#27690 Re-execution of prepared statement after table was replaced with a view crashes Bug#27420 A combination of PS and view operations cause error + assertion on shutdown The basic idea of the patch is to keep track of table metadata between prepared statement prepare and execute. If some table used in the statement has changed, the prepared statement is re-prepared before execution. See WL#4165 and WL#4166 contents and comments in the code for details of the implementation. include/my_global.h: Remove 'register' keyword to avoid warnings when swapping large structures that don't fit into a register. Any modern compiler is capable of placing a variable in a register when that would benefit performance. mysql-test/r/ps_1general.result: Update test results: since now we re-prepare automatically, more correct results are produced in prepare-ddl-execute scenario. mysql-test/r/query_cache_merge.result: Ensure that the table definition cache is large enough for the test to pass in --ps-protocol mysql-test/r/trigger.result: Update test results to reflect automatic statement reprepare. mysql-test/t/disabled.def: Enable ps_ddl.test, which now passes. mysql-test/t/ps_1general.test: Since now we re-execute prepared statements after DDL successfully, change the test to produce repeatable results. Remove expectancy of an error in one place where now we automatically reprepare the prepared statement. mysql-test/t/query_cache_merge.test: Ensure the table definition cache is large enough for the test to pass in --ps-protocol mysql-test/t/trigger.test: Sinc sql/item.cc: Implement Item_param "copy" functionality, used at re-prepare of a prepared statement. We copy the type of the original parameter, and move the assigned value, if any. Sic, the value is "moved", since it can be quite big -- e.g. in case we deal with a LONG DATA parameter. It's essential to move the value from the old parameter since at the time of re-prepare the client packet with the necessary information may be not available. sql/item.h: Declare a new method used for reprepare. sql/my_decimal.h: Implement "swap()" functionality of class my_decimal to be able to easily swap two decimal values. sql/mysql_priv.h: Declare enum_metadata_type. sql/mysqld.cc: Implement a status variable for the number of reprepared statements. sql/sql_base.cc: Implement metadata version validation. sql/share/errmsg.txt: Add two new error messages: ER_NEED_REPREPARE and ER_PS_REBIND. The first error (theoretically) never reaches the user. It is issued by the metadata validation framework when a metadata version has changed between prepare and execute. Later on it's intercepted and the statement is automatically re-prepared. Only if the error has occurred repeatedly MAX_REPREPARE_ATTEMTS (3) times do we return it to the user. The second error is issued when after re-prepare we discover that the metadata we sent over to the client using the binary protocol differs drammatically from the new result set metadata that the reprepared statement produces (e.g. number of result set columns is different). sql/sql_class.cc: Implement metadata version validation framework. sql/sql_class.h: Declarations for metadata version validation framework. sql/sql_parse.cc: Mark commands for which we must invalidate and reprepare a prepared statement when metadata has changed. sql/sql_prepare.cc: Implement WL#4165 and WL#4166 (limited support of metadata validation and re-prepare). sql/table.h: Implement metadata validation. tests/mysql_client_test.c: Add a test case for WL#4166 --- mysql-test/r/trigger.result | 1 - 1 file changed, 1 deletion(-) (limited to 'mysql-test/r/trigger.result') diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index e7f5c41513b..35d5134fa6b 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -820,7 +820,6 @@ call p1(); drop trigger t1_bi; create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id); execute stmt1; -ERROR 42S02: Table 'test.t3' doesn't exist call p1(); ERROR 42S02: Table 'test.t3' doesn't exist deallocate prepare stmt1; -- cgit v1.2.1