summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <konstantin@bodhi.netgear>2006-07-06 23:59:04 +0400
committerunknown <konstantin@bodhi.netgear>2006-07-06 23:59:04 +0400
commit8995277acc05f9998e9f7a24aa8cb9e1d917945e (patch)
tree3688ab01357b1d5fa6a6f036bd6ed40206160dc4 /mysql-test
parentd94521c32d9a40820e5e5f1e6175b8ee39d758b2 (diff)
downloadmariadb-git-8995277acc05f9998e9f7a24aa8cb9e1d917945e.tar.gz
A fix and a test case for Bug#19399 "res 'Lost Connection' when
dropping/creating tables". The bug could lead to a crash when multi-delete statements were prepared and used with temporary tables. The bug was caused by lack of clean-up of multi-delete tables before re-execution of a prepared statement. In a statement like DELETE t1 FROM t1, t2 WHERE ... the first table list (t1) is moved to lex->auxilliary_table_list and excluded from lex->query_tables or select_lex->tables. Thus it was unaccessible to reinit_stmt_before_use and not cleaned up before re-execution of a prepared statement. mysql-test/r/ps.result: Updated test results (Bug#19399) mysql-test/t/ps.test: A test case for Bug#19399 "Stored Procedures 'Lost Connection' when dropping/creating tables": test that multi-delete tables are cleaned up properly before re-execution. sql/sql_lex.cc: Always initialize auxilliary_table_list when we initialize the lex: this way we don't have to check that lex->sql_command equals to SQLCOM_DELETE_MULTI whenever we need to access auxilliary_table_list. In particular, in reinit_stmt_before_use we can simply check that auxilliary_table_list is not NULL and clean it up if the check returns a true value. sql/sql_prepare.cc: Move the one table clean-up functionality to a method of st_table_list. Clean up auxiliary_table_list if it's not empty. sql/table.cc: Implement st_table_list::reinit_before_use(). sql/table.h: Declare st_table_list::reinit_before_use().
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/ps.result14
-rw-r--r--mysql-test/t/ps.test25
2 files changed, 39 insertions, 0 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 2be5366b180..01aa4ddf859 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -875,3 +875,17 @@ select @@max_prepared_stmt_count, @@prepared_stmt_count;
@@max_prepared_stmt_count @@prepared_stmt_count
3 0
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
+drop table if exists t1;
+create temporary table if not exists t1 (a1 int);
+prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+deallocate prepare stmt;
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index d6dcf02d5b7..0ca293eb1ba 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -926,4 +926,29 @@ select @@max_prepared_stmt_count, @@prepared_stmt_count;
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
--enable_ps_protocol
+#
+# Bug#19399 "Stored Procedures 'Lost Connection' when dropping/creating
+# tables"
+# Check that multi-delete tables are also cleaned up before re-execution.
+#
+--disable_warnings
+drop table if exists t1;
+create temporary table if not exists t1 (a1 int);
+--enable_warnings
+# exact delete syntax is essential
+prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+# the server crashed on the next statement without the fix
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+# the problem was in memory corruption: repeat the test just in case
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+deallocate prepare stmt;
+
# End of 4.1 tests