Commit 780d7710 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-17969 Assertion `name' failed in THD::push_warning_truncated_value_for_field

parent a5ac029f
...@@ -160,3 +160,15 @@ SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d ); ...@@ -160,3 +160,15 @@ SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d );
d d
2012-12-21 2012-12-21
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-17969 Assertion `name' failed in THD::push_warning_truncated_value_for_field
#
CREATE TABLE t1 (c1 DATE , c2 TIMESTAMP) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('2006-07-17','0000-00-00 00:00:00');
CREATE TABLE t2 (pk INT, a1 TIME) Engine=InnoDB;
INSERT INTO t2 VALUES (6,'00:00:00');
SET SESSION sql_mode= 'strict_all_tables,no_zero_date';
CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6);
ERROR 22007: Truncated incorrect datetime value: '0000-00-00 00:00:00'
DROP TABLE t1,t2;
SET sql_mode=DEFAULT;
...@@ -66,3 +66,18 @@ CREATE TABLE t1 (d DATE) ENGINE=InnoDB; ...@@ -66,3 +66,18 @@ CREATE TABLE t1 (d DATE) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('2012-12-21'); INSERT INTO t1 VALUES ('2012-12-21');
SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d ); SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d );
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-17969 Assertion `name' failed in THD::push_warning_truncated_value_for_field
--echo #
CREATE TABLE t1 (c1 DATE , c2 TIMESTAMP) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('2006-07-17','0000-00-00 00:00:00');
CREATE TABLE t2 (pk INT, a1 TIME) Engine=InnoDB;
INSERT INTO t2 VALUES (6,'00:00:00');
SET SESSION sql_mode= 'strict_all_tables,no_zero_date';
--error ER_TRUNCATED_WRONG_VALUE
CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6);
# ^^^ there is no column c2 in table t2
DROP TABLE t1,t2;
SET sql_mode=DEFAULT;
...@@ -1185,5 +1185,14 @@ c IN (GREATEST(a,b)) ...@@ -1185,5 +1185,14 @@ c IN (GREATEST(a,b))
0 0
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-17969 Assertion `name' failed in THD::push_warning_truncated_value_for_field
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('2018-01-01'),('2019-01-01');
SET SESSION SQL_MODE= 'STRICT_ALL_TABLES,NO_ZERO_DATE';
CREATE TABLE t2 SELECT 1 AS f FROM t1 GROUP BY FROM_DAYS(d);
ERROR 22007: Truncated incorrect date value: '0000-00-00'
DROP TABLE t1;
#
# End of 10.4 tests # End of 10.4 tests
# #
...@@ -773,6 +773,19 @@ INSERT INTO t1 VALUES (0,0,0); ...@@ -773,6 +773,19 @@ INSERT INTO t1 VALUES (0,0,0);
SELECT c IN (GREATEST(a,b)) FROM t1; SELECT c IN (GREATEST(a,b)) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-17969 Assertion `name' failed in THD::push_warning_truncated_value_for_field
--echo #
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('2018-01-01'),('2019-01-01');
SET SESSION SQL_MODE= 'STRICT_ALL_TABLES,NO_ZERO_DATE';
--error ER_TRUNCATED_WRONG_VALUE
CREATE TABLE t2 SELECT 1 AS f FROM t1 GROUP BY FROM_DAYS(d);
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #
...@@ -11010,9 +11010,18 @@ void Field::set_datetime_warning(Sql_condition::enum_warning_level level, ...@@ -11010,9 +11010,18 @@ void Field::set_datetime_warning(Sql_condition::enum_warning_level level,
{ {
THD *thd= get_thd(); THD *thd= get_thd();
if (thd->really_abort_on_warning() && level >= Sql_condition::WARN_LEVEL_WARN) if (thd->really_abort_on_warning() && level >= Sql_condition::WARN_LEVEL_WARN)
thd->push_warning_truncated_value_for_field(level, typestr, {
/*
field_str.name can be NULL when field is not in the select list:
SET SESSION SQL_MODE= 'STRICT_ALL_TABLES,NO_ZERO_DATE';
CREATE OR REPLACE TABLE t2 SELECT 1 AS f FROM t1 GROUP BY FROM_DAYS(d);
Can't call push_warning_truncated_value_for_field() directly here,
as it expect a non-NULL name.
*/
thd->push_warning_wrong_or_truncated_value(level, false, typestr,
str->ptr(), table->s, str->ptr(), table->s,
field_name.str); field_name.str);
}
else else
set_warning(level, code, cuted_increment); set_warning(level, code, cuted_increment);
} }
......
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