summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2019-03-24 19:01:54 +1000
committerMarko Mäkelä <marko.makela@mariadb.com>2019-12-29 12:16:04 +0200
commit4923604ee2fba372f28c856a3f41274f7fc6c1c5 (patch)
tree93854e829cafa7ed4af7222f870d401ea49bba59
parent720e9bd5bed73fdc5b2452a6400431e08ae7eb6f (diff)
downloadmariadb-git-4923604ee2fba372f28c856a3f41274f7fc6c1c5.tar.gz
MDEV-18865 Assertion `t->first->versioned_by_id()' failed in innodb_prepare_commit_versionedbb-10.3-trxid_fixes
Cause: * row_start != 0 treated as it exists. Probably, possible row permutations had not been taken in mind. Solution: * Checking both row_start and row_end is correct, so versioned() function is used
-rw-r--r--mysql-test/suite/versioning/r/trx_id.result9
-rw-r--r--mysql-test/suite/versioning/t/trx_id.test12
-rw-r--r--storage/innobase/handler/ha_innodb.cc9
-rw-r--r--storage/innobase/include/dict0mem.h6
4 files changed, 35 insertions, 1 deletions
diff --git a/mysql-test/suite/versioning/r/trx_id.result b/mysql-test/suite/versioning/r/trx_id.result
index 7c4a540c52a..a140052439c 100644
--- a/mysql-test/suite/versioning/r/trx_id.result
+++ b/mysql-test/suite/versioning/r/trx_id.result
@@ -488,4 +488,13 @@ 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;
diff --git a/mysql-test/suite/versioning/t/trx_id.test b/mysql-test/suite/versioning/t/trx_id.test
index 97935ffc975..38724a47fd1 100644
--- a/mysql-test/suite/versioning/t/trx_id.test
+++ b/mysql-test/suite/versioning/t/trx_id.test
@@ -512,4 +512,16 @@ alter table t
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;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index e5387cd256e..6b0b49908c8 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -10905,6 +10905,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;
@@ -10912,8 +10915,10 @@ create_table_info_t::create_table_def()
if (m_form->versioned()) {
if (i == m_form->s->row_start_field) {
vers_row = DATA_VERS_START;
+ ut_d(have_vers_start = true);
} else if (i == m_form->s->row_end_field) {
vers_row = DATA_VERS_END;
+ ut_d(have_vers_end = true);
} else if (!(field->flags
& VERS_UPDATE_UNVERSIONED_FLAG)) {
vers_row = DATA_VERSIONED;
@@ -11034,6 +11039,10 @@ err_col:
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;
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 8c5314ed39d..1a22470569e 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1603,10 +1603,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()