mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
parent
01c9d1c97f
commit
5dea51657d
8 changed files with 57 additions and 24 deletions
|
@ -56,19 +56,19 @@ begin
|
|||
set @str= concat('
|
||||
create table t1 (
|
||||
id bigint primary key,
|
||||
a int,
|
||||
b int without system versioning)
|
||||
x int,
|
||||
y int without system versioning)
|
||||
with system versioning
|
||||
engine ', engine);
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
insert into t1 values(1, 1, 1);
|
||||
set @ins_t= now(6);
|
||||
select sys_trx_start into @tmp1 from t1;
|
||||
update t1 set a=11, b=11 where id=1;
|
||||
select @tmp1 < sys_trx_start, a, b from t1;
|
||||
update t1 set x= 11, y= 11 where id = 1;
|
||||
select @tmp1 < sys_trx_start as A1, x, y from t1;
|
||||
select sys_trx_start into @tmp1 from t1;
|
||||
update t1 set b=1 where id=1;
|
||||
select @tmp1 = sys_trx_start, b from t1;
|
||||
update t1 set y= 1 where id = 1;
|
||||
select @tmp1 = sys_trx_start as A2, x from t1;
|
||||
drop table t1;
|
||||
end~~
|
||||
create procedure test_03(
|
||||
|
@ -292,15 +292,15 @@ x y
|
|||
8 8000
|
||||
9 9000
|
||||
call test_02('timestamp(6)', 'myisam', 'sys_end');
|
||||
@tmp1 < sys_trx_start a b
|
||||
A1 x y
|
||||
1 11 11
|
||||
@tmp1 = sys_trx_start b
|
||||
1 1
|
||||
A2 x
|
||||
1 11
|
||||
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
|
||||
@tmp1 < sys_trx_start a b
|
||||
A1 x y
|
||||
1 11 11
|
||||
@tmp1 = sys_trx_start b
|
||||
0 1
|
||||
A2 x
|
||||
1 11
|
||||
call test_03('timestamp(6)', 'myisam', 'sys_end');
|
||||
x y
|
||||
1 1
|
||||
|
@ -489,6 +489,15 @@ B1 salary
|
|||
1 2500
|
||||
B2 salary
|
||||
1 2500
|
||||
call test_07('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
|
||||
A1 name
|
||||
1 Jerry
|
||||
A2 name
|
||||
1 Jerry
|
||||
B1 salary
|
||||
1 2500
|
||||
B2 salary
|
||||
1 2500
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
1 1 1 1 1
|
||||
|
@ -509,6 +518,10 @@ No A B C D
|
|||
16 1 1 1 1
|
||||
17 1 1 1 1
|
||||
18 1 1 1 1
|
||||
19 1 1 1 1
|
||||
20 1 1 1 1
|
||||
21 1 1 1 1
|
||||
22 1 1 1 1
|
||||
drop procedure test_01;
|
||||
drop procedure test_02;
|
||||
drop procedure test_03;
|
||||
|
|
|
@ -65,3 +65,4 @@ call verify_vtq;
|
|||
|
||||
drop procedure test_01;
|
||||
drop procedure verify_vtq;
|
||||
|
||||
|
|
|
@ -43,20 +43,20 @@ begin
|
|||
set @str= concat('
|
||||
create table t1 (
|
||||
id bigint primary key,
|
||||
a int,
|
||||
b int without system versioning)
|
||||
x int,
|
||||
y int without system versioning)
|
||||
with system versioning
|
||||
engine ', engine);
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
insert into t1 values(1, 1, 1);
|
||||
set @ins_t= now(6);
|
||||
select sys_trx_start into @tmp1 from t1;
|
||||
update t1 set a=11, b=11 where id=1;
|
||||
select @tmp1 < sys_trx_start, a, b from t1;
|
||||
update t1 set x= 11, y= 11 where id = 1;
|
||||
select @tmp1 < sys_trx_start as A1, x, y from t1;
|
||||
|
||||
select sys_trx_start into @tmp1 from t1;
|
||||
update t1 set b=1 where id=1;
|
||||
select @tmp1 = sys_trx_start, b from t1;
|
||||
update t1 set y= 1 where id = 1;
|
||||
select @tmp1 = sys_trx_start as A2, x from t1;
|
||||
|
||||
drop table t1;
|
||||
end~~
|
||||
|
@ -252,8 +252,7 @@ call test_06('timestamp(6)', 'myisam', 'sys_end');
|
|||
call test_06('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
|
||||
|
||||
call test_07('timestamp(6)', 'myisam', 'sys_end');
|
||||
# Issue #53
|
||||
# call test_07('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
|
||||
call test_07('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
|
||||
|
||||
call verify_vtq;
|
||||
|
||||
|
|
|
@ -8959,6 +8959,8 @@ calc_row_difference(
|
|||
/* We use upd_buff to convert changed fields */
|
||||
buf = (byte*) upd_buff;
|
||||
|
||||
prebuilt->upd_node->versioned = false;
|
||||
|
||||
for (i = 0; i < table->s->fields; i++) {
|
||||
field = table->field[i];
|
||||
bool is_virtual = innobase_is_v_fld(field);
|
||||
|
@ -9199,6 +9201,13 @@ calc_row_difference(
|
|||
}
|
||||
n_changed++;
|
||||
|
||||
if (!prebuilt->upd_node->versioned &&
|
||||
DICT_TF2_FLAG_IS_SET(prebuilt->table, DICT_TF2_VERSIONED) &&
|
||||
!(field->flags & WITHOUT_SYSTEM_VERSIONING_FLAG))
|
||||
{
|
||||
prebuilt->upd_node->versioned = true;
|
||||
}
|
||||
|
||||
/* If an FTS indexed column was changed by this
|
||||
UPDATE then we need to inform the FTS sub-system.
|
||||
|
||||
|
@ -9303,6 +9312,13 @@ calc_row_difference(
|
|||
innodb_table, ufield, &trx->fts_next_doc_id);
|
||||
|
||||
++n_changed;
|
||||
|
||||
if (!prebuilt->upd_node->versioned &&
|
||||
DICT_TF2_FLAG_IS_SET(prebuilt->table, DICT_TF2_VERSIONED) &&
|
||||
!(field->flags & WITHOUT_SYSTEM_VERSIONING_FLAG))
|
||||
{
|
||||
prebuilt->upd_node->versioned = true;
|
||||
}
|
||||
} else {
|
||||
/* We have a Doc ID column, but none of FTS indexed
|
||||
columns are touched, nor the Doc ID column, so set
|
||||
|
@ -9486,7 +9502,7 @@ ha_innobase::update_row(
|
|||
|
||||
error = row_update_for_mysql((byte*) old_row, m_prebuilt);
|
||||
|
||||
if (error == DB_SUCCESS && DICT_TF2_FLAG_IS_SET(m_prebuilt->table, DICT_TF2_VERSIONED)) {
|
||||
if (error == DB_SUCCESS && m_prebuilt->upd_node->versioned) {
|
||||
if (trx->id != static_cast<trx_id_t>(table->vers_start_field()->val_int()))
|
||||
error = row_insert_for_mysql((byte*) old_row, m_prebuilt, true);
|
||||
}
|
||||
|
|
|
@ -582,6 +582,7 @@ struct upd_node_t{
|
|||
compilation; speeds up execution:
|
||||
UPD_NODE_NO_ORD_CHANGE and
|
||||
UPD_NODE_NO_SIZE_CHANGE, ORed */
|
||||
bool versioned;/* update is versioned */
|
||||
/*----------------------*/
|
||||
/* Local storage for this graph node */
|
||||
ulint state; /*!< node execution state */
|
||||
|
|
|
@ -2854,7 +2854,7 @@ row_ins_sec_index_entry_low(
|
|||
|
||||
cursor.thr = thr;
|
||||
cursor.rtr_info = NULL;
|
||||
ut_ad(thr_get_trx(thr)->id != 0);
|
||||
ut_ad(trx && trx->id != 0 || thr_get_trx(thr)->id != 0);
|
||||
|
||||
mtr_start(&mtr);
|
||||
mtr.set_named_space(index->space);
|
||||
|
@ -3890,7 +3890,7 @@ void vers_notify_vtq(trx_t* trx)
|
|||
timeval begin_ts, commit_ts;
|
||||
begin_ts.tv_sec = trx->start_time;
|
||||
begin_ts.tv_usec = trx->start_time_micro;
|
||||
ut_usectime((ulint *)&commit_ts.tv_sec, (ulint *)&commit_ts.tv_usec);
|
||||
ut_usectime((ulong*)&commit_ts.tv_sec, (ulong*)&commit_ts.tv_usec);
|
||||
|
||||
dict_table_copy_types(row, dict_sys->sys_vtq);
|
||||
set_row_field_8(row, DICT_FLD__SYS_VTQ__TRX_ID, trx->id, heap);
|
||||
|
|
|
@ -1957,7 +1957,8 @@ row_update_for_mysql_using_upd_graph(
|
|||
prebuilt->clust_pcur);
|
||||
}
|
||||
|
||||
if (DICT_TF2_FLAG_IS_SET(node->table, DICT_TF2_VERSIONED))
|
||||
if (DICT_TF2_FLAG_IS_SET(node->table, DICT_TF2_VERSIONED) &&
|
||||
(node->is_delete || node->versioned))
|
||||
{
|
||||
/* System Versioning: modify update vector to set
|
||||
sys_trx_start (or sys_trx_end in case of DELETE)
|
||||
|
|
|
@ -442,6 +442,8 @@ upd_node_create(
|
|||
node->common.type = QUE_NODE_UPDATE;
|
||||
node->state = UPD_NODE_UPDATE_CLUSTERED;
|
||||
node->heap = mem_heap_create(128);
|
||||
node->cmpl_info = 0;
|
||||
node->versioned = false;
|
||||
node->magic_n = UPD_NODE_MAGIC_N;
|
||||
|
||||
return(node);
|
||||
|
|
Loading…
Reference in a new issue