Commit 32f09df2 authored by Sergei Golubchik's avatar Sergei Golubchik

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)
parent 610cea3d
...@@ -1144,5 +1144,23 @@ t2 CREATE TABLE `t2` ( ...@@ -1144,5 +1144,23 @@ t2 CREATE TABLE `t2` (
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; 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 # End of 10.4 tests
# #
...@@ -784,6 +784,23 @@ SHOW CREATE TABLE t2; ...@@ -784,6 +784,23 @@ SHOW CREATE TABLE t2;
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; 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 #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #
...@@ -19035,8 +19035,10 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, ...@@ -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 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 - my_ptrdiff_t ptr_diff= (orig_field->table->s->default_values -
orig_field->table->record[0]); orig_field->table->record[0]);
field->set_notnull(); field->set_notnull();
......
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