Commit 98e3034e authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-25534 Assertion lock_table_has...LOCK_IX

ha_innobase::start_stmt(): Always set m_prebuilt->sql_stat_start.

row_search_mvcc(): Cleanup: Simplify debug assertions.
parent a29618f3
...@@ -159,3 +159,18 @@ a ...@@ -159,3 +159,18 @@ a
1 1
2 2
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-25534 Assertion lock_table_has...LOCK_IX
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET autocommit=0;
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES (1);
COMMIT;
CREATE TEMPORARY TABLE t0 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t0 VALUES (1);
INSERT INTO t1 VALUES (2);
COMMIT;
SET autocommit=1;
DROP TABLE t1;
DROP TEMPORARY TABLE t0;
...@@ -167,3 +167,19 @@ SET GLOBAL innodb_limit_optimistic_insert_debug = @save_limit; ...@@ -167,3 +167,19 @@ SET GLOBAL innodb_limit_optimistic_insert_debug = @save_limit;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-25534 Assertion lock_table_has...LOCK_IX
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET autocommit=0;
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES (1);
COMMIT;
CREATE TEMPORARY TABLE t0 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t0 VALUES (1);
INSERT INTO t1 VALUES (2);
COMMIT;
SET autocommit=1;
DROP TABLE t1;
DROP TEMPORARY TABLE t0;
...@@ -15279,7 +15279,6 @@ ha_innobase::start_stmt( ...@@ -15279,7 +15279,6 @@ ha_innobase::start_stmt(
/* fall through */ /* fall through */
default: default:
trx->end_bulk_insert(*m_prebuilt->table); trx->end_bulk_insert(*m_prebuilt->table);
m_prebuilt->sql_stat_start = TRUE;
if (!trx->bulk_insert) { if (!trx->bulk_insert) {
break; break;
} }
...@@ -15287,6 +15286,8 @@ ha_innobase::start_stmt( ...@@ -15287,6 +15286,8 @@ ha_innobase::start_stmt(
trx->last_sql_stat_start.least_undo_no = trx->undo_no; trx->last_sql_stat_start.least_undo_no = trx->undo_no;
} }
m_prebuilt->sql_stat_start = TRUE;
if (m_prebuilt->table->is_temporary() if (m_prebuilt->table->is_temporary()
&& m_mysql_has_locked && m_mysql_has_locked
&& m_prebuilt->select_lock_type == LOCK_NONE) { && m_prebuilt->select_lock_type == LOCK_NONE) {
......
...@@ -4559,16 +4559,22 @@ row_search_mvcc( ...@@ -4559,16 +4559,22 @@ row_search_mvcc(
spatial_search = dict_index_is_spatial(index) spatial_search = dict_index_is_spatial(index)
&& mode >= PAGE_CUR_CONTAIN; && mode >= PAGE_CUR_CONTAIN;
#ifdef UNIV_DEBUG
/* The state of a running trx can only be changed by the /* The state of a running trx can only be changed by the
thread that is currently serving the transaction. Because we thread that is currently serving the transaction. Because we
are that thread, we can read trx->state without holding any are that thread, we can read trx->state without holding any
mutex. */ mutex. */
ut_ad(prebuilt->sql_stat_start switch (trx->state) {
|| trx->state == TRX_STATE_ACTIVE case TRX_STATE_ACTIVE:
|| (prebuilt->table->no_rollback() break;
&& trx->state == TRX_STATE_NOT_STARTED)); case TRX_STATE_NOT_STARTED:
ut_ad(prebuilt->sql_stat_start
ut_ad(!trx_is_started(trx) || trx->state == TRX_STATE_ACTIVE); || prebuilt->table->no_rollback());
break;
default:
ut_ad("invalid trx->state" == 0);
}
#endif
ut_ad(prebuilt->sql_stat_start ut_ad(prebuilt->sql_stat_start
|| prebuilt->select_lock_type != LOCK_NONE || prebuilt->select_lock_type != LOCK_NONE
......
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