Skip to content

Commit 32f09df

Browse files
committed
MDEV-29890 Update with inner join false row count result
when creating a temp table field from an actual table field, these two fields are supposed to be mostly identical (except for BIT field storage), in particular, temp field should have the same default as the orig field, even if the sql_mode has been changed meanwhile (e.g. to include NO_ZERO_DATE)
1 parent 610cea3 commit 32f09df

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

mysql-test/main/type_date.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,5 +1144,23 @@ t2 CREATE TABLE `t2` (
11441144
DROP TABLE t2;
11451145
DROP TABLE t1;
11461146
#
1147+
# MDEV-29890 Update with inner join false row count result
1148+
#
1149+
set sql_mode='NO_ZERO_DATE';
1150+
create table t1 (a1 bigint primary key, a2 date not null, a3 bigint not null);
1151+
create table t2 (b1 bigint primary key);
1152+
insert into t2 (b1) values (1);
1153+
insert into t1 (a1, a2, a3) values (1, current_date, 1),( 2, current_date, 1);
1154+
update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day;
1155+
select row_count();
1156+
row_count()
1157+
2
1158+
set sql_mode='';
1159+
alter table t1 modify a2 date not null default '0000-00-00';
1160+
set sql_mode='NO_ZERO_DATE';
1161+
update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day;
1162+
drop table t1, t2;
1163+
set sql_mode=default;
1164+
#
11471165
# End of 10.4 tests
11481166
#

mysql-test/main/type_date.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,23 @@ SHOW CREATE TABLE t2;
784784
DROP TABLE t2;
785785
DROP TABLE t1;
786786

787+
--echo #
788+
--echo # MDEV-29890 Update with inner join false row count result
789+
--echo #
790+
set sql_mode='NO_ZERO_DATE';
791+
create table t1 (a1 bigint primary key, a2 date not null, a3 bigint not null);
792+
create table t2 (b1 bigint primary key);
793+
insert into t2 (b1) values (1);
794+
insert into t1 (a1, a2, a3) values (1, current_date, 1),( 2, current_date, 1);
795+
update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day;
796+
select row_count();
797+
set sql_mode='';
798+
alter table t1 modify a2 date not null default '0000-00-00';
799+
set sql_mode='NO_ZERO_DATE';
800+
update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day;
801+
drop table t1, t2;
802+
set sql_mode=default;
803+
787804
--echo #
788805
--echo # End of 10.4 tests
789806
--echo #

sql/sql_select.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19035,8 +19035,10 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
1903519035
{
1903619036
/*
1903719037
Copy default value. We have to use field_conv() for copy, instead of
19038-
memcpy(), because bit_fields may be stored differently
19038+
memcpy(), because bit_fields may be stored differently.
19039+
But otherwise we copy as is, in particular, ignore NO_ZERO_DATE, etc
1903919040
*/
19041+
Use_relaxed_field_copy urfc(thd);
1904019042
my_ptrdiff_t ptr_diff= (orig_field->table->s->default_values -
1904119043
orig_field->table->record[0]);
1904219044
field->set_notnull();

0 commit comments

Comments
 (0)