mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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)
This commit is contained in:
@ -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
|
||||
#
|
||||
|
@ -784,6 +784,23 @@ SHOW CREATE TABLE t2;
|
||||
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 #
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user