Commit 8c9c3020 authored by Eugene Kosov's avatar Eugene Kosov Committed by Aleksey Midenkov

SQL: fix implicit sys fields for implicit engine of partitioned table [#366]

parent 03b54a6b
...@@ -287,4 +287,10 @@ x ...@@ -287,4 +287,10 @@ x
select * from t1 partition (p1sp1) for system_time all; select * from t1 partition (p1sp1) for system_time all;
x x
2 2
create or replace table t1 (a bigint)
with system versioning
partition by range (a)
(partition p0 values less than (20) engine innodb,
partition p1 values less than maxvalue engine innodb);
insert into t1 values (1);
drop table t1; drop table t1;
...@@ -229,6 +229,13 @@ select * from t1 partition (p0sp1) for system_time all; ...@@ -229,6 +229,13 @@ select * from t1 partition (p0sp1) for system_time all;
select * from t1 partition (p1sp0) for system_time all; select * from t1 partition (p1sp0) for system_time all;
select * from t1 partition (p1sp1) for system_time all; select * from t1 partition (p1sp1) for system_time all;
create or replace table t1 (a bigint)
with system versioning
partition by range (a)
(partition p0 values less than (20) engine innodb,
partition p1 values less than maxvalue engine innodb);
insert into t1 values (1);
drop table t1; drop table t1;
-- source suite/versioning/common_finish.inc -- source suite/versioning/common_finish.inc
...@@ -6872,7 +6872,25 @@ bool Vers_parse_info::check_and_fix_implicit( ...@@ -6872,7 +6872,25 @@ bool Vers_parse_info::check_and_fix_implicit(
} }
} }
bool integer_fields= create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING; bool integer_fields= ha_check_storage_engine_flag(create_info->db_type,
HTON_NATIVE_SYS_VERSIONING);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (partition_info *info= thd->work_part_info)
{
if (!(create_info->used_fields & HA_CREATE_USED_ENGINE) &&
info->partitions.elements)
{
partition_element *element=
static_cast<partition_element *>(info->partitions.elem(0));
handlerton *hton= element->engine_type;
if (hton && ha_check_storage_engine_flag(hton, HTON_NATIVE_SYS_VERSIONING))
{
integer_fields= true;
}
}
}
#endif
if (fix_implicit(thd, alter_info, integer_fields)) if (fix_implicit(thd, alter_info, integer_fields))
return true; return true;
...@@ -6947,8 +6965,8 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info, ...@@ -6947,8 +6965,8 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
TABLE *table) TABLE *table)
{ {
TABLE_SHARE *share= table->s; TABLE_SHARE *share= table->s;
bool integer_fields= bool integer_fields= ha_check_storage_engine_flag(create_info->db_type,
create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING; HTON_NATIVE_SYS_VERSIONING);
const char *table_name= share->table_name.str; const char *table_name= share->table_name.str;
if (!need_check() && !share->versioned) if (!need_check() && !share->versioned)
......
...@@ -8854,13 +8854,17 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name, ...@@ -8854,13 +8854,17 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
if (versioned) if (versioned)
{ {
if (create_info->db_type && if (handlerton *hton1= create_info->db_type)
table->s->db_type() != create_info->db_type && (
table->file->native_versioned() ||
create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING))
{ {
my_error(ER_VERS_ALTER_ENGINE_PROHIBITED, MYF(0), table_list->db, table_list->table_name); handlerton *hton2= table->file->ht;
DBUG_RETURN(true); if (hton1 != hton2 &&
(ha_check_storage_engine_flag(hton1, HTON_NATIVE_SYS_VERSIONING) ||
ha_check_storage_engine_flag(hton2, HTON_NATIVE_SYS_VERSIONING)))
{
my_error(ER_VERS_ALTER_ENGINE_PROHIBITED, MYF(0), table_list->db,
table_list->table_name);
DBUG_RETURN(true);
}
} }
bool vers_data_mod= alter_info->data_modifying(); bool vers_data_mod= alter_info->data_modifying();
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE) if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
......
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