1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-14788 System versioning cannot be based on local timestamps, as it is now

followup to be81b00c84
Fix updates and deletes too
This commit is contained in:
Sergei Golubchik
2018-01-11 19:41:32 +01:00
parent 6a8cf407d2
commit 826f615fc9
8 changed files with 27 additions and 15 deletions

View File

@ -353,6 +353,12 @@ a
select * from t1 for system_time as of sysdate(6);
a
1
update t1 set a=2;
delete from t1;
select *, row_start > @a, row_end > @a from t1 for system_time all;
a row_start > @a row_end > @a
1 0 1
2 1 1
#
# MDEV-14871 Server crashes in fill_record / fill_record_n_invoke_before_triggers upon inserting into versioned table with trigger
#

View File

@ -616,12 +616,10 @@ No A B C D
2 1 1 1 1
3 1 1 1 1
### Issue #365, bug 7 (duplicate of historical row)
set timestamp= 1000000019;
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
update t1 set b= 2;
insert into t1 (a) values (1) on duplicate key update a= 2;
ERROR 23000: Duplicate entry '1-2001-09-09 01:46:59.000000' for key 'PRIMARY'
replace t1 values (1,2),(1,3),(2,4);
ERROR 23000: Duplicate entry '1-YYYY-MM-DD hh:mm:ss.uuuuuu' for key 'PRIMARY'
drop database test;
create database test;

View File

@ -251,6 +251,10 @@ set @a=sysdate(6);
select * from t1 for system_time as of now(6);
select * from t1 for system_time as of sysdate(6);
update t1 set a=2;
delete from t1;
--sorted_result
select *, row_start > @a, row_end > @a from t1 for system_time all;
--echo #
--echo # MDEV-14871 Server crashes in fill_record / fill_record_n_invoke_before_triggers upon inserting into versioned table with trigger

View File

@ -277,13 +277,12 @@ call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
call verify_vtq;
--echo ### Issue #365, bug 7 (duplicate of historical row)
set timestamp= 1000000019;
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
update t1 set b= 2;
--replace_regex /'1-[- .\d:]+'/'1-YYYY-MM-DD hh:mm:ss.uuuuuu'/
--error ER_DUP_ENTRY
insert into t1 (a) values (1) on duplicate key update a= 2;
replace t1 values (1,2),(1,3),(2,4);
drop database test;
create database test;

View File

@ -253,7 +253,7 @@ int TABLE::delete_row()
return file->ha_delete_row(record[0]);
store_record(this, record[1]);
vers_end_field()->set_time();
vers_update_end();
return file->ha_update_row(record[1], record[0]);
}

View File

@ -1638,8 +1638,7 @@ int vers_insert_history_row(TABLE *table)
restore_record(table,record[1]);
// Set Sys_end to now()
if (table->vers_end_field()->set_time())
DBUG_ASSERT(0);
table->vers_update_end();
return table->file->ha_write_row(table->record[0]);
}
@ -1971,11 +1970,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
DBUG_ASSERT(table->insert_values);
store_record(table,insert_values);
restore_record(table,record[1]);
if (table->vers_end_field()->set_time())
{
error= 1;
goto err;
}
table->vers_update_end();
error= table->file->ha_update_row(table->record[1],
table->record[0]);
restore_record(table,insert_values);

View File

@ -7800,6 +7800,15 @@ void TABLE::vers_update_fields()
}
void TABLE::vers_update_end()
{
vers_end_field()->set_notnull();
if (vers_end_field()->store_timestamp(in_use->system_time,
in_use->system_time_sec_part))
DBUG_ASSERT(0);
}
bool TABLE_LIST::vers_vtmd_name(String& out) const
{
static const char *vtmd_suffix= "_vtmd";

View File

@ -1588,6 +1588,7 @@ public:
int delete_row();
void vers_update_fields();
void vers_update_end();
/** Number of additional fields used in versioned tables */
#define VERSIONING_FIELDS 2