mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Daemon: debug_system_versioning_show, debug_system_versioning_force
This commit is contained in:
parent
c777add74f
commit
34abee2c21
12 changed files with 111 additions and 49 deletions
|
@ -1227,9 +1227,6 @@ The following options may be given as the first argument:
|
|||
Versioning ALTER TABLE mode. ERROR: Fail ALTER with
|
||||
error; KEEP: Keep historical system rows and subject them
|
||||
to ALTER;
|
||||
--system-versioning-force
|
||||
Force system versioning for all created tables
|
||||
--system-versioning-hide=name
|
||||
--system-versioning-innodb-algorithm-simple
|
||||
Use simple algorithm of timestamp handling in InnoDB
|
||||
instead of TRX_SEES
|
||||
|
@ -1667,7 +1664,6 @@ sync-relay-log 10000
|
|||
sync-relay-log-info 10000
|
||||
sysdate-is-now FALSE
|
||||
system-versioning-alter-history ERROR
|
||||
system-versioning-force FALSE
|
||||
system-versioning-innodb-algorithm-simple TRUE
|
||||
system-versioning-transaction-registry FALSE
|
||||
table-cache 431
|
||||
|
|
|
@ -4099,20 +4099,6 @@ NUMERIC_BLOCK_SIZE NULL
|
|||
ENUM_VALUE_LIST DEFAULT
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT NULL
|
||||
VARIABLE_NAME SYSTEM_VERSIONING_FORCE
|
||||
SESSION_VALUE OFF
|
||||
GLOBAL_VALUE OFF
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE OFF
|
||||
VARIABLE_SCOPE SESSION
|
||||
VARIABLE_TYPE BOOLEAN
|
||||
VARIABLE_COMMENT Force system versioning for all created tables
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST OFF,ON
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME SYSTEM_VERSIONING_INNODB_ALGORITHM_SIMPLE
|
||||
SESSION_VALUE ON
|
||||
GLOBAL_VALUE ON
|
||||
|
|
|
@ -5051,20 +5051,6 @@ NUMERIC_BLOCK_SIZE NULL
|
|||
ENUM_VALUE_LIST DEFAULT
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT NULL
|
||||
VARIABLE_NAME SYSTEM_VERSIONING_FORCE
|
||||
SESSION_VALUE OFF
|
||||
GLOBAL_VALUE OFF
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE OFF
|
||||
VARIABLE_SCOPE SESSION
|
||||
VARIABLE_TYPE BOOLEAN
|
||||
VARIABLE_COMMENT Force system versioning for all created tables
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST OFF,ON
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME SYSTEM_VERSIONING_INNODB_ALGORITHM_SIMPLE
|
||||
SESSION_VALUE ON
|
||||
GLOBAL_VALUE ON
|
||||
|
|
|
@ -1472,6 +1472,10 @@ public:
|
|||
return flags & VERS_UPDATE_UNVERSIONED_FLAG;
|
||||
}
|
||||
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
bool vers_sys_invisible(THD *thd) const;
|
||||
#endif
|
||||
|
||||
virtual bool vers_trx_id() const
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -6962,13 +6962,13 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
|
|||
}
|
||||
}
|
||||
|
||||
// CREATE ... SELECT: if at least one table in SELECT is versioned,
|
||||
// then created table will be versioned.
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
if (thd->variables.vers_force)
|
||||
{
|
||||
alter_info->flags|= Alter_info::ALTER_ADD_SYSTEM_VERSIONING;
|
||||
options|= HA_VERSIONED_TABLE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Possibly override default storage engine to match one used in source table.
|
||||
if (vers_tables && alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING &&
|
||||
|
@ -7177,7 +7177,11 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
|
|||
if (!need_check(alter_info) && !share->versioned)
|
||||
return false;
|
||||
|
||||
if (!thd->variables.vers_force && share->tmp_table && share->tmp_table != INTERNAL_TMP_TABLE)
|
||||
if (share->tmp_table && share->tmp_table != INTERNAL_TMP_TABLE
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
&& !thd->variables.vers_force
|
||||
#endif
|
||||
)
|
||||
{
|
||||
my_error(ER_VERS_TEMPORARY, MYF(0));
|
||||
return true;
|
||||
|
|
|
@ -9901,8 +9901,10 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
|
|||
if (thread_cache_size > max_connections)
|
||||
SYSVAR_AUTOSIZE(thread_cache_size, max_connections);
|
||||
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
if (opt_bootstrap)
|
||||
global_system_variables.vers_force= 0;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
15
sql/mysqld.h
15
sql/mysqld.h
|
@ -184,11 +184,11 @@ extern const char *log_backup_output_str;
|
|||
enum vers_system_time_t
|
||||
{
|
||||
SYSTEM_TIME_UNSPECIFIED = 0,
|
||||
SYSTEM_TIME_ALL,
|
||||
SYSTEM_TIME_AS_OF,
|
||||
SYSTEM_TIME_FROM_TO,
|
||||
SYSTEM_TIME_BETWEEN,
|
||||
SYSTEM_TIME_BEFORE
|
||||
SYSTEM_TIME_BEFORE,
|
||||
SYSTEM_TIME_ALL
|
||||
};
|
||||
|
||||
struct vers_asof_timestamp_t
|
||||
|
@ -200,13 +200,14 @@ struct vers_asof_timestamp_t
|
|||
{}
|
||||
};
|
||||
|
||||
enum vers_hide_enum
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
enum vers_show_enum
|
||||
{
|
||||
VERS_HIDE_AUTO= 0,
|
||||
VERS_HIDE_IMPLICIT,
|
||||
VERS_HIDE_FULL,
|
||||
VERS_HIDE_NEVER
|
||||
VERS_SHOW_OFF= 0,
|
||||
VERS_SHOW_RANGE,
|
||||
VERS_SHOW_ALWAYS
|
||||
};
|
||||
#endif
|
||||
|
||||
enum vers_alter_history_enum
|
||||
{
|
||||
|
|
|
@ -7492,6 +7492,35 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
|
|||
}
|
||||
|
||||
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
inline
|
||||
bool Field::vers_sys_invisible(THD *thd) const
|
||||
{
|
||||
DBUG_ASSERT(vers_sys_field());
|
||||
DBUG_ASSERT(table);
|
||||
DBUG_ASSERT(table->versioned());
|
||||
DBUG_ASSERT(table->pos_in_table_list);
|
||||
|
||||
if (thd->lex->sql_command != SQLCOM_SELECT)
|
||||
return invisible;
|
||||
|
||||
switch (thd->variables.vers_show)
|
||||
{
|
||||
case VERS_SHOW_RANGE:
|
||||
{
|
||||
vers_system_time_t vers_type= table->pos_in_table_list->vers_conditions.type;
|
||||
return vers_type > SYSTEM_TIME_AS_OF ? false : invisible;
|
||||
}
|
||||
case VERS_SHOW_ALWAYS:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
return invisible;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Drops in all fields instead of current '*' field
|
||||
|
||||
|
@ -7621,8 +7650,14 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
|||
Field_iterator_natural_join).
|
||||
But view fields can never be invisible.
|
||||
*/
|
||||
if ((field= field_iterator.field()) && field->invisible != VISIBLE)
|
||||
if ((field= field_iterator.field()) && (
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
field->vers_sys_field() && field->table->versioned() ?
|
||||
field->vers_sys_invisible(thd) :
|
||||
#endif
|
||||
field->invisible != VISIBLE))
|
||||
continue;
|
||||
|
||||
Item *item;
|
||||
|
||||
if (!(item= field_iterator.create_item(thd)))
|
||||
|
|
|
@ -707,7 +707,10 @@ typedef struct system_variables
|
|||
ulong in_subquery_conversion_threshold;
|
||||
|
||||
vers_asof_timestamp_t vers_asof_timestamp;
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
my_bool vers_force;
|
||||
ulong vers_show;
|
||||
#endif
|
||||
my_bool vers_innodb_algorithm_simple;
|
||||
ulong vers_alter_history;
|
||||
} SV;
|
||||
|
|
|
@ -2108,6 +2108,10 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
TABLE *table= table_list->table;
|
||||
TABLE_SHARE *share= table->s;
|
||||
sql_mode_t sql_mode= thd->variables.sql_mode;
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
ulong vers_show= thd->variables.vers_show;
|
||||
#endif
|
||||
bool explicit_fields= false;
|
||||
bool foreign_db_mode= sql_mode & (MODE_POSTGRESQL | MODE_ORACLE |
|
||||
MODE_MSSQL | MODE_DB2 |
|
||||
MODE_MAXDB | MODE_ANSI);
|
||||
|
@ -2188,7 +2192,11 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
|
||||
uint flags = field->flags;
|
||||
|
||||
if (field->invisible > INVISIBLE_USER)
|
||||
if (field->invisible > INVISIBLE_USER
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
&& !(field->vers_sys_field() && vers_show == VERS_SHOW_ALWAYS)
|
||||
#endif
|
||||
)
|
||||
continue;
|
||||
if (not_the_first_field)
|
||||
packet->append(STRING_WITH_LEN(",\n"));
|
||||
|
@ -2336,7 +2344,11 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
for (uint j=0 ; j < key_info->user_defined_key_parts ; j++,key_part++)
|
||||
{
|
||||
Field *field= key_part->field;
|
||||
if (field->invisible > INVISIBLE_USER)
|
||||
if (field->invisible > INVISIBLE_USER
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
&& !(field->vers_sys_field() && vers_show == VERS_SHOW_ALWAYS)
|
||||
#endif
|
||||
)
|
||||
continue;
|
||||
|
||||
if (j)
|
||||
|
@ -2373,9 +2385,14 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
const Field *fe = table->vers_end_field();
|
||||
DBUG_ASSERT(fs);
|
||||
DBUG_ASSERT(fe);
|
||||
if (fs->invisible < INVISIBLE_SYSTEM)
|
||||
explicit_fields= fs->invisible < INVISIBLE_SYSTEM;
|
||||
DBUG_ASSERT(!explicit_fields || fe->invisible < INVISIBLE_SYSTEM);
|
||||
if (explicit_fields
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
|| vers_show == VERS_SHOW_ALWAYS
|
||||
#endif
|
||||
)
|
||||
{
|
||||
DBUG_ASSERT(fe->invisible < INVISIBLE_SYSTEM);
|
||||
packet->append(STRING_WITH_LEN(",\n PERIOD FOR SYSTEM_TIME ("));
|
||||
append_identifier(thd,packet,fs->field_name.str, fs->field_name.length);
|
||||
packet->append(STRING_WITH_LEN(", "));
|
||||
|
@ -2427,7 +2444,11 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
add_table_options(thd, table, create_info_arg,
|
||||
table_list->schema_table != 0, 0, packet);
|
||||
|
||||
if (table->versioned())
|
||||
if (table->versioned()
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
&& (!thd->variables.vers_force || explicit_fields)
|
||||
#endif
|
||||
)
|
||||
packet->append(STRING_WITH_LEN(" WITH SYSTEM VERSIONING"));
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
|
@ -5016,6 +5037,11 @@ public:
|
|||
static bool get_all_archive_tables(THD *thd,
|
||||
Dynamic_array<String> &all_archive_tables)
|
||||
{
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
if (thd->variables.vers_show == VERS_SHOW_ALWAYS)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (thd->variables.vers_alter_history != VERS_ALTER_HISTORY_SURVIVE)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -6233,7 +6233,9 @@ versioning_option:
|
|||
{
|
||||
if (Lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)
|
||||
{
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
if (!thd->variables.vers_force)
|
||||
#endif
|
||||
{
|
||||
my_error(ER_VERS_TEMPORARY, MYF(0));
|
||||
MYSQL_YYABORT;
|
||||
|
@ -16167,6 +16169,12 @@ set_expr_or_default:
|
|||
if ($$ == NULL)
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| RANGE_SYM
|
||||
{
|
||||
$$=new (thd->mem_root) Item_string_sys(thd, C_STRING_WITH_LEN("RANGE"));
|
||||
if ($$ == NULL)
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
;
|
||||
|
||||
/* Lock function */
|
||||
|
|
|
@ -396,10 +396,21 @@ static Sys_var_vers_asof Sys_vers_asof_timestamp(
|
|||
SESSION_VAR(vers_asof_timestamp.type), NO_CMD_LINE,
|
||||
Sys_var_vers_asof::asof_keywords, DEFAULT(SYSTEM_TIME_UNSPECIFIED));
|
||||
|
||||
#ifdef VERS_EXPERIMENTAL
|
||||
static Sys_var_mybool Sys_vers_force(
|
||||
"system_versioning_force", "Force system versioning for all created tables",
|
||||
"debug_system_versioning_force", "Force system versioning for all created tables",
|
||||
SESSION_VAR(vers_force), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
||||
|
||||
static const char *vers_show_keywords[]= {"OFF", "RANGE", "ALWAYS", NULL};
|
||||
static Sys_var_enum Sys_vers_show(
|
||||
"debug_system_versioning_show", "Show system fields special rules. "
|
||||
"OFF: don't use special show rules; "
|
||||
"RANGE: show implicit system fields only in range versioned queries; "
|
||||
"ALWAYS: show system fields in all queries",
|
||||
SESSION_VAR(vers_show), CMD_LINE(REQUIRED_ARG),
|
||||
vers_show_keywords, DEFAULT(VERS_SHOW_OFF));
|
||||
#endif
|
||||
|
||||
static Sys_var_mybool Sys_vers_innodb_algorithm_simple(
|
||||
"system_versioning_innodb_algorithm_simple",
|
||||
"Use simple algorithm of timestamp handling in InnoDB instead of TRX_SEES",
|
||||
|
|
Loading…
Add table
Reference in a new issue