mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
MDEV-31164 default current_timestamp() not working when used INSERT ON DUPLICATE KEY in some cases
select_insert::store_values() must reset has_value_set bitmap before every row, just like mysql_insert() does. because ON DUPLICATE KEY UPDATE and triggers modify it
This commit is contained in:
parent
f5e7c56e32
commit
4d6e458f9f
3 changed files with 68 additions and 0 deletions
|
@ -412,3 +412,44 @@ select if( @stamp1 = @stamp2, "correct", "wrong");
|
|||
if( @stamp1 = @stamp2, "correct", "wrong")
|
||||
correct
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-31164 default current_timestamp() not working when used INSERT ON DUPLICATE KEY in some cases
|
||||
#
|
||||
set timestamp=unix_timestamp('2000-10-20 0:0:0');
|
||||
create table t1 (pk integer primary key, val varchar(20) not null, ts timestamp);
|
||||
insert t1 (pk, val) values(1, 'val1');
|
||||
select * from t1;
|
||||
pk val ts
|
||||
1 val1 2000-10-20 00:00:00
|
||||
set timestamp=unix_timestamp('2000-10-20 1:0:0');
|
||||
insert t1 (pk, val) select 2, 'val3' union select 3, 'val4'
|
||||
on duplicate key update ts=now();
|
||||
select * from t1;
|
||||
pk val ts
|
||||
1 val1 2000-10-20 00:00:00
|
||||
2 val3 2000-10-20 01:00:00
|
||||
3 val4 2000-10-20 01:00:00
|
||||
set timestamp=unix_timestamp('2000-10-20 2:0:0');
|
||||
insert t1 (pk, val) select 1, 'val1' union select 4, 'val2'
|
||||
on duplicate key update ts=now();
|
||||
select * from t1;
|
||||
pk val ts
|
||||
1 val1 2000-10-20 02:00:00
|
||||
2 val3 2000-10-20 01:00:00
|
||||
3 val4 2000-10-20 01:00:00
|
||||
4 val2 2000-10-20 02:00:00
|
||||
set timestamp=unix_timestamp('2000-10-20 3:0:0');
|
||||
insert t1 (pk, val) select 5, 'val1' union select 1, 'val2'
|
||||
on duplicate key update ts=now();
|
||||
select * from t1;
|
||||
pk val ts
|
||||
1 val1 2000-10-20 03:00:00
|
||||
2 val3 2000-10-20 01:00:00
|
||||
3 val4 2000-10-20 01:00:00
|
||||
4 val2 2000-10-20 02:00:00
|
||||
5 val1 2000-10-20 03:00:00
|
||||
drop table t1;
|
||||
set timestamp=default;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
|
|
|
@ -311,3 +311,29 @@ insert into t1(f1) values(1) on duplicate key update f1=1;
|
|||
select @stamp2:=f2 from t1;
|
||||
select if( @stamp1 = @stamp2, "correct", "wrong");
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31164 default current_timestamp() not working when used INSERT ON DUPLICATE KEY in some cases
|
||||
--echo #
|
||||
set timestamp=unix_timestamp('2000-10-20 0:0:0');
|
||||
create table t1 (pk integer primary key, val varchar(20) not null, ts timestamp);
|
||||
insert t1 (pk, val) values(1, 'val1');
|
||||
select * from t1;
|
||||
set timestamp=unix_timestamp('2000-10-20 1:0:0');
|
||||
insert t1 (pk, val) select 2, 'val3' union select 3, 'val4'
|
||||
on duplicate key update ts=now();
|
||||
select * from t1;
|
||||
set timestamp=unix_timestamp('2000-10-20 2:0:0');
|
||||
insert t1 (pk, val) select 1, 'val1' union select 4, 'val2'
|
||||
on duplicate key update ts=now();
|
||||
select * from t1;
|
||||
set timestamp=unix_timestamp('2000-10-20 3:0:0');
|
||||
insert t1 (pk, val) select 5, 'val1' union select 1, 'val2'
|
||||
on duplicate key update ts=now();
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
set timestamp=default;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
|
|
@ -4028,6 +4028,7 @@ bool select_insert::store_values(List<Item> &values)
|
|||
DBUG_ENTER("select_insert::store_values");
|
||||
bool error;
|
||||
|
||||
table->reset_default_fields();
|
||||
if (fields->elements)
|
||||
error= fill_record_n_invoke_before_triggers(thd, table, *fields, values,
|
||||
true, TRG_EVENT_INSERT);
|
||||
|
|
Loading…
Add table
Reference in a new issue