diff options
author | Georgi Kodinov <kgeorge@mysql.com> | 2008-10-08 14:23:53 +0300 |
---|---|---|
committer | Georgi Kodinov <kgeorge@mysql.com> | 2008-10-08 14:23:53 +0300 |
commit | 489ad44ab53c21c9d4006b21223037f869710fd5 (patch) | |
tree | 9244a02dac3bb0b0d2dafbc410630a91346aba2f /mysql-test/t/ps_11bugs.test | |
parent | 7fa30b2858cc00ab0e18ee847ddc1dfd9215cfc8 (diff) | |
download | mariadb-git-489ad44ab53c21c9d4006b21223037f869710fd5.tar.gz |
Bug #32124: crash if prepared statements refer to variables in the where clause
The code to get read the value of a system variable was extracting its value
on PREPARE stage and was substituting the value (as a constant) into the parse tree.
Note that this must be a reversible transformation, i.e. it must be reversed before
each re-execution.
Unfortunately this cannot be reliably done using the current code, because there are
other non-reversible source tree transformations that can interfere with this
reversible transformation.
Fixed by not resolving the value at PREPARE, but at EXECUTE (as the rest of the
functions operate). Added a cache of the value (so that it's constant throughout
the execution of the query). Note that the cache also caches NULL values.
Updated an obsolete related test suite (variables-big) and the code to test the
result type of system variables (as per bug 74).
Diffstat (limited to 'mysql-test/t/ps_11bugs.test')
-rw-r--r-- | mysql-test/t/ps_11bugs.test | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/t/ps_11bugs.test b/mysql-test/t/ps_11bugs.test index 515bcc03c1a..ccab833e878 100644 --- a/mysql-test/t/ps_11bugs.test +++ b/mysql-test/t/ps_11bugs.test @@ -177,4 +177,41 @@ select * from t2; drop table t1; drop table t2; +# +# Bug #32124: crash if prepared statements refer to variables in the where +# clause +# + +CREATE TABLE t1 (a INT); +PREPARE stmt FROM 'select 1 from `t1` where `a` = any (select (@@tmpdir))'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +CREATE TABLE t2 (a INT PRIMARY KEY); +INSERT INTO t2 VALUES (400000), (400001); + +SET @@sort_buffer_size=400000; + +DELIMITER |; + +CREATE FUNCTION p1(i INT) RETURNS INT +BEGIN + SET @@sort_buffer_size= i; + RETURN i + 1; +END| + +DELIMITER ;| + +SELECT * FROM t2 WHERE a = @@sort_buffer_size AND p1(@@sort_buffer_size + 1) > a - 1; + +DROP TABLE t2; +DROP FUNCTION p1; + + +SELECT CONCAT(@@sort_buffer_size); +SELECT LEFT("12345", @@ft_boolean_syntax); + +SET @@sort_buffer_size=DEFAULT; + --echo End of 5.0 tests. |