summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc47
1 files changed, 29 insertions, 18 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index aebfeb17b2c..20bf32f3cdc 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -7325,7 +7325,6 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f
f->flags= flags | NOT_NULL_FLAG;
if (integer)
{
- DBUG_ASSERT(0); // Not implemented yet
f->set_handler(&type_handler_vers_trx_id);
f->length= MY_INT64_NUM_DECIMAL_DIGITS - 1;
f->flags|= UNSIGNED_FLAG;
@@ -7343,10 +7342,13 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f
return f;
}
-static bool vers_create_sys_field(THD *thd, const char *field_name,
- Alter_info *alter_info, int flags)
+bool Vers_parse_info::create_sys_field(THD *thd, const char *field_name,
+ Alter_info *alter_info, int flags)
{
- Create_field *f= vers_init_sys_field(thd, field_name, flags, false);
+ DBUG_ASSERT(can_native >= 0); /* Requires vers_check_native() called */
+ Create_field *f= vers_init_sys_field(thd, field_name, flags,
+ DBUG_EVALUATE_IF("sysvers_force_trx",
+ (bool) can_native, false));
if (!f)
return true;
@@ -7370,8 +7372,8 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info)
period= start_end_t(default_start, default_end);
as_row= period;
- if (vers_create_sys_field(thd, default_start, alter_info, VERS_ROW_START) ||
- vers_create_sys_field(thd, default_end, alter_info, VERS_ROW_END))
+ if (create_sys_field(thd, default_start, alter_info, VERS_ROW_START) ||
+ create_sys_field(thd, default_end, alter_info, VERS_ROW_END))
{
return true;
}
@@ -7379,14 +7381,25 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info)
}
+void Table_scope_and_contents_source_st::vers_check_native()
+{
+ vers_info.can_native= (db_type->db_type == DB_TYPE_PARTITION_DB ||
+ ha_check_storage_engine_flag(db_type,
+ HTON_NATIVE_SYS_VERSIONING));
+}
+
+
bool Table_scope_and_contents_source_st::vers_fix_system_fields(
THD *thd, Alter_info *alter_info, const TABLE_LIST &create_table)
{
DBUG_ASSERT(!(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING));
- DBUG_EXECUTE_IF("sysvers_force", if (!tmp_table()) {
- alter_info->flags|= ALTER_ADD_SYSTEM_VERSIONING;
- options|= HA_VERSIONED_TABLE; });
+ if (DBUG_EVALUATE_IF("sysvers_force", true, false) ||
+ DBUG_EVALUATE_IF("sysvers_force_trx", true, false))
+ {
+ alter_info->flags|= ALTER_ADD_SYSTEM_VERSIONING;
+ options|= HA_VERSIONED_TABLE;
+ }
if (!vers_info.need_check(alter_info))
return false;
@@ -7417,7 +7430,9 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
{
f->flags|= VERS_UPDATE_UNVERSIONED_FLAG;
}
- } // while (Create_field *f= it++)
+ } // while
+
+ vers_check_native();
if (vers_info.fix_implicit(thd, alter_info))
return true;
@@ -7470,11 +7485,7 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields(
if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING) && !versioned_fields)
return false;
- bool can_native= ha_check_storage_engine_flag(db_type,
- HTON_NATIVE_SYS_VERSIONING)
- || db_type->db_type == DB_TYPE_PARTITION_DB;
-
- return vers_info.check_sys_fields(table_name, db, alter_info, can_native);
+ return vers_info.check_sys_fields(table_name, db, alter_info);
}
@@ -7487,7 +7498,8 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
if (!need_check(alter_info) && !share->versioned)
return false;
- if (DBUG_EVALUATE_IF("sysvers_force", 0, share->tmp_table))
+ if (DBUG_EVALUATE_IF("sysvers_force", 0, share->tmp_table) ||
+ DBUG_EVALUATE_IF("sysvers_force_trx", 0, share->tmp_table))
{
my_error(ER_VERS_NOT_SUPPORTED, MYF(0), "CREATE TEMPORARY TABLE");
return true;
@@ -7732,8 +7744,7 @@ bool Create_field::vers_check_bigint(const Lex_table_name &table_name) const
bool Vers_parse_info::check_sys_fields(const Lex_table_name &table_name,
const Lex_table_name &db,
- Alter_info *alter_info,
- bool can_native) const
+ Alter_info *alter_info) const
{
if (check_conditions(table_name, db))
return true;