diff options
author | Eugene Kosov <claprix@yandex.ru> | 2017-12-12 22:01:39 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2017-12-12 22:01:39 +0300 |
commit | c66a20b494a391626c21907b42d515db66963787 (patch) | |
tree | f54eae22a72144464b7651871b289c9ddeeac9ad /sql | |
parent | 74cc9ec14257275a0cd22a8f1d53353c6d039da1 (diff) | |
download | mariadb-git-c66a20b494a391626c21907b42d515db66963787.tar.gz |
SQL: better check for partition engine [#366]
Cleaned up by @midenok.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 24 | ||||
-rw-r--r-- | sql/partition_element.h | 15 |
2 files changed, 27 insertions, 12 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 3cdabe9c1a9..eee9c1bb897 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -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( diff --git a/sql/partition_element.h b/sql/partition_element.h index da08a15b2ce..9785789d3eb 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -231,6 +231,21 @@ public: 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 */ |