summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-03-23 16:33:37 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-03-23 16:33:37 +0200
commit245979f5e02303b1a8336d13578d1c030af7d685 (patch)
tree2a150685a6a7c71411720a8ba9df10627329ce7c
parentf9d67a39f3b8f8ebb0248d06c170cc1cb2c1f1a9 (diff)
downloadmariadb-git-245979f5e02303b1a8336d13578d1c030af7d685.tar.gz
MDEV-10139 Support for InnoDB SEQUENCE objects (work in progress)
This is a first patch (a quick hack, you might say). We introduce a NO_ROLLBACK flag for InnoDB tables. This flag only works for tables that have a single index. TODO: Is this really safe? Test if the NO_ROLLBACK table can momentarily lose records, for example when REPLACE is updating an existing row. (The low-level data structures will be crash-safe, but such high-level safely might not be guaranteed.) dict_table_t::no_rollback(): Check if the table does not support rollback. BTR_NO_ROLLBACK: Logging and locking flags for no_rollback() tables. DICT_TF_BITS: Add the NO_ROLLBACK flag.
-rw-r--r--storage/innobase/dict/dict0dict.cc1
-rw-r--r--storage/innobase/handler/ha_innodb.cc8
-rw-r--r--storage/innobase/include/btr0cur.h5
-rw-r--r--storage/innobase/include/dict0mem.h28
-rw-r--r--storage/innobase/row/row0ins.cc2
-rw-r--r--storage/innobase/row/row0upd.cc6
6 files changed, 38 insertions, 12 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index dc64163bee3..d1ef2b536cc 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -2502,6 +2502,7 @@ dict_index_add_to_cache_w_vcol(
ut_d(mem_heap_validate(index->heap));
ut_a(!dict_index_is_clust(index)
|| UT_LIST_GET_LEN(table->indexes) == 0);
+ ut_ad(dict_index_is_clust(index) || !table->no_rollback());
if (!dict_index_find_cols(table, index, add_v)) {
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 93c15c74943..d024356039e 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -12898,6 +12898,10 @@ index_bad:
default_compression_level : static_cast<ulint>(options->page_compression_level),
0);
+ if (m_form->s->table_type == TABLE_TYPE_SEQUENCE) {
+ m_flags |= 1U << DICT_TF_POS_NO_ROLLBACK;
+ }
+
/* Set the flags2 when create table or alter tables */
m_flags2 |= DICT_TF2_FTS_AUX_HEX_NAME;
DBUG_EXECUTE_IF("innodb_test_wrong_fts_aux_table_name",
@@ -13528,6 +13532,10 @@ ha_innobase::create(
trx_t* trx;
DBUG_ENTER("ha_innobase::create");
+ DBUG_ASSERT(form->s == table_share);
+ DBUG_ASSERT(table_share->table_type == TABLE_TYPE_SEQUENCE
+ || table_share->table_type == TABLE_TYPE_NORMAL);
+
create_table_info_t info(ha_thd(),
form,
create_info,
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index fee7f375cb4..e1f5286e122 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -42,6 +42,11 @@ enum {
/** sys fields will be found in the update vector or inserted
entry */
BTR_KEEP_SYS_FLAG = 4,
+
+ /** no rollback */
+ BTR_NO_ROLLBACK = BTR_NO_UNDO_LOG_FLAG
+ | BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG,
+
/** btr_cur_pessimistic_update() must keep cursor position
when moving columns to big_rec */
BTR_KEEP_POS_FLAG = 8,
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 0630137bb4f..9b87e654b21 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -148,16 +148,19 @@ Width of the page compression flag
#define DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL 4
/**
+Width of atomic writes flag
+DEFAULT=0, ON = 1, OFF = 2
+*/
+#define DICT_TF_WIDTH_ATOMIC_WRITES 2
+
+/**
Width of the page encryption flag
*/
#define DICT_TF_WIDTH_PAGE_ENCRYPTION 1
#define DICT_TF_WIDTH_PAGE_ENCRYPTION_KEY 8
-/**
-Width of atomic writes flag
-DEFAULT=0, ON = 1, OFF = 2
-*/
-#define DICT_TF_WIDTH_ATOMIC_WRITES 2
+/** Width of the NO_ROLLBACK flag */
+#define DICT_TF_WIDTH_NO_ROLLBACK 1
/** Width of all the currently known table flags */
#define DICT_TF_BITS (DICT_TF_WIDTH_COMPACT \
@@ -169,7 +172,8 @@ DEFAULT=0, ON = 1, OFF = 2
+ DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL \
+ DICT_TF_WIDTH_ATOMIC_WRITES \
+ DICT_TF_WIDTH_PAGE_ENCRYPTION \
- + DICT_TF_WIDTH_PAGE_ENCRYPTION_KEY)
+ + DICT_TF_WIDTH_PAGE_ENCRYPTION_KEY \
+ + DICT_TF_WIDTH_NO_ROLLBACK)
/** A mask of all the known/used bits in table flags */
#define DICT_TF_BIT_MASK (~(~0U << DICT_TF_BITS))
@@ -203,9 +207,11 @@ DEFAULT=0, ON = 1, OFF = 2
/** Zero relative shift position of the PAGE_ENCRYPTION_KEY field */
#define DICT_TF_POS_PAGE_ENCRYPTION_KEY (DICT_TF_POS_PAGE_ENCRYPTION \
+ DICT_TF_WIDTH_PAGE_ENCRYPTION)
-#define DICT_TF_POS_UNUSED (DICT_TF_POS_PAGE_ENCRYPTION_KEY \
+/** Zero relative shift position of the NO_ROLLBACK field */
+#define DICT_TF_POS_NO_ROLLBACK (DICT_TF_POS_PAGE_ENCRYPTION_KEY \
+ DICT_TF_WIDTH_PAGE_ENCRYPTION_KEY)
-
+#define DICT_TF_POS_UNUSED (DICT_TF_POS_NO_ROLLBACK \
+ + DICT_TF_WIDTH_NO_ROLLBACK)
/** Bit mask of the COMPACT field */
#define DICT_TF_MASK_COMPACT \
((~(~0U << DICT_TF_WIDTH_COMPACT)) \
@@ -1357,6 +1363,12 @@ struct dict_table_t {
/** Release the table handle. */
inline void release();
+ /** @return whether the table supports transactions */
+ bool no_rollback() const
+ {
+ return flags & (1U << DICT_TF_POS_NO_ROLLBACK);
+ }
+
/** Id of the table. */
table_id_t id;
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 9626645ebf2..d2d938d7757 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -3169,7 +3169,7 @@ row_ins_clust_index_entry(
log_free_check();
const ulint flags = dict_table_is_temporary(index->table)
? BTR_NO_LOCKING_FLAG
- : 0;
+ : index->table->no_rollback() ? BTR_NO_ROLLBACK : 0;
err = row_ins_clust_index_entry_low(
flags, BTR_MODIFY_LEAF, index, n_uniq, entry,
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 9c159c6bd15..b8d26672479 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -2264,7 +2264,7 @@ row_upd_sec_index_entry(
flags = BTR_NO_LOCKING_FLAG;
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
- flags = 0;
+ flags = index->table->no_rollback() ? BTR_NO_ROLLBACK : 0;
}
if (!index->is_committed()) {
@@ -3050,11 +3050,11 @@ row_upd_clust_step(
server or connection lifetime and so REDO information is not needed
on restart for recovery.
Disable locking as temp-tables are not shared across connection. */
- if (dict_table_is_temporary(index->table)) {
+ if (dict_table_is_temporary(node->table)) {
flags = BTR_NO_LOCKING_FLAG;
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
- flags = 0;
+ flags = node->table->no_rollback() ? BTR_NO_ROLLBACK : 0;
}
/* If the restoration does not succeed, then the same