Commit 8b25c0e4 authored by Georgi Kodinov's avatar Georgi Kodinov

Bug #55565: debug assertion when ordering by expressions with user

variable assignments

The assert() that is firing is checking if expressions that can't be
null return a NULL when evaluated.
MAKEDATE() function can return NULL if the second argument is 
less then or equal to 0. Thus its nullability depends not only on 
the nullability of its arguments but also on their values.
Fixed by (overoptimistically) setting MAKEDATE() to be nullable 
despite the nullability of its arguments.
Test added.
Had to update one test result to reflect the metadata change.
parent 41cfa3e7
...@@ -194,7 +194,7 @@ date("1997-12-31 23:59:59.000001") as f8, ...@@ -194,7 +194,7 @@ date("1997-12-31 23:59:59.000001") as f8,
time("1997-12-31 23:59:59.000001") as f9; time("1997-12-31 23:59:59.000001") as f9;
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
f1 date NO 0000-00-00 f1 date YES NULL
f2 datetime YES NULL f2 datetime YES NULL
f3 time YES NULL f3 time YES NULL
f4 time YES NULL f4 time YES NULL
......
...@@ -1335,4 +1335,12 @@ date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND) ...@@ -1335,4 +1335,12 @@ date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND)
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND); select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND) date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)
0168-12-31 23:59:59 0168-12-31 23:59:59
CREATE TABLE t1(a DOUBLE NOT NULL);
INSERT INTO t1 VALUES (0),(9.216e-096);
# should not crash
SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
1
1
1
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
...@@ -838,4 +838,15 @@ select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND); ...@@ -838,4 +838,15 @@ select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND); select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
#
# Bug #55565: debug assertion when ordering by expressions with user
# variable assignments
#
CREATE TABLE t1(a DOUBLE NOT NULL);
INSERT INTO t1 VALUES (0),(9.216e-096);
--echo # should not crash
SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -881,6 +881,8 @@ class Item_func_makedate :public Item_date_func ...@@ -881,6 +881,8 @@ class Item_func_makedate :public Item_date_func
{ {
decimals=0; decimals=0;
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
/* It returns NULL when the second argument is less or equal to 0 */
maybe_null= 1;
} }
longlong val_int(); longlong val_int();
}; };
......
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