summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/func_regexp.result5
-rw-r--r--mysql-test/t/func_regexp.test11
-rw-r--r--sql/item_cmpfunc.cc1
3 files changed, 16 insertions, 1 deletions
diff --git a/mysql-test/r/func_regexp.result b/mysql-test/r/func_regexp.result
index 4e35c2a1348..05e56f05457 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 1710799d6e7..04e0011f1a7 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -4408,6 +4408,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;