summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2023-01-08 09:53:09 +1100
committerDaniel Black <daniel@mariadb.org>2023-01-09 19:20:31 +1100
commitd7f447915c96681c85abf00d22de589a5332a6da (patch)
treeabf60dd41662bbaa6b329127cd3be9b26b1d82ff
parente64e6768e00c6ef58824b79f2009aa5668ccd538 (diff)
downloadmariadb-git-d7f447915c96681c85abf00d22de589a5332a6da.tar.gz
MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error
regression from MDEV-29540 / 8c389393695. INSERT SELECT errors needed to be unconditionally ignored. As this touches the CREATE .. SELECT functionality, show the equalivent test there.
-rw-r--r--mysql-test/main/create.result11
-rw-r--r--mysql-test/main/create.test13
-rw-r--r--mysql-test/main/insert_select.result13
-rw-r--r--mysql-test/main/insert_select.test17
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_insert.cc12
6 files changed, 62 insertions, 8 deletions
diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result
index b7ed4388db7..290f293325d 100644
--- a/mysql-test/main/create.result
+++ b/mysql-test/main/create.result
@@ -2121,5 +2121,16 @@ Warnings:
Warning 1280 Name 'foo' ignored for PRIMARY key.
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
#
diff --git a/mysql-test/main/create.test b/mysql-test/main/create.test
index f1dfba65b4b..83c894dd8dc 100644
--- a/mysql-test/main/create.test
+++ b/mysql-test/main/create.test
@@ -1979,5 +1979,18 @@ CREATE TABLE t1 ( id1 INT, id2 INT, CONSTRAINT `foo` PRIMARY KEY (id1), CONSTRAI
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 # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/insert_select.result b/mysql-test/main/insert_select.result
index 6d939d0ed8e..29618c6ddd4 100644
--- a/mysql-test/main/insert_select.result
+++ b/mysql-test/main/insert_select.result
@@ -1042,4 +1042,17 @@ select * from t1;
a
deallocate prepare stmt;
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
+#
diff --git a/mysql-test/main/insert_select.test b/mysql-test/main/insert_select.test
index 6baa7e43c34..a3604e38f34 100644
--- a/mysql-test/main/insert_select.test
+++ b/mysql-test/main/insert_select.test
@@ -595,4 +595,21 @@ deallocate prepare stmt;
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 #
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 5e209f56458..49a8509b519 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5455,7 +5455,7 @@ class select_insert :public select_result_interceptor {
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
virtual int prepare2(JOIN *join);
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; }
bool prepare_eof();
bool send_ok_packet();
@@ -5497,7 +5497,7 @@ public:
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
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();
virtual void abort_result_set();
virtual bool can_rollback_data() { return 1; }
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 43007b2243a..b743fc88061 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -3928,7 +3928,7 @@ int select_insert::send_data(List<Item> &values)
DBUG_RETURN(0);
thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
- if (store_values(values, info.ignore))
+ if (store_values(values))
DBUG_RETURN(1);
thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
if (unlikely(thd->is_error()))
@@ -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");
bool error;
if (fields->elements)
error= fill_record_n_invoke_before_triggers(thd, table, *fields, values,
- ignore_errors, TRG_EVENT_INSERT);
+ true, TRG_EVENT_INSERT);
else
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);
}
@@ -4669,10 +4669,10 @@ select_create::binlog_show_create_table(TABLE **tables, uint count)
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,
- ignore_errors, TRG_EVENT_INSERT);
+ true, TRG_EVENT_INSERT);
}