Commit 8acf4d6f authored by Marko Mäkelä's avatar Marko Mäkelä

Follow-up fixes for MDEV-10139 Support for InnoDB SEQUENCE objects

Because SEQUENCE objects or NO_ROLLBACK tables do not support locking
or MVCC or transactions, avoid starting a transaction.

row_upd_step(): Do not start a transaction. Let the caller do that.

que_thr_step(): Call trx_start_if_not_started_xa() for QUE_NODE_UPDATE.
(The InnoDB SQL parser is not used for accessing NO_ROLLBACK tables.)

row_ins_step(): Correct a too strict assertion and comment about
concurrency. Multiple concurrent readers are allowed.

row_update_for_mysql_using_upd_graph(): Do not start the transaction
for NO_ROLLBACK tables.

row_search_mvcc(): For NO_ROLLBACK tables, skip locking even inside
LOCK TABLES. Only call trx_start_if_not_started() at the start
of a statement, not for each individual request.
parent 9497a646
......@@ -1031,6 +1031,7 @@ que_thr_step(
} else if (type == QUE_NODE_INSERT) {
thr = row_ins_step(thr);
} else if (type == QUE_NODE_UPDATE) {
trx_start_if_not_started_xa(thr_get_trx(thr), true);
thr = row_upd_step(thr);
} else if (type == QUE_NODE_FETCH) {
thr = fetch_step(thr);
......
......@@ -3726,10 +3726,10 @@ row_ins_step(
it again here. But we must write trx->id to node->trx_id_buf. */
if (node->table->no_rollback()) {
/* No-rollback tables should only be accessed by a
single thread at a time. Concurrency control (mutual
exclusion) must be guaranteed by the SQL layer. */
DBUG_ASSERT(node->table->n_ref_count == 1);
/* No-rollback tables should only be written to by a
single thread at a time, but there can be multiple
concurrent readers. We must hold an open table handle. */
DBUG_ASSERT(node->table->n_ref_count > 0);
DBUG_ASSERT(node->ins_type == INS_DIRECT);
/* No-rollback tables can consist only of a single index. */
DBUG_ASSERT(UT_LIST_GET_LEN(node->entry_list) == 1);
......
......@@ -1888,7 +1888,9 @@ row_update_for_mysql_using_upd_graph(
init_fts_doc_id_for_ref(table, &fk_depth);
if (!table->no_rollback()) {
trx_start_if_not_started_xa(trx, true);
}
if (dict_table_is_referenced_by_foreign_key(table)) {
/* Share lock the data dictionary to prevent any
......
......@@ -4481,8 +4481,6 @@ row_search_mvcc(
|| MVCC::is_view_active(trx->read_view)
|| srv_read_only_mode);
trx_start_if_not_started(trx, false);
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
&& prebuilt->select_lock_type != LOCK_NONE
&& trx->mysql_thd != NULL
......@@ -4533,9 +4531,14 @@ row_search_mvcc(
fputc('\n', stderr);
ut_error;
}
} else if (prebuilt->table->no_rollback()) {
/* NO_ROLLBACK tables do not support MVCC or locking. */
prebuilt->select_lock_type = LOCK_NONE;
prebuilt->sql_stat_start = FALSE;
} else if (prebuilt->select_lock_type == LOCK_NONE) {
/* This is a consistent read */
/* Assign a read view for the query */
trx_start_if_not_started(trx, false);
if (!srv_read_only_mode) {
trx_assign_read_view(trx);
......@@ -4543,6 +4546,7 @@ row_search_mvcc(
prebuilt->sql_stat_start = FALSE;
} else {
trx_start_if_not_started(trx, false);
wait_table_again:
err = lock_table(0, prebuilt->table,
prebuilt->select_lock_type == LOCK_S
......
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2016, MariaDB Corporation.
Copyright (c) 2015, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -3128,7 +3128,8 @@ row_upd_clust_step(
}
}
ut_ad(lock_trx_has_rec_x_lock(thr_get_trx(thr), index->table,
ut_ad(index->table->no_rollback()
|| lock_trx_has_rec_x_lock(thr_get_trx(thr), index->table,
btr_pcur_get_block(pcur),
page_rec_get_heap_no(rec)));
......@@ -3330,8 +3331,6 @@ row_upd_step(
trx = thr_get_trx(thr);
trx_start_if_not_started_xa(trx, true);
node = static_cast<upd_node_t*>(thr->run_node);
sel_node = node->select;
......
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