Commit ffc0a08d authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.3 into 10.4

parents 071feae3 02e30069
......@@ -492,3 +492,25 @@ SET @@SYSTEM_VERSIONING_ALTER_HISTORY=ERROR;
SELECT count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp;
count(*)
0
# MDEV-18875 Assertion `thd->transaction.stmt.ha_list == __null ||
# trans == &thd->transaction.stmt' failed or bogus ER_DUP_ENTRY upon
# ALTER TABLE with versioning
create or replace table t (x int) engine=innodb;
set autocommit= 0;
alter table t
algorithm=copy,
add column row_start bigint unsigned as row start,
add column row_end bigint unsigned as row end,
add period for system_time(row_start,row_end),
with system versioning;
set autocommit= 1;
# MDEV-18865 Assertion `t->first->versioned_by_id()'
# failed in innodb_prepare_commit_versioned
create or replace table t (x int) engine=innodb;
insert into t values (0);
alter table t add `row_start` bigint unsigned as row start,
add `row_end` bigint unsigned as row end,
add period for system_time(`row_start`,`row_end`),
modify x int after row_start,
with system versioning;
create or replace database test;
......@@ -498,3 +498,30 @@ DROP TABLE t;
SET @@SYSTEM_VERSIONING_ALTER_HISTORY=ERROR;
SELECT count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp;
--echo # MDEV-18875 Assertion `thd->transaction.stmt.ha_list == __null ||
--echo # trans == &thd->transaction.stmt' failed or bogus ER_DUP_ENTRY upon
--echo # ALTER TABLE with versioning
create or replace table t (x int) engine=innodb;
set autocommit= 0;
alter table t
algorithm=copy,
add column row_start bigint unsigned as row start,
add column row_end bigint unsigned as row end,
add period for system_time(row_start,row_end),
with system versioning;
set autocommit= 1;
--echo # MDEV-18865 Assertion `t->first->versioned_by_id()'
--echo # failed in innodb_prepare_commit_versioned
create or replace table t (x int) engine=innodb;
insert into t values (0);
alter table t add `row_start` bigint unsigned as row start,
add `row_end` bigint unsigned as row end,
add period for system_time(`row_start`,`row_end`),
modify x int after row_start,
with system versioning;
create or replace database test;
......@@ -1513,7 +1513,8 @@ int ha_commit_trans(THD *thd, bool all)
#if 1 // FIXME: This should be done in ha_prepare().
if (rw_trans || (thd->lex->sql_command == SQLCOM_ALTER_TABLE &&
thd->lex->alter_info.flags & ALTER_ADD_SYSTEM_VERSIONING))
thd->lex->alter_info.flags & ALTER_ADD_SYSTEM_VERSIONING &&
is_real_trans))
{
ulonglong trx_start_id= 0, trx_end_id= 0;
for (Ha_trx_info *ha_info= trans->ha_list; ha_info; ha_info= ha_info->next())
......
......@@ -10920,6 +10920,9 @@ create_table_info_t::create_table_def()
heap = mem_heap_create(1000);
ut_d(bool have_vers_start = false);
ut_d(bool have_vers_end = false);
for (ulint i = 0, j = 0; j < n_cols; i++) {
Field* field = m_form->field[i];
ulint vers_row = 0;
......@@ -10927,8 +10930,10 @@ create_table_info_t::create_table_def()
if (m_form->versioned()) {
if (i == m_form->s->vers.start_fieldno) {
vers_row = DATA_VERS_START;
ut_d(have_vers_start = true);
} else if (i == m_form->s->vers.end_fieldno) {
vers_row = DATA_VERS_END;
ut_d(have_vers_end = true);
} else if (!(field->flags
& VERS_UPDATE_UNVERSIONED_FLAG)) {
vers_row = DATA_VERSIONED;
......@@ -11049,6 +11054,10 @@ create_table_info_t::create_table_def()
j++;
}
ut_ad(have_vers_start == have_vers_end);
ut_ad(table->versioned() == have_vers_start);
ut_ad(!table->versioned() || table->vers_start != table->vers_end);
if (num_v) {
for (ulint i = 0, j = 0; i < n_cols; i++) {
dict_v_col_t* v_col;
......
......@@ -1854,10 +1854,14 @@ struct dict_table_t {
/** Add the table definition to the data dictionary cache */
void add_to_cache();
/** @return whether the table is versioned.
It is assumed that both vers_start and vers_end set to 0
iff table is not versioned. In any other case,
these fields correspond to actual positions in cols[]. */
bool versioned() const { return vers_start || vers_end; }
bool versioned_by_id() const
{
return vers_start && cols[vers_start].mtype == DATA_INT;
return versioned() && cols[vers_start].mtype == DATA_INT;
}
void inc_fk_checks()
......
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