mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
SQL: create_like_table strip versioning for tmp tables [#365 bug 6]
Tests affected (forced versioning): rpl.rpl_row_merge_engine
This commit is contained in:
@ -281,6 +281,15 @@ tt1 CREATE TABLE `tt1` (
|
|||||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||||
drop table tt1;
|
drop table tt1;
|
||||||
|
create temporary table tt1 like t1;
|
||||||
|
Warnings:
|
||||||
|
Warning 1105 System versioning is stripped from temporary `test.tt1`
|
||||||
|
# Temporary is stripped from versioning
|
||||||
|
show create table tt1;
|
||||||
|
Table Create Table
|
||||||
|
tt1 CREATE TEMPORARY TABLE `tt1` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1
|
||||||
create or replace table t1 (x int) with system versioning;
|
create or replace table t1 (x int) with system versioning;
|
||||||
create or replace table t0(
|
create or replace table t0(
|
||||||
y int,
|
y int,
|
||||||
|
@ -198,6 +198,10 @@ create table tt1 like t1;
|
|||||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||||
show create table tt1;
|
show create table tt1;
|
||||||
drop table tt1;
|
drop table tt1;
|
||||||
|
create temporary table tt1 like t1;
|
||||||
|
--echo # Temporary is stripped from versioning
|
||||||
|
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM
|
||||||
|
show create table tt1;
|
||||||
|
|
||||||
# CREATE TABLE ... SELECT
|
# CREATE TABLE ... SELECT
|
||||||
create or replace table t1 (x int) with system versioning;
|
create or replace table t1 (x int) with system versioning;
|
||||||
|
@ -7138,13 +7138,34 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
|
|||||||
check_generated_type(table_name, alter_info, integer_fields)));
|
check_generated_type(table_name, alter_info, integer_fields)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vers_parse_info::fix_create_like(THD *thd, Alter_info *alter_info,
|
bool
|
||||||
HA_CREATE_INFO *create_info, TABLE_LIST *table)
|
Vers_parse_info::fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_info,
|
||||||
|
TABLE_LIST &src_table, TABLE_LIST &table)
|
||||||
{
|
{
|
||||||
List_iterator<Create_field> it(alter_info->create_list);
|
List_iterator<Create_field> it(alter_info.create_list);
|
||||||
Create_field *f, *f_start=NULL, *f_end= NULL;
|
Create_field *f, *f_start=NULL, *f_end= NULL;
|
||||||
|
|
||||||
DBUG_ASSERT(alter_info->create_list.elements > 2);
|
DBUG_ASSERT(alter_info.create_list.elements > 2);
|
||||||
|
|
||||||
|
if (create_info.tmp_table())
|
||||||
|
{
|
||||||
|
int remove= 2;
|
||||||
|
while (remove && (f= it++))
|
||||||
|
{
|
||||||
|
if (f->flags & (VERS_SYS_START_FLAG|VERS_SYS_END_FLAG))
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
remove--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBUG_ASSERT(remove == 0);
|
||||||
|
push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
|
||||||
|
ER_UNKNOWN_ERROR,
|
||||||
|
"System versioning is stripped from temporary `%s.%s`",
|
||||||
|
table.db, table.table_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
while ((f= it++))
|
while ((f= it++))
|
||||||
{
|
{
|
||||||
if (f->flags & VERS_SYS_START_FLAG)
|
if (f->flags & VERS_SYS_START_FLAG)
|
||||||
@ -7163,7 +7184,7 @@ bool Vers_parse_info::fix_create_like(THD *thd, Alter_info *alter_info,
|
|||||||
|
|
||||||
if (!f_start || !f_end)
|
if (!f_start || !f_end)
|
||||||
{
|
{
|
||||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISSING, MYF(0), table->table_name,
|
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISSING, MYF(0), src_table.table_name,
|
||||||
f_start ? "AS ROW END" : "AS ROW START");
|
f_start ? "AS ROW END" : "AS ROW START");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -7171,7 +7192,7 @@ bool Vers_parse_info::fix_create_like(THD *thd, Alter_info *alter_info,
|
|||||||
as_row= start_end_t(f_start->field_name, f_end->field_name);
|
as_row= start_end_t(f_start->field_name, f_end->field_name);
|
||||||
system_time= as_row;
|
system_time= as_row;
|
||||||
|
|
||||||
create_info->options|= HA_VERSIONED_TABLE;
|
create_info.options|= HA_VERSIONED_TABLE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1747,8 +1747,8 @@ public:
|
|||||||
const char *table_name);
|
const char *table_name);
|
||||||
bool check_and_fix_alter(THD *thd, Alter_info *alter_info,
|
bool check_and_fix_alter(THD *thd, Alter_info *alter_info,
|
||||||
HA_CREATE_INFO *create_info, TABLE *table);
|
HA_CREATE_INFO *create_info, TABLE *table);
|
||||||
bool fix_create_like(THD *thd, Alter_info *alter_info,
|
bool fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_info,
|
||||||
HA_CREATE_INFO *create_info, TABLE_LIST *table);
|
TABLE_LIST &src_table, TABLE_LIST &table);
|
||||||
|
|
||||||
/** User has added 'WITH SYSTEM VERSIONING' to table definition */
|
/** User has added 'WITH SYSTEM VERSIONING' to table definition */
|
||||||
bool with_system_versioning : 1;
|
bool with_system_versioning : 1;
|
||||||
|
@ -5502,13 +5502,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
|||||||
thd->work_part_info= src_table->table->part_info->get_clone(thd);
|
thd->work_part_info= src_table->table->part_info->get_clone(thd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (src_table->table->versioned() &&
|
|
||||||
local_create_info.vers_info.fix_create_like(thd, &local_alter_info,
|
|
||||||
&local_create_info, src_table))
|
|
||||||
{
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Adjust description of source table before using it for creation of
|
Adjust description of source table before using it for creation of
|
||||||
target table.
|
target table.
|
||||||
@ -5520,7 +5513,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
|||||||
local_create_info.max_rows= 0;
|
local_create_info.max_rows= 0;
|
||||||
/* Replace type of source table with one specified in the statement. */
|
/* Replace type of source table with one specified in the statement. */
|
||||||
local_create_info.options&= ~HA_LEX_CREATE_TMP_TABLE;
|
local_create_info.options&= ~HA_LEX_CREATE_TMP_TABLE;
|
||||||
local_create_info.options|= create_info->tmp_table();
|
|
||||||
local_create_info.options|= create_info->options;
|
local_create_info.options|= create_info->options;
|
||||||
/* Reset auto-increment counter for the new table. */
|
/* Reset auto-increment counter for the new table. */
|
||||||
local_create_info.auto_increment_value= 0;
|
local_create_info.auto_increment_value= 0;
|
||||||
@ -5530,6 +5522,13 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
|||||||
*/
|
*/
|
||||||
local_create_info.data_file_name= local_create_info.index_file_name= NULL;
|
local_create_info.data_file_name= local_create_info.index_file_name= NULL;
|
||||||
|
|
||||||
|
if (src_table->table->versioned() &&
|
||||||
|
local_create_info.vers_info.fix_create_like(local_alter_info, local_create_info,
|
||||||
|
*src_table, *table))
|
||||||
|
{
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* The following is needed only in case of lock tables */
|
/* The following is needed only in case of lock tables */
|
||||||
if ((local_create_info.table= thd->lex->query_tables->table))
|
if ((local_create_info.table= thd->lex->query_tables->table))
|
||||||
pos_in_locked_tables= local_create_info.table->pos_in_locked_tables;
|
pos_in_locked_tables= local_create_info.table->pos_in_locked_tables;
|
||||||
|
Reference in New Issue
Block a user