Skip to content

Commit

Permalink
SQL: better check for partition engine [#366]
Browse files Browse the repository at this point in the history
Cleaned up by @midenok.
  • Loading branch information
kevgs authored and midenok committed Dec 12, 2017
1 parent 74cc9ec commit c66a20b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
9 changes: 9 additions & 0 deletions mysql-test/suite/versioning/r/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,13 @@ 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);
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;
11 changes: 11 additions & 0 deletions mysql-test/suite/versioning/t/partition.test
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ partition by range (a)
partition p1 values less than maxvalue engine innodb);
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;

-- source suite/versioning/common_finish.inc
24 changes: 12 additions & 12 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 integer_fields= ha_check_storage_engine_flag(db_type,
HTON_NATIVE_SYS_VERSIONING);
if (ha_check_storage_engine_flag(db_type, HTON_NATIVE_SYS_VERSIONING))
return true;

#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=
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;
}
if (partition_element->find_engine_flag(HTON_NATIVE_SYS_VERSIONING))
return true;
}
}
#endif
return integer_fields;
return false;
}

bool Table_scope_and_contents_source_st::vers_fix_system_fields(
Expand Down
15 changes: 15 additions & 0 deletions sql/partition_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,21 @@ class partition_element :public Sql_alloc
DBUG_ASSERT(ev->col_val_array);
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 */

0 comments on commit c66a20b

Please sign in to comment.