Skip to content

Commit 6e81ba0

Browse files
committed
Don't give errors for default value copy in create_tmp_table
1 parent 53ecc35 commit 6e81ba0

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

mysql-test/main/type_temporal_innodb.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,18 @@ SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d );
160160
d
161161
2012-12-21
162162
DROP TABLE t1;
163+
#
164+
# MDEV-17969 Assertion `name' failed in THD::push_warning_truncated_value_for_field
165+
#
166+
CREATE TABLE t1 (c1 DATE , c2 TIMESTAMP) ENGINE=InnoDB;
167+
INSERT INTO t1 VALUES ('2006-07-17','0000-00-00 00:00:00');
168+
CREATE TABLE t2 (pk INT, a1 TIME) Engine=InnoDB;
169+
INSERT INTO t2 VALUES (6,'00:00:00');
170+
SET SESSION sql_mode= 'strict_all_tables,no_zero_date';
171+
CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6);
172+
ERROR 22007: Truncated incorrect datetime value: '0000-00-00 00:00:00'
173+
DROP TABLE t1,t2;
174+
SET sql_mode=DEFAULT;
175+
#
176+
# End of 10.3 tests
177+
#

mysql-test/main/type_temporal_innodb.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,22 @@ CREATE TABLE t1 (d DATE) ENGINE=InnoDB;
6666
INSERT INTO t1 VALUES ('2012-12-21');
6767
SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d );
6868
DROP TABLE t1;
69+
70+
--echo #
71+
--echo # MDEV-17969 Assertion `name' failed in THD::push_warning_truncated_value_for_field
72+
--echo #
73+
74+
CREATE TABLE t1 (c1 DATE , c2 TIMESTAMP) ENGINE=InnoDB;
75+
INSERT INTO t1 VALUES ('2006-07-17','0000-00-00 00:00:00');
76+
CREATE TABLE t2 (pk INT, a1 TIME) Engine=InnoDB;
77+
INSERT INTO t2 VALUES (6,'00:00:00');
78+
SET SESSION sql_mode= 'strict_all_tables,no_zero_date';
79+
--error ER_TRUNCATED_WRONG_VALUE
80+
CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6);
81+
# ^^^ there is no column c2 in table t2
82+
DROP TABLE t1,t2;
83+
SET sql_mode=DEFAULT;
84+
85+
--echo #
86+
--echo # End of 10.3 tests
87+
--echo #

sql/sql_select.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17460,6 +17460,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
1746017460
bool using_unique_constraint= false;
1746117461
bool use_packed_rows= false;
1746217462
bool not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS);
17463+
bool save_abort_on_warning;
1746317464
char *tmpname,path[FN_REFLEN];
1746417465
uchar *pos, *group_buff, *bitmaps;
1746517466
uchar *null_flags;
@@ -17932,6 +17933,11 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
1793217933
}
1793317934
null_count= (blob_count == 0) ? 1 : 0;
1793417935
hidden_field_count=param->hidden_field_count;
17936+
17937+
/* Protect against warnings in field_conv() in the next loop*/
17938+
save_abort_on_warning= thd->abort_on_warning;
17939+
thd->abort_on_warning= 0;
17940+
1793517941
for (i=0,reg_field=table->field; i < field_count; i++,reg_field++,recinfo++)
1793617942
{
1793717943
Field *field= *reg_field;
@@ -18018,6 +18024,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
1801818024
bzero(pos, table->s->reclength - (pos - table->record[0]));
1801918025
MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
1802018026

18027+
thd->abort_on_warning= save_abort_on_warning;
1802118028
param->copy_field_end=copy;
1802218029
param->recinfo= recinfo; // Pointer to after last field
1802318030
store_record(table,s->default_values); // Make empty default record

0 commit comments

Comments
 (0)