Commit 1d056f5a authored by Aleksey Midenkov's avatar Aleksey Midenkov

SQL: not a VTMD table warning [related to #199]

parent 9062385c
......@@ -281,7 +281,7 @@ A_start B_end name C_archive_name
1 0 t3 t3_
1 0 t3 t3_
1 1 t3 NULL
set versioning_hide = auto;
set versioning_hide= auto;
call show_tables();
Tables_in_test
t2
......@@ -293,7 +293,7 @@ t2 test
t2_vtmd test
t3 test
t3_vtmd test
set versioning_hide = implicit;
set versioning_hide= implicit;
call show_tables();
Tables_in_test
t2
......@@ -305,7 +305,7 @@ t2 test
t2_vtmd test
t3 test
t3_vtmd test
set versioning_hide = full;
set versioning_hide= full;
call show_tables();
Tables_in_test
t2
......@@ -317,7 +317,7 @@ t2 test
t2_vtmd test
t3 test
t3_vtmd test
set versioning_hide = never;
set versioning_hide= never;
call show_tables();
Tables_in_test
t0_TIMESTAMP_SUFFIX
......@@ -342,6 +342,18 @@ t3 test
t3_TIMESTAMP_SUFFIX test
t3_TIMESTAMP_SUFFIX test
t3_vtmd test
set versioning_hide= auto;
create or replace table u0_vtmd (x int) with system versioning;
show tables;
Tables_in_test
t2
t2_vtmd
t3
t3_vtmd
u0_vtmd
u0_vtmd_vtmd
Warnings:
Warning 4088 Table `test.u0_vtmd` is not a VTMD table
drop database db0;
drop database db1;
drop database test;
......
......@@ -174,19 +174,25 @@ alter table t3 change x x bigint;
alter table t3 change x x bigint after sys_trx_start;
call check_vtmd('t3_vtmd');
set versioning_hide = auto;
# hide archive tables
set versioning_hide= auto;
call show_tables();
set versioning_hide = implicit;
set versioning_hide= implicit;
call show_tables();
set versioning_hide = full;
set versioning_hide= full;
call show_tables();
set versioning_hide = never;
set versioning_hide= never;
--replace_regex /\d{8}_\d{6}_\d{6}/TIMESTAMP_SUFFIX/
call show_tables();
# wrong VTMD handling
set versioning_hide= auto;
create or replace table u0_vtmd (x int) with system versioning;
show tables;
drop database db0;
drop database db1;
drop database test;
......
......@@ -7588,3 +7588,6 @@ ER_VERS_ALTER_SYSTEM_FIELD
ER_VERS_SYS_FIELD_NOT_HIDDEN
eng "System versioning field '%s' is not hidden"
ER_NOT_LOG_TABLE
eng "Table `%s.%s` is not a log table"
......@@ -8723,11 +8723,32 @@ open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup)
if ((table= open_ltable(thd, one_table, one_table->lock_type, flags)))
{
DBUG_ASSERT(table->s->table_category == TABLE_CATEGORY_LOG);
if (table->s->table_category == TABLE_CATEGORY_LOG)
{
/* Make sure all columns get assigned to a default value */
table->use_all_columns();
DBUG_ASSERT(table->no_replicate);
}
else
{
my_error(ER_NOT_LOG_TABLE, MYF(0), table->s->db.str, table->s->table_name.str);
int error= 0;
if (table->current_lock != F_UNLCK)
{
table->current_lock= F_UNLCK;
error= table->file->ha_external_lock(thd, F_UNLCK);
}
if (error)
table->file->print_error(error, MYF(0));
else
{
tc_release_table(table);
thd->reset_open_tables_state(thd);
thd->restore_backup_open_tables_state(backup);
table= NULL;
}
}
}
else
thd->restore_backup_open_tables_state(backup);
......
......@@ -1530,6 +1530,12 @@ struct TABLE
return s->versioned && file->native_versioned();
}
bool vers_vtmd() const
{
DBUG_ASSERT(s);
return s->versioned && s->vtmd;
}
Field *vers_start_field() const
{
DBUG_ASSERT(s && s->versioned);
......
......@@ -593,6 +593,7 @@ VTMD_table::get_archive_tables(THD *thd, const char *db, size_t db_length,
if (get_vtmd_tables(thd, db, db_length, vtmd_tables))
return true;
Local_da local_da(thd, ER_VERS_VTMD_ERROR);
for (uint i= 0; i < vtmd_tables.elements(); i++)
{
LEX_STRING table_name= *vtmd_tables.at(i);
......@@ -603,8 +604,24 @@ VTMD_table::get_archive_tables(THD *thd, const char *db, size_t db_length,
table_name.str, TL_READ);
TABLE *table= open_log_table(thd, &table_list, &open_tables_backup);
if (!table)
if (!table || !table->vers_vtmd())
{
if (table)
close_log_table(thd, &open_tables_backup);
else
{
if (local_da.is_error() && local_da.sql_errno() == ER_NOT_LOG_TABLE)
local_da.reset_diagnostics_area();
else
return true;
}
push_warning_printf(
thd, Sql_condition::WARN_LEVEL_WARN,
ER_VERS_VTMD_ERROR,
"Table `%s.%s` is not a VTMD table",
db, table_name.str);
continue;
}
READ_RECORD read_record;
int error= 0;
......
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