Commit d7f44791 authored by Daniel Black's avatar Daniel Black

MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error

regression from MDEV-29540 / 8c389393.

INSERT SELECT errors needed to be unconditionally ignored.

As this touches the CREATE .. SELECT functionality, show
the equalivent test there.
parent e64e6768
...@@ -2121,5 +2121,16 @@ Warnings: ...@@ -2121,5 +2121,16 @@ Warnings:
Warning 1280 Name 'foo' ignored for PRIMARY key. Warning 1280 Name 'foo' ignored for PRIMARY key.
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error
#
create table t1(c1 varchar(1));
insert into t1(c1) values('#');
select @@sql_mode like '%strict_all_tables%';
@@sql_mode like '%strict_all_tables%'
0
create table t2 as select if(c1 = '#', c1 = 0, c1) as c1 from t1;
ERROR 22007: Truncated incorrect DECIMAL value: '#'
drop table t1;
#
# End of 10.3 tests # End of 10.3 tests
# #
...@@ -1978,6 +1978,19 @@ create table t1 (c int(10) unsigned) engine=memory transactional=0; ...@@ -1978,6 +1978,19 @@ create table t1 (c int(10) unsigned) engine=memory transactional=0;
CREATE TABLE t1 ( id1 INT, id2 INT, CONSTRAINT `foo` PRIMARY KEY (id1), CONSTRAINT `bar` UNIQUE KEY(id2)); CREATE TABLE t1 ( id1 INT, id2 INT, CONSTRAINT `foo` PRIMARY KEY (id1), CONSTRAINT `bar` UNIQUE KEY(id2));
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error
--echo #
create table t1(c1 varchar(1));
insert into t1(c1) values('#');
select @@sql_mode like '%strict_all_tables%';
--error ER_TRUNCATED_WRONG_VALUE
create table t2 as select if(c1 = '#', c1 = 0, c1) as c1 from t1;
drop table t1;
--echo # --echo #
--echo # End of 10.3 tests --echo # End of 10.3 tests
--echo # --echo #
...@@ -1042,4 +1042,17 @@ select * from t1; ...@@ -1042,4 +1042,17 @@ select * from t1;
a a
deallocate prepare stmt; deallocate prepare stmt;
drop table t1,t2,t3; drop table t1,t2,t3;
#
# MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error
#
create table t1(c1 varchar(1));
create table t2(c1 varchar(1));
insert into t1(c1) values('#');
select @@sql_mode like '%strict_all_tables%';
@@sql_mode like '%strict_all_tables%'
0
insert into t2(c1) select if(c1 = '#', c1 = 0, c1) as c1 from t1;
drop table t1, t2;
#
# End of 10.3 test # End of 10.3 test
#
...@@ -595,4 +595,21 @@ deallocate prepare stmt; ...@@ -595,4 +595,21 @@ deallocate prepare stmt;
drop table t1,t2,t3; drop table t1,t2,t3;
--echo #
--echo # MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error
--echo #
create table t1(c1 varchar(1));
create table t2(c1 varchar(1));
insert into t1(c1) values('#');
select @@sql_mode like '%strict_all_tables%';
insert into t2(c1) select if(c1 = '#', c1 = 0, c1) as c1 from t1;
drop table t1, t2;
--echo #
--echo # End of 10.3 test --echo # End of 10.3 test
--echo #
...@@ -5455,7 +5455,7 @@ class select_insert :public select_result_interceptor { ...@@ -5455,7 +5455,7 @@ class select_insert :public select_result_interceptor {
int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
virtual int prepare2(JOIN *join); virtual int prepare2(JOIN *join);
virtual int send_data(List<Item> &items); virtual int send_data(List<Item> &items);
virtual bool store_values(List<Item> &values, bool ignore_errors); virtual bool store_values(List<Item> &values);
virtual bool can_rollback_data() { return 0; } virtual bool can_rollback_data() { return 0; }
bool prepare_eof(); bool prepare_eof();
bool send_ok_packet(); bool send_ok_packet();
...@@ -5497,7 +5497,7 @@ class select_create: public select_insert { ...@@ -5497,7 +5497,7 @@ class select_create: public select_insert {
int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int binlog_show_create_table(TABLE **tables, uint count); int binlog_show_create_table(TABLE **tables, uint count);
bool store_values(List<Item> &values, bool ignore_errors); bool store_values(List<Item> &values);
bool send_eof(); bool send_eof();
virtual void abort_result_set(); virtual void abort_result_set();
virtual bool can_rollback_data() { return 1; } virtual bool can_rollback_data() { return 1; }
......
...@@ -3928,7 +3928,7 @@ int select_insert::send_data(List<Item> &values) ...@@ -3928,7 +3928,7 @@ int select_insert::send_data(List<Item> &values)
DBUG_RETURN(0); DBUG_RETURN(0);
thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
if (store_values(values, info.ignore)) if (store_values(values))
DBUG_RETURN(1); DBUG_RETURN(1);
thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
if (unlikely(thd->is_error())) if (unlikely(thd->is_error()))
...@@ -3986,17 +3986,17 @@ int select_insert::send_data(List<Item> &values) ...@@ -3986,17 +3986,17 @@ int select_insert::send_data(List<Item> &values)
} }
bool select_insert::store_values(List<Item> &values, bool ignore_errors) bool select_insert::store_values(List<Item> &values)
{ {
DBUG_ENTER("select_insert::store_values"); DBUG_ENTER("select_insert::store_values");
bool error; bool error;
if (fields->elements) if (fields->elements)
error= fill_record_n_invoke_before_triggers(thd, table, *fields, values, error= fill_record_n_invoke_before_triggers(thd, table, *fields, values,
ignore_errors, TRG_EVENT_INSERT); true, TRG_EVENT_INSERT);
else else
error= fill_record_n_invoke_before_triggers(thd, table, table->field_to_fill(), error= fill_record_n_invoke_before_triggers(thd, table, table->field_to_fill(),
values, ignore_errors, TRG_EVENT_INSERT); values, true, TRG_EVENT_INSERT);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -4669,10 +4669,10 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) ...@@ -4669,10 +4669,10 @@ select_create::binlog_show_create_table(TABLE **tables, uint count)
return result; return result;
} }
bool select_create::store_values(List<Item> &values, bool ignore_errors) bool select_create::store_values(List<Item> &values)
{ {
return fill_record_n_invoke_before_triggers(thd, table, field, values, return fill_record_n_invoke_before_triggers(thd, table, field, values,
ignore_errors, TRG_EVENT_INSERT); true, TRG_EVENT_INSERT);
} }
......
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