diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-11-17 17:33:34 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2023-01-09 18:06:06 +0100 |
commit | 32f09df2b86ed4d2b9b63b26b5c95f8555bc1db3 (patch) | |
tree | dd8bc7aa53e6bf3d1f602a81879214a7c143ed90 | |
parent | 610cea3ddae5aa7756a3ec1409466c9e0c5fd5b3 (diff) | |
download | mariadb-git-32f09df2b86ed4d2b9b63b26b5c95f8555bc1db3.tar.gz |
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)
-rw-r--r-- | mysql-test/main/type_date.result | 18 | ||||
-rw-r--r-- | mysql-test/main/type_date.test | 17 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 |
3 files changed, 38 insertions, 1 deletions
diff --git a/mysql-test/main/type_date.result b/mysql-test/main/type_date.result index 0cf78458817..d1ea71dae68 100644 --- a/mysql-test/main/type_date.result +++ b/mysql-test/main/type_date.result @@ -1144,5 +1144,23 @@ t2 CREATE TABLE `t2` ( DROP TABLE t2; DROP TABLE t1; # +# MDEV-29890 Update with inner join false row count result +# +set sql_mode='NO_ZERO_DATE'; +create table t1 (a1 bigint primary key, a2 date not null, a3 bigint not null); +create table t2 (b1 bigint primary key); +insert into t2 (b1) values (1); +insert into t1 (a1, a2, a3) values (1, current_date, 1),( 2, current_date, 1); +update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day; +select row_count(); +row_count() +2 +set sql_mode=''; +alter table t1 modify a2 date not null default '0000-00-00'; +set sql_mode='NO_ZERO_DATE'; +update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day; +drop table t1, t2; +set sql_mode=default; +# # End of 10.4 tests # diff --git a/mysql-test/main/type_date.test b/mysql-test/main/type_date.test index 74997aa0ef7..cbc3c67bf64 100644 --- a/mysql-test/main/type_date.test +++ b/mysql-test/main/type_date.test @@ -785,5 +785,22 @@ DROP TABLE t2; DROP TABLE t1; --echo # +--echo # MDEV-29890 Update with inner join false row count result +--echo # +set sql_mode='NO_ZERO_DATE'; +create table t1 (a1 bigint primary key, a2 date not null, a3 bigint not null); +create table t2 (b1 bigint primary key); +insert into t2 (b1) values (1); +insert into t1 (a1, a2, a3) values (1, current_date, 1),( 2, current_date, 1); +update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day; +select row_count(); +set sql_mode=''; +alter table t1 modify a2 date not null default '0000-00-00'; +set sql_mode='NO_ZERO_DATE'; +update t1 inner join t2 on t1.a3 = t2.b1 set t1.a2 = t1.a2 + interval 1 day; +drop table t1, t2; +set sql_mode=default; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f313d571b5b..d7b2891c9d4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -19035,8 +19035,10 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, { /* Copy default value. We have to use field_conv() for copy, instead of - memcpy(), because bit_fields may be stored differently + memcpy(), because bit_fields may be stored differently. + But otherwise we copy as is, in particular, ignore NO_ZERO_DATE, etc */ + Use_relaxed_field_copy urfc(thd); my_ptrdiff_t ptr_diff= (orig_field->table->s->default_values - orig_field->table->record[0]); field->set_notnull(); |