Backport of the 5.1 fix for bug #55826 to 5.0
This commit is contained in:
parent
5df7f9bc26
commit
7e8ddb6b03
@ -1315,4 +1315,16 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# Bug#55826: create table .. select crashes with when KILL_BAD_DATA
|
||||
# is returned
|
||||
#
|
||||
CREATE TABLE t1(a INT) ENGINE=innodb;
|
||||
INSERT INTO t1 VALUES (0);
|
||||
SET SQL_MODE='STRICT_ALL_TABLES';
|
||||
CREATE TABLE t2
|
||||
SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`;
|
||||
ERROR 22007: Truncated incorrect datetime value: ''
|
||||
DROP TABLE t1;
|
||||
SET SQL_MODE=DEFAULT;
|
||||
End of 5.0 tests
|
||||
|
@ -1073,4 +1073,19 @@ explain
|
||||
select b from t1 where a not in (select b from t1,t2 group by a) group by a;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#55826: create table .. select crashes with when KILL_BAD_DATA
|
||||
--echo # is returned
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1(a INT) ENGINE=innodb;
|
||||
INSERT INTO t1 VALUES (0);
|
||||
SET SQL_MODE='STRICT_ALL_TABLES';
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
CREATE TABLE t2
|
||||
SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`;
|
||||
DROP TABLE t1;
|
||||
SET SQL_MODE=DEFAULT;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
@ -2270,7 +2270,7 @@ void Item_func_min_max::fix_length_and_dec()
|
||||
stored to the value pointer, if latter is provided.
|
||||
|
||||
RETURN
|
||||
0 If one of arguments is NULL
|
||||
0 If one of arguments is NULL or there was a execution error
|
||||
# index of the least/greatest argument
|
||||
*/
|
||||
|
||||
@ -2284,6 +2284,14 @@ uint Item_func_min_max::cmp_datetimes(ulonglong *value)
|
||||
Item **arg= args + i;
|
||||
bool is_null;
|
||||
longlong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
|
||||
|
||||
/* Check if we need to stop (because of error or KILL) and stop the loop */
|
||||
if (thd->net.report_error)
|
||||
{
|
||||
null_value= 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((null_value= args[i]->null_value))
|
||||
return 0;
|
||||
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
|
||||
@ -2312,6 +2320,12 @@ String *Item_func_min_max::val_str(String *str)
|
||||
if (null_value)
|
||||
return 0;
|
||||
str_res= args[min_max_idx]->val_str(str);
|
||||
if (args[min_max_idx]->null_value)
|
||||
{
|
||||
// check if the call to val_str() above returns a NULL value
|
||||
null_value= 1;
|
||||
return NULL;
|
||||
}
|
||||
str_res->set_charset(collation.collation);
|
||||
return str_res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user