summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2021-03-31 16:36:36 +0300
committerEugene Kosov <claprix@yandex.ru>2021-04-15 17:53:33 +0300
commita3871cd2832dec43ca4ad6592646f58a7acf6630 (patch)
treea2f784ca1fca5923612bf661441849bae273834a
parent7fa12b1e34d3d561baed9e7f2aacb0d6a3eb7062 (diff)
downloadmariadb-git-a3871cd2832dec43ca4ad6592646f58a7acf6630.tar.gz
MDEV-22255 SIGABRT: Assertion `id' failed in trx_write_trx_id on INSERT | Assertion `id > 0' failed in trx_write_trx_id | Assertion `val > 0' failed in row_upd_index_entry_sys_field | Assertion `thr_get_trx(thr)->id || index->table->no_rollback()' failed.
-rw-r--r--mysql-test/suite/innodb/r/temporary_table.result91
-rw-r--r--mysql-test/suite/innodb/t/temporary_table.test102
-rw-r--r--storage/innobase/btr/btr0cur.cc13
-rw-r--r--storage/innobase/include/trx0sys.ic1
-rw-r--r--storage/innobase/pars/pars0pars.cc1
-rw-r--r--storage/innobase/row/row0ins.cc8
-rw-r--r--storage/innobase/row/row0uins.cc2
-rw-r--r--storage/innobase/row/row0umod.cc2
-rw-r--r--storage/innobase/row/row0undo.cc2
-rw-r--r--storage/innobase/row/row0upd.cc2
10 files changed, 212 insertions, 12 deletions
diff --git a/mysql-test/suite/innodb/r/temporary_table.result b/mysql-test/suite/innodb/r/temporary_table.result
index 628bb648ead..490179fe6cb 100644
--- a/mysql-test/suite/innodb/r/temporary_table.result
+++ b/mysql-test/suite/innodb/r/temporary_table.result
@@ -663,3 +663,94 @@ DROP TABLE t1;
END//
call t1_proc;
drop procedure t1_proc;
+CREATE TABLE t (c INT) ENGINE=InnoDB;
+INSERT INTO t VALUES(0);
+CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
+START TRANSACTION READ ONLY;
+INSERT INTO t2 SELECT * FROM t;
+COMMIT;
+DROP TABLE t, t2;
+CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
+START TRANSACTION READ ONLY;
+INSERT INTO t VALUES(0);
+ERROR 21S01: Column count doesn't match value count at row 1
+SAVEPOINT s;
+INSERT INTO t VALUES(0,0);
+COMMIT;
+DROP TABLE t;
+CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
+START TRANSACTION READ ONLY;
+INSERT INTO t VALUES(0);
+ERROR 21S01: Column count doesn't match value count at row 1
+SAVEPOINT s;
+INSERT INTO t VALUES(0,0);
+ROLLBACK;
+DROP TABLE t;
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET a= 2;
+COMMIT;
+DROP TABLE t1;
+CREATE TEMPORARY TABLE t(c INT) ENGINE=InnoDB;
+SET SESSION tx_read_only=TRUE;
+LOCK TABLE test.t READ;
+SELECT * FROM t;
+c
+INSERT INTO t VALUES(0xADC3);
+SET SESSION tx_read_only=FALSE;
+DROP TABLE t;
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET a= 2;
+COMMIT;
+DROP TABLE t1;
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1, 1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET b= 2;
+COMMIT;
+DROP TABLE t1;
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int, c varchar(255)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1, 1, repeat('a', 200));
+START TRANSACTION READ ONLY;
+UPDATE t1 SET b= 2, c=repeat('a', 250);
+COMMIT;
+DROP TABLE t1;
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET a= 2;
+ROLLBACK;
+DROP TABLE t1;
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+DELETE FROM t1 WHERE a= 2;
+COMMIT;
+DROP TABLE t1;
+CREATE TEMPORARY TABLE tmp (a INT) ENGINE=InnoDB;
+INSERT INTO tmp () VALUES (),();
+SET TX_READ_ONLY= 1;
+INSERT INTO tmp SELECT * FROM tmp;
+SET TX_READ_ONLY= 0;
+DROP TABLE tmp;
+SET sql_mode='';
+SET GLOBAL tx_read_only=TRUE;
+CREATE TEMPORARY TABLE t (c INT);
+SET SESSION tx_read_only=DEFAULT;
+INSERT INTO t VALUES(1);
+INSERT INTO t SELECT * FROM t;
+SET SESSION tx_read_only=FALSE;
+SET GLOBAL tx_read_only=OFF;
+DROP TABLE t;
+CREATE TEMPORARY TABLE t(a INT);
+SET SESSION tx_read_only=ON;
+LOCK TABLE t READ;
+SELECT COUNT(*)FROM t;
+COUNT(*)
+0
+INSERT INTO t VALUES (0);
+SET SESSION tx_read_only=OFF;
+DROP TABLE t;
diff --git a/mysql-test/suite/innodb/t/temporary_table.test b/mysql-test/suite/innodb/t/temporary_table.test
index 6856ca86323..42bd403d0be 100644
--- a/mysql-test/suite/innodb/t/temporary_table.test
+++ b/mysql-test/suite/innodb/t/temporary_table.test
@@ -493,3 +493,105 @@ delimiter ;//
call t1_proc;
drop procedure t1_proc;
+
+
+CREATE TABLE t (c INT) ENGINE=InnoDB;
+INSERT INTO t VALUES(0);
+CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
+START TRANSACTION READ ONLY;
+INSERT INTO t2 SELECT * FROM t;
+COMMIT;
+DROP TABLE t, t2;
+
+CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
+START TRANSACTION READ ONLY;
+--error ER_WRONG_VALUE_COUNT_ON_ROW
+INSERT INTO t VALUES(0);
+SAVEPOINT s;
+INSERT INTO t VALUES(0,0);
+COMMIT;
+DROP TABLE t;
+
+CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
+START TRANSACTION READ ONLY;
+--error ER_WRONG_VALUE_COUNT_ON_ROW
+INSERT INTO t VALUES(0);
+SAVEPOINT s;
+INSERT INTO t VALUES(0,0);
+ROLLBACK;
+DROP TABLE t;
+
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET a= 2;
+COMMIT;
+DROP TABLE t1;
+
+CREATE TEMPORARY TABLE t(c INT) ENGINE=InnoDB;
+SET SESSION tx_read_only=TRUE;
+LOCK TABLE test.t READ;
+SELECT * FROM t;
+INSERT INTO t VALUES(0xADC3);
+SET SESSION tx_read_only=FALSE;
+DROP TABLE t;
+
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET a= 2;
+COMMIT;
+DROP TABLE t1;
+
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1, 1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET b= 2;
+COMMIT;
+DROP TABLE t1;
+
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int, c varchar(255)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1, 1, repeat('a', 200));
+START TRANSACTION READ ONLY;
+UPDATE t1 SET b= 2, c=repeat('a', 250);
+COMMIT;
+DROP TABLE t1;
+
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+UPDATE t1 SET a= 2;
+ROLLBACK;
+DROP TABLE t1;
+
+CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+START TRANSACTION READ ONLY;
+DELETE FROM t1 WHERE a= 2;
+COMMIT;
+DROP TABLE t1;
+
+CREATE TEMPORARY TABLE tmp (a INT) ENGINE=InnoDB;
+INSERT INTO tmp () VALUES (),();
+SET TX_READ_ONLY= 1;
+INSERT INTO tmp SELECT * FROM tmp;
+SET TX_READ_ONLY= 0;
+DROP TABLE tmp;
+
+SET sql_mode='';
+SET GLOBAL tx_read_only=TRUE;
+CREATE TEMPORARY TABLE t (c INT);
+SET SESSION tx_read_only=DEFAULT;
+INSERT INTO t VALUES(1);
+INSERT INTO t SELECT * FROM t;
+SET SESSION tx_read_only=FALSE;
+SET GLOBAL tx_read_only=OFF;
+DROP TABLE t;
+
+CREATE TEMPORARY TABLE t(a INT);
+SET SESSION tx_read_only=ON;
+LOCK TABLE t READ;
+SELECT COUNT(*)FROM t;
+INSERT INTO t VALUES (0);
+SET SESSION tx_read_only=OFF;
+DROP TABLE t;
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 8f2acdb35bd..3bbddb79a0c 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -3242,7 +3242,8 @@ fail_err:
ut_ad(thr->graph->trx->id
== trx_read_trx_id(
static_cast<const byte*>(
- trx_id->data)));
+ trx_id->data))
+ || index->table->is_temporary());
}
}
#endif
@@ -3844,7 +3845,8 @@ btr_cur_update_in_place(
index = cursor->index;
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
- ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG));
+ ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
+ || index->table->is_temporary());
/* The insert buffer tree should never be updated in place. */
ut_ad(!dict_index_is_ibuf(index));
ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG)
@@ -4017,7 +4019,8 @@ btr_cur_optimistic_update(
page = buf_block_get_frame(block);
rec = btr_cur_get_rec(cursor);
index = cursor->index;
- ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG));
+ ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
+ || index->table->is_temporary());
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(mtr_is_block_fix(mtr, block, MTR_MEMO_PAGE_X_FIX, index->table));
/* This is intended only for leaf page updates */
@@ -4354,8 +4357,8 @@ btr_cur_pessimistic_update(
ut_ad(!page_zip || !dict_table_is_temporary(index->table));
/* The insert buffer tree should never be updated in place. */
ut_ad(!dict_index_is_ibuf(index));
- ut_ad(trx_id > 0
- || (flags & BTR_KEEP_SYS_FLAG));
+ ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
+ || index->table->is_temporary());
ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG)
|| dict_index_is_clust(index));
ut_ad(thr_get_trx(thr)->id == trx_id
diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic
index 0a4d583671f..c85695630f0 100644
--- a/storage/innobase/include/trx0sys.ic
+++ b/storage/innobase/include/trx0sys.ic
@@ -185,7 +185,6 @@ trx_write_trx_id(
#if DATA_TRX_ID_LEN != 6
# error "DATA_TRX_ID_LEN != 6"
#endif
- ut_ad(id > 0);
mach_write_to_6(ptr, id);
}
diff --git a/storage/innobase/pars/pars0pars.cc b/storage/innobase/pars/pars0pars.cc
index 280c4ee1815..991762673aa 100644
--- a/storage/innobase/pars/pars0pars.cc
+++ b/storage/innobase/pars/pars0pars.cc
@@ -1219,6 +1219,7 @@ pars_update_statement(
sel_node->row_lock_mode = LOCK_X;
} else {
node->has_clust_rec_x_lock = sel_node->set_x_locks;
+ ut_ad(node->has_clust_rec_x_lock);
}
ut_a(sel_node->n_tables == 1);
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 635e7f659eb..4dc9c66a536 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -3250,7 +3250,7 @@ row_ins_index_entry(
dtuple_t* entry, /*!< in/out: index entry to insert */
que_thr_t* thr) /*!< in: query thread */
{
- ut_ad(thr_get_trx(thr)->id != 0);
+ ut_ad(thr_get_trx(thr)->id != 0 || index->table->is_temporary());
DBUG_EXECUTE_IF("row_ins_index_entry_timeout", {
DBUG_SET("-d,row_ins_index_entry_timeout");
@@ -3613,12 +3613,16 @@ row_ins_step(
table during the search operation, and there is no need to set
it again here. But we must write trx->id to node->sys_buf. */
- trx_write_trx_id(&node->sys_buf[DATA_ROW_ID_LEN], trx->id);
+ trx_write_trx_id(&node->sys_buf[DATA_TRX_ID_LEN], trx->id);
if (node->state == INS_NODE_SET_IX_LOCK) {
node->state = INS_NODE_ALLOC_ROW_ID;
+ if (node->table->is_temporary()) {
+ node->trx_id = trx->id;
+ }
+
/* It may be that the current session has not yet started
its transaction, or it has been committed: */
diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc
index 915d4b99d16..8c944189de6 100644
--- a/storage/innobase/row/row0uins.cc
+++ b/storage/innobase/row/row0uins.cc
@@ -106,7 +106,7 @@ row_undo_ins_remove_clust_rec(
btr_cur = btr_pcur_get_btr_cur(&node->pcur);
ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur), btr_cur->index)
- == node->trx->id);
+ == node->trx->id || node->table->is_temporary());
ut_ad(!rec_get_deleted_flag(
btr_cur_get_rec(btr_cur),
dict_table_is_comp(btr_cur->index->table)));
diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc
index 80d90f40379..d207aa5b9bc 100644
--- a/storage/innobase/row/row0umod.cc
+++ b/storage/innobase/row/row0umod.cc
@@ -109,7 +109,7 @@ row_undo_mod_clust_low(
ut_ad(success);
ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur),
btr_cur_get_index(btr_cur))
- == thr_get_trx(thr)->id);
+ == thr_get_trx(thr)->id || node->index->table->is_temporary());
if (mode != BTR_MODIFY_LEAF
&& dict_index_is_online_ddl(btr_cur_get_index(btr_cur))) {
diff --git a/storage/innobase/row/row0undo.cc b/storage/innobase/row/row0undo.cc
index b65b173fedb..e1978cfb297 100644
--- a/storage/innobase/row/row0undo.cc
+++ b/storage/innobase/row/row0undo.cc
@@ -194,7 +194,7 @@ row_undo_search_clust_to_pcur(
if (found) {
ut_ad(row_get_rec_trx_id(rec, clust_index, offsets)
- == node->trx->id);
+ == node->trx->id || node->table->is_temporary());
if (dict_table_get_format(node->table) >= UNIV_FORMAT_B) {
/* In DYNAMIC or COMPRESSED format, there is
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 4b81d1478b0..429282906df 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -549,7 +549,7 @@ row_upd_index_entry_sys_field(
field = static_cast<byte*>(dfield_get_data(dfield));
if (type == DATA_TRX_ID) {
- ut_ad(val > 0);
+ ut_ad(val > 0 || index->table->is_temporary());
trx_write_trx_id(field, val);
} else {
ut_ad(type == DATA_ROLL_PTR);