Commit c66a20b4 authored by Eugene Kosov's avatar Eugene Kosov Committed by Aleksey Midenkov

SQL: better check for partition engine [#366]

Cleaned up by @midenok.
parent 74cc9ec1
...@@ -293,4 +293,13 @@ partition by range (a) ...@@ -293,4 +293,13 @@ partition by range (a)
(partition p0 values less than (20) engine innodb, (partition p0 values less than (20) engine innodb,
partition p1 values less than maxvalue engine innodb); partition p1 values less than maxvalue engine innodb);
insert into t1 values (1); insert into t1 values (1);
create or replace table t1 (
f_int1 integer default 0
) with system versioning
partition by range(f_int1)
subpartition by hash(f_int1)
( partition part1 values less than (1000)
(subpartition subpart11 storage engine = 'innodb',
subpartition subpart12 storage engine = 'innodb'));
insert into t1 values (1);
drop table t1; drop table t1;
...@@ -236,6 +236,17 @@ partition by range (a) ...@@ -236,6 +236,17 @@ partition by range (a)
partition p1 values less than maxvalue engine innodb); partition p1 values less than maxvalue engine innodb);
insert into t1 values (1); insert into t1 values (1);
create or replace table t1 (
f_int1 integer default 0
) with system versioning
partition by range(f_int1)
subpartition by hash(f_int1)
( partition part1 values less than (1000)
(subpartition subpart11 storage engine = 'innodb',
subpartition subpart12 storage 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
...@@ -6845,25 +6845,25 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info, ...@@ -6845,25 +6845,25 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info,
bool Table_scope_and_contents_source_st::vers_native(THD *thd) const bool Table_scope_and_contents_source_st::vers_native(THD *thd) const
{ {
bool integer_fields= ha_check_storage_engine_flag(db_type, if (ha_check_storage_engine_flag(db_type, HTON_NATIVE_SYS_VERSIONING))
HTON_NATIVE_SYS_VERSIONING); return true;
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
if (partition_info *info= thd->work_part_info) partition_info *info= thd->work_part_info;
if (info && !(used_fields & HA_CREATE_USED_ENGINE))
{ {
if (!(used_fields & HA_CREATE_USED_ENGINE) && info->partitions.elements) if (handlerton *hton= info->default_engine_type)
return ha_check_storage_engine_flag(hton, HTON_NATIVE_SYS_VERSIONING);
List_iterator_fast<partition_element> it(info->partitions);
while (partition_element *partition_element= it++)
{ {
partition_element *element= if (partition_element->find_engine_flag(HTON_NATIVE_SYS_VERSIONING))
static_cast<partition_element *>(info->partitions.elem(0)); return true;
handlerton *hton= element->engine_type;
if (hton && ha_check_storage_engine_flag(hton, HTON_NATIVE_SYS_VERSIONING))
{
integer_fields= true;
}
} }
} }
#endif #endif
return integer_fields; return false;
} }
bool Table_scope_and_contents_source_st::vers_fix_system_fields( bool Table_scope_and_contents_source_st::vers_fix_system_fields(
......
...@@ -231,6 +231,21 @@ class partition_element :public Sql_alloc ...@@ -231,6 +231,21 @@ class partition_element :public Sql_alloc
DBUG_ASSERT(ev->col_val_array); DBUG_ASSERT(ev->col_val_array);
return ev->col_val_array[idx]; return ev->col_val_array[idx];
} }
bool find_engine_flag(uint32 flag)
{
if (ha_check_storage_engine_flag(engine_type, flag))
return true;
List_iterator_fast<partition_element> it(subpartitions);
while (partition_element *element= it++)
{
if (element->find_engine_flag(flag))
return true;
}
return false;
}
}; };
#endif /* PARTITION_ELEMENT_INCLUDED */ #endif /* PARTITION_ELEMENT_INCLUDED */
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