From 99f1606e942985d4a803c2914eb25fe4fc61c338 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 11 Oct 2007 11:29:26 +0300 Subject: [PATCH] Bug #31440: 'select 1 regex null' asserts debug server The special case with NULL as a regular expression was handled at prepare time. But in this special case the item was not marked as fixed. This caused an assertion at execution time. Fixed my marking the item as fixed even when known to return NULL at prepare time. --- mysql-test/r/func_regexp.result | 5 +++++ mysql-test/t/func_regexp.test | 11 ++++++++++- sql/item_cmpfunc.cc | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_regexp.result b/mysql-test/r/func_regexp.result index 584c8a9b820..2366947d2a7 100644 --- a/mysql-test/r/func_regexp.result +++ b/mysql-test/r/func_regexp.result @@ -98,3 +98,8 @@ R2 R3 deallocate prepare stmt1; drop table t1; +End of 4.1 tests +SELECT 1 REGEXP NULL; +1 REGEXP NULL +NULL +End of 5.0 tests diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test index 23070c71fe9..5eff404bc0f 100644 --- a/mysql-test/t/func_regexp.test +++ b/mysql-test/t/func_regexp.test @@ -74,4 +74,13 @@ execute stmt1 using @a; deallocate prepare stmt1; drop table t1; -# End of 4.1 tests +--echo End of 4.1 tests + + +# +# Bug #31440: 'select 1 regex null' asserts debug server +# + +SELECT 1 REGEXP NULL; + +--echo End of 5.0 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 1599bcc1571..a5ede9e757c 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4285,6 +4285,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref) if (args[1]->null_value) { // Will always return NULL maybe_null=1; + fixed= 1; return FALSE; } int error;