Commit e9e3cb0f authored by Aleksey Midenkov's avatar Aleksey Midenkov

SQL: VTMD for SHOW CREATE fixes [related to #125]

parent 79e17b26
......@@ -51,7 +51,7 @@ drop table tt_vtmd;
end~~
create table t (a int) with system versioning;
show create table t for system_time as of now;
ERROR 42S02: Table 'test.t_vtmd' doesn't exist
ERROR HY000: VTMD error: Table 'test.t_vtmd' doesn't exist
set versioning_alter_history=survive;
create or replace table t (a int) with system versioning;
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
......@@ -59,9 +59,9 @@ ERROR HY000: SYSTEM_TIME range selector is prohibited
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
ERROR HY000: SYSTEM_TIME range selector is prohibited
show create table t for system_time as of timestamp '01-01-1990';
ERROR HY000: VTMD error: failed to query VTMD table
ERROR HY000: VTMD error: Table 'test.t' doesn't exist
show create table t for system_time as of timestamp '01-01-2020';
ERROR HY000: VTMD error: failed to query VTMD table
ERROR HY000: VTMD error: Table 'test.t' doesn't exist
drop table t;
call drop_archives('t_vtmd');
drop table t_vtmd;
......
......@@ -65,7 +65,7 @@ end~~
delimiter ;~~
create table t (a int) with system versioning;
--error ER_NO_SUCH_TABLE
--error ER_VERS_VTMD_ERROR
show create table t for system_time as of now;
set versioning_alter_history=survive;
......
......@@ -1270,23 +1270,22 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
*/
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
TABLE_LIST tl;
bool versioned_query=
table_list->vers_conditions.type != FOR_SYSTEM_TIME_UNSPECIFIED;
String archive_name;
if (versioned_query)
TABLE_LIST archive;
bool versioned= table_list->vers_conditions;
if (versioned)
{
DBUG_ASSERT(table_list->vers_conditions.type == FOR_SYSTEM_TIME_AS_OF);
String archive_name;
DBUG_ASSERT(table_list->vers_conditions == FOR_SYSTEM_TIME_AS_OF);
VTMD_table vtmd(*table_list);
if (vtmd.find_archive_name(thd, archive_name))
goto exit;
tl.init_one_table(table_list->db, table_list->db_length, archive_name.ptr(),
archive.init_one_table(table_list->db, table_list->db_length, archive_name.ptr(),
archive_name.length(), archive_name.ptr(), TL_READ);
tl.alias= table_list->table_name;
tl.vers_force_alias= true;
table_list= &tl;
archive.alias= table_list->table_name;
archive.vers_force_alias= true;
table_list= &archive;
}
if (mysqld_show_create_get_fields(thd, table_list, &field_list, &buffer))
......@@ -1302,9 +1301,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
protocol->store(table_list->view_name.str, system_charset_info);
else
{
if (versioned_query)
protocol->store(tl.alias, system_charset_info);
else if (table_list->schema_table)
if (table_list->schema_table)
protocol->store(table_list->schema_table->table_name,
system_charset_info);
else
......@@ -1332,7 +1329,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
my_eof(thd);
exit:
if (versioned_query)
if (versioned)
{
/* If commit fails, we should be able to reset the OK status. */
thd->get_stmt_da()->set_overwrite_status(true);
......
This diff is collapsed.
......@@ -48,8 +48,10 @@ class THD;
class VTMD_table
{
Open_tables_backup open_tables_backup;
protected:
TABLE *vtmd;
TABLE_LIST vtmd;
const TABLE_LIST &about;
SString_t vtmd_name;
......@@ -72,13 +74,16 @@ class VTMD_table
};
VTMD_table(TABLE_LIST &_about) :
vtmd(NULL),
about(_about)
{}
{
vtmd.table= NULL;
}
bool create(THD *thd);
bool find_record(ulonglong sys_trx_end, bool &found);
bool open(THD *thd, Local_da &local_da, bool *created= NULL);
bool update(THD *thd, const char* archive_name= NULL);
bool setup_select(THD *thd);
static void archive_name(THD *thd, const char *table_name, char *new_name, size_t new_name_size);
void archive_name(THD *thd, char *new_name, size_t new_name_size)
......
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