summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/innobase/data/data0data.cc14
-rw-r--r--storage/innobase/dict/dict0mem.cc10
-rw-r--r--storage/innobase/handler/ha_innodb.cc14
-rw-r--r--storage/innobase/handler/handler0alter.cc3
-rw-r--r--storage/innobase/include/data0data.h19
-rw-r--r--storage/innobase/include/data0type.h15
-rw-r--r--storage/innobase/include/dict0mem.h14
-rw-r--r--storage/innobase/include/dict0types.h6
-rw-r--r--storage/innobase/include/trx0types.h3
-rw-r--r--storage/innobase/row/row0ins.cc7
-rw-r--r--storage/innobase/row/row0merge.cc4
-rw-r--r--storage/innobase/trx/trx0trx.cc5
12 files changed, 74 insertions, 40 deletions
diff --git a/storage/innobase/data/data0data.cc b/storage/innobase/data/data0data.cc
index fbdb409dbc5..6601edfec9d 100644
--- a/storage/innobase/data/data0data.cc
+++ b/storage/innobase/data/data0data.cc
@@ -861,17 +861,3 @@ dfield_t::clone(mem_heap_t* heap) const
return(obj);
}
-
-/** Assuming field is sys_trx_end checks whether its value is not SYS_TRX_MAX.
-@param dfield field to check
-@return true for historical rows and false otherwise*/
-bool
-dfield_is_historical_sys_trx_end(const dfield_t* dfield)
-{
- static const trx_id_t MAX = TRX_ID_MAX;
- ut_ad(dfield);
- ut_ad(dfield->type.prtype & DATA_VERS_END);
- const byte* data = static_cast<const byte*>(dfield_get_data(dfield));
- ut_ad(dfield_get_len(dfield) == 8);
- return(memcmp(data, &MAX, 8));
-}
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index 490889a5e57..2bba95d2404 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -312,11 +312,13 @@ dict_mem_table_add_col(
dict_mem_fill_column_struct(col, i, mtype, prtype, len);
- if (prtype & DATA_VERS_START) {
- ut_ad(!(prtype & DATA_VERS_END));
+ switch (prtype & DATA_VERSIONED) {
+ case DATA_VERS_START:
+ ut_ad(!table->vers_start);
table->vers_start = i;
- } else if (prtype & DATA_VERS_END) {
- ut_ad(!(prtype & DATA_VERS_START));
+ break;
+ case DATA_VERS_END:
+ ut_ad(!table->vers_end);
table->vers_end = i;
}
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b2be5e2f1b6..fa77f42516e 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -11413,14 +11413,16 @@ create_table_info_t::create_table_def()
bool is_stored = false;
Field* field = m_form->field[i];
- ulint vers_row_start = 0;
- ulint vers_row_end = 0;
+ ulint vers_row = 0;
if (m_form->versioned()) {
if (i == m_form->s->row_start_field) {
- vers_row_start = DATA_VERS_START;
+ vers_row = DATA_VERS_START;
} else if (i == m_form->s->row_end_field) {
- vers_row_end = DATA_VERS_END;
+ vers_row = DATA_VERS_END;
+ } else if (!(field->flags
+ & VERS_UPDATE_UNVERSIONED_FLAG)) {
+ vers_row = DATA_VERSIONED;
}
}
@@ -11514,7 +11516,7 @@ err_col:
(ulint) field->type()
| nulls_allowed | unsigned_type
| binary_type | long_true_varchar
- | vers_row_start | vers_row_end,
+ | vers_row,
charset_no),
col_len);
} else {
@@ -11524,7 +11526,7 @@ err_col:
(ulint) field->type()
| nulls_allowed | unsigned_type
| binary_type | long_true_varchar
- | vers_row_start | vers_row_end
+ | vers_row
| is_virtual,
charset_no),
col_len, i, 0);
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 64ef4a33504..a0fe046eccd 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -4983,6 +4983,9 @@ new_clustered_failed:
} else if (i ==
altered_table->s->row_end_field) {
field_type |= DATA_VERS_END;
+ } else if (!(field->flags
+ & VERS_UPDATE_UNVERSIONED_FLAG)) {
+ field_type |= DATA_VERSIONED;
}
}
diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h
index 30ad9a23260..0dde23a7820 100644
--- a/storage/innobase/include/data0data.h
+++ b/storage/innobase/include/data0data.h
@@ -508,12 +508,6 @@ dtuple_print(
const dtuple_t* tuple) /*!< in: tuple */
MY_ATTRIBUTE((nonnull));
-/** Assuming field is sys_trx_end checks whether its value is not SYS_TRX_MAX.
-@param dfield field to check
-@return true for historical rows and false otherwise*/
-bool
-dfield_is_historical_sys_trx_end(const dfield_t* dfield);
-
/** Print the contents of a tuple.
@param[out] o output stream
@param[in] field array of data fields
@@ -597,6 +591,19 @@ struct dfield_t{
@param[in,out] heap memory heap in which the clone will be created
@return the cloned object */
dfield_t* clone(mem_heap_t* heap) const;
+
+ /** @return whether this column is the end of the system
+ version history and points to the past, that is, this record
+ does not exist in the current time */
+ bool is_version_historical_end() const
+ {
+ if (!type.is_version_end()) {
+ return false;
+ }
+
+ ut_ad(len == sizeof trx_id_max_bytes);
+ return memcmp(data, trx_id_max_bytes, sizeof trx_id_max_bytes);
+ }
};
/** Structure for an SQL data tuple of fields (logical record) */
diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h
index d9c1cc24d24..c08058f9730 100644
--- a/storage/innobase/include/data0type.h
+++ b/storage/innobase/include/data0type.h
@@ -192,6 +192,8 @@ be less than 256 */
/** System Versioning */
#define DATA_VERS_START 16384U /* start system field */
#define DATA_VERS_END 32768U /* end system field */
+/** system-versioned user data column */
+#define DATA_VERSIONED (DATA_VERS_START|DATA_VERS_END)
/** Check whether locking is disabled (never). */
#define dict_table_is_locking_disabled(table) false
@@ -558,6 +560,19 @@ struct dtype_t{
DATA_MBMINMAXLEN(mbminlen,mbmaxlen);
mbminlen=DATA_MBMINLEN(mbminmaxlen);
mbmaxlen=DATA_MBMINLEN(mbminmaxlen) */
+
+ /** @return whether this is system versioned */
+ bool is_versioned() const { return !(~prtype & DATA_VERSIONED); }
+ /** @return whether this is the system version start */
+ bool is_version_start() const
+ {
+ return (prtype & DATA_VERSIONED) == DATA_VERS_START;
+ }
+ /** @return whether this is the system version end */
+ bool is_version_end() const
+ {
+ return (prtype & DATA_VERSIONED) == DATA_VERS_END;
+ }
};
#include "data0type.ic"
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 7897b4d8033..f80aabade6c 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -652,6 +652,20 @@ struct dict_col_t{
bool is_virtual() const { return prtype & DATA_VIRTUAL; }
/** @return whether NULL is an allowed value for this column */
bool is_nullable() const { return !(prtype & DATA_NOT_NULL); }
+
+ /** @return whether this is system versioned */
+ bool is_versioned() const { return !(~prtype & DATA_VERSIONED); }
+ /** @return whether this is the system version start */
+ bool is_version_start() const
+ {
+ return (prtype & DATA_VERSIONED) == DATA_VERS_START;
+ }
+ /** @return whether this is the system version end */
+ bool is_version_end() const
+ {
+ return (prtype & DATA_VERSIONED) == DATA_VERS_END;
+ }
+
/** @return whether this is an instantly-added column */
bool is_instant() const
{
diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h
index 27b4cc0e694..171fbc3efd9 100644
--- a/storage/innobase/include/dict0types.h
+++ b/storage/innobase/include/dict0types.h
@@ -52,6 +52,12 @@ DICT_IBUF_ID_MIN plus the space id */
typedef ib_id_t table_id_t;
typedef ib_id_t index_id_t;
+/** Maximum transaction identifier */
+#define TRX_ID_MAX IB_ID_MAX
+
+/** The bit pattern corresponding to TRX_ID_MAX */
+extern const char trx_id_max_bytes[8];
+
/** Error to ignore when we load table dictionary into memory. However,
the table and index will be marked as "corrupted", and caller will
be responsible to deal with corrupted table or index.
diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h
index b3da6f7b102..1bf07763015 100644
--- a/storage/innobase/include/trx0types.h
+++ b/storage/innobase/include/trx0types.h
@@ -140,9 +140,6 @@ typedef ib_id_t roll_ptr_t;
/** Undo number */
typedef ib_id_t undo_no_t;
-/** Maximum transaction identifier */
-#define TRX_ID_MAX IB_ID_MAX
-
/** Transaction savepoint */
struct trx_savept_t{
undo_no_t least_undo_no; /*!< least undo number to undo */
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index dfb67fde123..c6ac4fa2483 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -1701,11 +1701,8 @@ row_ins_check_foreign_constraint(
}
/* System Versioning: if sys_trx_end != Inf, we
suppress the foreign key check */
- if (dfield_get_type(field)->prtype & DATA_VERS_END) {
- ut_ad(table->versioned());
- if (dfield_is_historical_sys_trx_end(field)) {
- goto exit_func;
- }
+ if (field->is_version_historical_end()) {
+ goto exit_func;
}
}
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index ba9914e4978..ab23edd0fc6 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -2249,8 +2249,8 @@ end_of_index:
if (new_table->versioned()) {
const dfield_t* dfield = dtuple_get_nth_field(
row, new_table->vers_end);
- historical_row =
- dfield_is_historical_sys_trx_end(dfield);
+ historical_row
+ = dfield->is_version_historical_end();
}
const dfield_t* dfield;
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 3f09cf8b0b1..dd990d984b7 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -62,6 +62,11 @@ Created 3/26/1996 Heikki Tuuri
extern "C"
int thd_deadlock_victim_preference(const MYSQL_THD thd1, const MYSQL_THD thd2);
+/** The bit pattern corresponding to TRX_ID_MAX */
+const char trx_id_max_bytes[8] = {
+ '\377', '\377', '\377', '\377', '\377', '\377', '\377', '\377'
+};
+
static const ulint MAX_DETAILED_ERROR_LEN = 256;
/** Set of table_id */