Commit 5a474139 authored by unknown's avatar unknown

fix of LP bug#998321

The problem is that we can't check null_value field of non-basic constant without the item execution.:
parent e1b6e1b8
......@@ -186,3 +186,20 @@ MAX(IFNULL(CAST(c AS UNSIGNED), 0))
12345678901234567890
DROP TABLE t1;
End of 5.0 tests
#
# LP bug#998321 Simple query with IF expression causes an
# assertion abort (see also mysql Bug#12620084)
#
SELECT if(0, (SELECT min('hello')), NULL);
if(0, (SELECT min('hello')), NULL)
NULL
SELECT if(1, (SELECT min('hello')), NULL);
if(1, (SELECT min('hello')), NULL)
hello
SELECT if(0, NULL, (SELECT min('hello')));
if(0, NULL, (SELECT min('hello')))
hello
SELECT if(1, NULL, (SELECT min('hello')));
if(1, NULL, (SELECT min('hello')))
NULL
End of 5.2 tests
......@@ -170,6 +170,19 @@ DROP TABLE t1;
--echo End of 5.0 tests
--echo #
--echo # LP bug#998321 Simple query with IF expression causes an
--echo # assertion abort (see also mysql Bug#12620084)
--echo #
SELECT if(0, (SELECT min('hello')), NULL);
SELECT if(1, (SELECT min('hello')), NULL);
SELECT if(0, NULL, (SELECT min('hello')));
SELECT if(1, NULL, (SELECT min('hello')));
--echo End of 5.2 tests
--disable_query_log
# Restore timezone to default
set time_zone= @@global.time_zone;
......
......@@ -2659,8 +2659,8 @@ Item_func_if::fix_length_and_dec()
enum Item_result arg1_type=args[1]->result_type();
enum Item_result arg2_type=args[2]->result_type();
bool null1=args[1]->const_item() && args[1]->null_value;
bool null2=args[2]->const_item() && args[2]->null_value;
bool null1=args[1]->basic_const_item() && args[1]->null_value;
bool null2=args[2]->basic_const_item() && args[2]->null_value;
if (null1)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment