summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-09-29 14:48:57 +0300
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-09-29 14:48:57 +0300
commit5591295cd42b548f4ca96b0081af6f729649dc15 (patch)
treefd910c5a5197283ec0acc6b546e6cbb8bb9338e6
parent292e1af26e0c6921f6b36ca30dbda104e8e7a8d2 (diff)
parentb76277fce5a375b931ae2f967e26956539eb1ffc (diff)
downloadmariadb-git-5591295cd42b548f4ca96b0081af6f729649dc15.tar.gz
merge
-rw-r--r--mysql-test/r/ps.result20
-rw-r--r--mysql-test/t/ps.test11
-rw-r--r--sql/sql_prepare.cc4
3 files changed, 34 insertions, 1 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 0e75ebd57ec..96e6fc196a9 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -3005,6 +3005,26 @@ EXECUTE stmt;
1
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
+#
+# Bug#54494 crash with explain extended and prepared statements
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2);
+PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1';
+EXECUTE stmt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+Warnings:
+Note 1003 select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1
+EXECUTE stmt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+Warnings:
+Note 1003 select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
End of 5.1 tests.
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index f7ce70c1d3a..5fdaebd1610 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -3079,7 +3079,16 @@ EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
-###########################################################################
+--echo #
+--echo # Bug#54494 crash with explain extended and prepared statements
+--echo #
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2);
+PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1';
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
--echo
--echo End of 5.1 tests.
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 366c46d9c92..fcbf2c48896 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2420,11 +2420,15 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
sl->where= sl->prep_where->copy_andor_structure(thd);
sl->where->cleanup();
}
+ else
+ sl->where= NULL;
if (sl->prep_having)
{
sl->having= sl->prep_having->copy_andor_structure(thd);
sl->having->cleanup();
}
+ else
+ sl->having= NULL;
DBUG_ASSERT(sl->join == 0);
ORDER *order;
/* Fix GROUP list */