Commit 31a79ee3 authored by jimw@mysql.com's avatar jimw@mysql.com

Fix Item_func_abs::fix_length_and_dec() to set maybe_null properly. (Bug #14009)

parent d10326a3
...@@ -145,3 +145,9 @@ insert into t1 values (1); ...@@ -145,3 +145,9 @@ insert into t1 values (1);
select rand(i) from t1; select rand(i) from t1;
ERROR HY000: Incorrect arguments to RAND ERROR HY000: Incorrect arguments to RAND
drop table t1; drop table t1;
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
insert into t1 values ('http://www.foo.com/', now());
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
a
http://www.foo.com/
drop table t1;
...@@ -86,4 +86,14 @@ insert into t1 values (1); ...@@ -86,4 +86,14 @@ insert into t1 values (1);
select rand(i) from t1; select rand(i) from t1;
drop table t1; drop table t1;
#
# Bug #14009: use of abs() on null value causes problems with filesort
#
# InnoDB is required to reproduce the fault, but it is okay if we default to
# MyISAM when testing.
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
insert into t1 values ('http://www.foo.com/', now());
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
drop table t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -766,6 +766,7 @@ void Item_func_abs::fix_length_and_dec() ...@@ -766,6 +766,7 @@ void Item_func_abs::fix_length_and_dec()
hybrid_type= REAL_RESULT; hybrid_type= REAL_RESULT;
if (args[0]->result_type() == INT_RESULT) if (args[0]->result_type() == INT_RESULT)
hybrid_type= INT_RESULT; hybrid_type= INT_RESULT;
maybe_null= 1;
} }
......
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