Commit fd73c6dd authored by Eugene Kosov's avatar Eugene Kosov

Vers IB: Mark unversioned fields in system versioning tables

Some fields in system-versioned table may be unversioned.
SQL layer marks unversioned.
And this patch makes InnoDB mark unversioned too because of two reasons:
1) by default fields are versioned
2) most of fields are expected to be versioned

dtype_t::vers_sys_field(): fixed return true on row_start/row_end
dict_col_t::vers_sys_field(): fixed return true on row_start/row_end
parent 0cf97ad5
...@@ -312,14 +312,15 @@ dict_mem_table_add_col( ...@@ -312,14 +312,15 @@ dict_mem_table_add_col(
dict_mem_fill_column_struct(col, i, mtype, prtype, len); dict_mem_fill_column_struct(col, i, mtype, prtype, len);
switch (prtype & DATA_VERSIONED) { if ((prtype & DATA_UNVERSIONED) != DATA_UNVERSIONED) {
case DATA_VERS_START: if (prtype & DATA_VERS_START) {
ut_ad(!table->vers_start); ut_ad(!table->vers_start);
table->vers_start = i; table->vers_start = i;
break; }
case DATA_VERS_END: if (prtype & DATA_VERS_END) {
ut_ad(!table->vers_end); ut_ad(!table->vers_end);
table->vers_end = i; table->vers_end = i;
}
} }
} }
......
...@@ -11265,9 +11265,9 @@ create_table_info_t::create_table_def() ...@@ -11265,9 +11265,9 @@ create_table_info_t::create_table_def()
vers_row = DATA_VERS_START; vers_row = DATA_VERS_START;
} else if (i == m_form->s->row_end_field) { } else if (i == m_form->s->row_end_field) {
vers_row = DATA_VERS_END; vers_row = DATA_VERS_END;
} else if (!(field->flags } else if (field->flags
& VERS_UPDATE_UNVERSIONED_FLAG)) { & VERS_UPDATE_UNVERSIONED_FLAG) {
vers_row = DATA_VERSIONED; vers_row = DATA_UNVERSIONED;
} }
} }
......
...@@ -5009,9 +5009,9 @@ prepare_inplace_alter_table_dict( ...@@ -5009,9 +5009,9 @@ prepare_inplace_alter_table_dict(
} else if (i == } else if (i ==
altered_table->s->row_end_field) { altered_table->s->row_end_field) {
field_type |= DATA_VERS_END; field_type |= DATA_VERS_END;
} else if (!(field->flags } else if (field->flags
& VERS_UPDATE_UNVERSIONED_FLAG)) { & VERS_UPDATE_UNVERSIONED_FLAG) {
field_type |= DATA_VERSIONED; field_type |= DATA_UNVERSIONED;
} }
} }
......
...@@ -192,8 +192,7 @@ be less than 256 */ ...@@ -192,8 +192,7 @@ be less than 256 */
/** System Versioning */ /** System Versioning */
#define DATA_VERS_START 16384U /* start system field */ #define DATA_VERS_START 16384U /* start system field */
#define DATA_VERS_END 32768U /* end system field */ #define DATA_VERS_END 32768U /* end system field */
/** system-versioned user data column */ #define DATA_UNVERSIONED (DATA_VERS_START|DATA_VERS_END) /* unversioned user field */
#define DATA_VERSIONED (DATA_VERS_START|DATA_VERS_END)
/** Check whether locking is disabled (never). */ /** Check whether locking is disabled (never). */
#define dict_table_is_locking_disabled(table) false #define dict_table_is_locking_disabled(table) false
...@@ -543,18 +542,21 @@ struct dtype_t{ ...@@ -543,18 +542,21 @@ struct dtype_t{
in bytes */ in bytes */
/** @return whether this is system field */ /** @return whether this is system field */
bool vers_sys_field() const { return prtype & DATA_VERSIONED; } bool vers_sys_field() const
{
return vers_sys_start() || vers_sys_end();
}
/** @return whether this is system versioned user field */ /** @return whether this is system versioned user field */
bool is_versioned() const { return !(~prtype & DATA_VERSIONED); } bool is_versioned() const { return (prtype & DATA_UNVERSIONED) == 0; }
/** @return whether this is the system field start */ /** @return whether this is the system field start */
bool vers_sys_start() const bool vers_sys_start() const
{ {
return (prtype & DATA_VERSIONED) == DATA_VERS_START; return (prtype & DATA_UNVERSIONED) == DATA_VERS_START;
} }
/** @return whether this is the system field end */ /** @return whether this is the system field end */
bool vers_sys_end() const bool vers_sys_end() const
{ {
return (prtype & DATA_VERSIONED) == DATA_VERS_END; return (prtype & DATA_UNVERSIONED) == DATA_VERS_END;
} }
}; };
......
...@@ -653,7 +653,10 @@ struct dict_col_t{ ...@@ -653,7 +653,10 @@ struct dict_col_t{
bool is_nullable() const { return !(prtype & DATA_NOT_NULL); } bool is_nullable() const { return !(prtype & DATA_NOT_NULL); }
/** @return whether this is system field */ /** @return whether this is system field */
bool vers_sys_field() const { return prtype & DATA_VERSIONED; } bool vers_sys_field() const
{
return vers_sys_start() || vers_sys_end();
}
/** @return whether table of this system field is TRX_ID-based */ /** @return whether table of this system field is TRX_ID-based */
bool vers_native() const bool vers_native() const
{ {
...@@ -662,16 +665,16 @@ struct dict_col_t{ ...@@ -662,16 +665,16 @@ struct dict_col_t{
return mtype == DATA_INT; return mtype == DATA_INT;
} }
/** @return whether this is system versioned */ /** @return whether this is system versioned */
bool is_versioned() const { return !(~prtype & DATA_VERSIONED); } bool is_versioned() const { return (prtype & DATA_UNVERSIONED) == 0; }
/** @return whether this is the system version start */ /** @return whether this is the system version start */
bool vers_sys_start() const bool vers_sys_start() const
{ {
return (prtype & DATA_VERSIONED) == DATA_VERS_START; return (prtype & DATA_UNVERSIONED) == DATA_VERS_START;
} }
/** @return whether this is the system version end */ /** @return whether this is the system version end */
bool vers_sys_end() const bool vers_sys_end() const
{ {
return (prtype & DATA_VERSIONED) == DATA_VERS_END; return (prtype & DATA_UNVERSIONED) == DATA_VERS_END;
} }
/** @return whether this is an instantly-added column */ /** @return whether this is an instantly-added column */
......
...@@ -474,11 +474,16 @@ struct upd_t{ ...@@ -474,11 +474,16 @@ struct upd_t{
return(false); return(false);
} }
/** Determine if the update affects a system versioned column. */ /** Determine if the update affects a system versioned column or row_end. */
bool affects_versioned() const bool affects_versioned() const
{ {
for (ulint i = 0; i < n_fields; i++) { for (ulint i = 0; i < n_fields; i++) {
if (fields[i].new_val.type.vers_sys_field()) { dtype_t type = fields[i].new_val.type;
if (type.is_versioned()) {
return true;
}
// versioned DELETE is UPDATE SET row_end=NOW
if (type.vers_sys_end()) {
return true; return true;
} }
} }
......
...@@ -2089,8 +2089,8 @@ trx_undo_report_row_operation( ...@@ -2089,8 +2089,8 @@ trx_undo_report_row_operation(
if (!time.is_versioned() if (!time.is_versioned()
&& index->table->versioned_by_id() && index->table->versioned_by_id()
&& (!rec /* INSERT */ && (!rec /* INSERT */
|| !update /* DELETE */ || (update
|| update->affects_versioned())) { && update->affects_versioned()))) {
time.set_versioned(limit); time.set_versioned(limit);
} }
} }
......
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