summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2004-10-12 21:16:07 +0400
committerkonstantin@mysql.com <>2004-10-12 21:16:07 +0400
commitcc57252bb76feab94caf3035a2ca083b0734222f (patch)
treec334b8654080fb8a1b9e9b5e7a353085ebd4b6c1 /mysql-test
parentae8800d8d33e549f20b501c818d3de01ffdac920 (diff)
downloadmariadb-git-cc57252bb76feab94caf3035a2ca083b0734222f.tar.gz
ps.test, ps.result: a test case for Bug#6042 "constants
propogation works only once (prepared statements)".
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/ps.result18
-rw-r--r--mysql-test/t/ps.test21
2 files changed, 39 insertions, 0 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index c10cb7bb25a..df5fa5fe999 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -318,3 +318,21 @@ execute stmt;
a
drop table t1;
deallocate prepare stmt;
+create table t1 (a int, b int);
+insert into t1 (a, b) values (1,1), (1,2), (2,1), (2,2);
+prepare stmt from
+"explain select * from t1 where t1.a=2 and t1.a=t1.b and t1.b > 1 + ?";
+set @v=5;
+execute stmt using @v;
+id select_type table type possible_keys key key_len ref rows Extra
+- - - - - - - - NULL Impossible WHERE
+set @v=0;
+execute stmt using @v;
+id select_type table type possible_keys key key_len ref rows Extra
+- - - - - - - - 4 Using where
+set @v=5;
+execute stmt using @v;
+id select_type table type possible_keys key key_len ref rows Extra
+- - - - - - - - NULL Impossible WHERE
+drop table t1;
+deallocate prepare stmt;
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 42f6d4d0f64..76c7fb7c2e7 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -342,4 +342,25 @@ execute stmt;
drop table t1;
deallocate prepare stmt;
+#
+# Test case for Bug#6042 "constants propogation works only once (prepared
+# statements): check that the query plan changes whenever we change
+# placeholder value.
+#
+create table t1 (a int, b int);
+insert into t1 (a, b) values (1,1), (1,2), (2,1), (2,2);
+prepare stmt from
+"explain select * from t1 where t1.a=2 and t1.a=t1.b and t1.b > 1 + ?";
+--replace_column 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -
+set @v=5;
+execute stmt using @v;
+--replace_column 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -
+set @v=0;
+execute stmt using @v;
+--replace_column 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -
+set @v=5;
+execute stmt using @v;
+drop table t1;
+deallocate prepare stmt;
+