diff --git a/storage/tianchi/ha_tse.cc b/storage/tianchi/ha_tse.cc index 59a76113c251591e42afcc7d1099c316465f94e1..cfa9d906cad9431f9c7764b67f29550e910d3d69 100644 --- a/storage/tianchi/ha_tse.cc +++ b/storage/tianchi/ha_tse.cc @@ -106,6 +106,9 @@ #include "sql/dd/upgrade/server.h" // UPGRADE_FORCE #include "sql/abstract_query_plan.h" +#include "sql/dd/properties.h" +#include "sql/dd/types/partition.h" + #include "tse_stats.h" #include "tse_error.h" #include "tse_log.h" @@ -117,6 +120,7 @@ #include "sql/mysqld.h" #include "sql/plugin_table.h" #include "sql/dd/object_id.h" +#include "sql/dd/string_type.h" #include "sql/dd/cache/dictionary_client.h" #include "sql/dd/dd_schema.h" #include "sql/sql_table.h" @@ -775,7 +779,10 @@ bool ha_tse::check_unsupported_operation(THD *thd, HA_CREATE_INFO *create_info) my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); return HA_ERR_UNSUPPORTED; } - + if (create_info != nullptr && create_info->index_file_name) { + my_error(ER_ILLEGAL_HA, MYF(0), table_share->table_name.str, HA_WRONG_CREATE_OPTION); + return true; + } return false; } diff --git a/storage/tianchi/ha_tse.h b/storage/tianchi/ha_tse.h index 9cdeedb73b2a535c6119c3f6cb761b39af3d4548..33ec26a7b75ecacc28db19a700b51ca64834dc5f 100644 --- a/storage/tianchi/ha_tse.h +++ b/storage/tianchi/ha_tse.h @@ -36,6 +36,7 @@ #include "sql/abstract_query_plan.h" #include "sql/dd/types/schema.h" #include "sql/dd/types/object_table_definition.h" +#include "sql/dd/string_type.h" #pragma GCC visibility push(default) @@ -148,6 +149,7 @@ again. */ #define IS_PRIMARY_ROLE() (tse_get_cluster_role() == (int32_t)dis_cluster_role::PRIMARY) #define IS_STANDBY_ROLE() (tse_get_cluster_role() == (int32_t)dis_cluster_role::STANDBY) +static const dd::String_type index_file_name_val_key("index_file_name"); static const uint ROW_ID_LENGTH = sizeof(uint64_t); static const uint TSE_START_TIMEOUT = 120; // seconds extern const char *tse_hton_name; diff --git a/storage/tianchi/ha_tsepart.cc b/storage/tianchi/ha_tsepart.cc index dc0ad9ca86d2be7a1ffbfab787e5a057c5af2947..a2616f8d5e952528f2a47c36e865c17ec0bd8978 100644 --- a/storage/tianchi/ha_tsepart.cc +++ b/storage/tianchi/ha_tsepart.cc @@ -53,6 +53,9 @@ #include "typelib.h" #include "tse_cbo.h" #include "sql/sql_alter.h" +#include "sql/dd/properties.h" +#include "sql/dd/types/partition.h" +#include "sql/dd/string_type.h" #define INVALID_PART_ID (uint32)0xFFFFFFFF; @@ -1130,3 +1133,32 @@ uint32 ha_tsepart::calculate_key_hash_value(Field **field_array) return (Partition_helper::ph_calculate_key_hash_value(field_array)); } +bool ha_tsepart::check_unsupported_index(dd::Table *table_def) { + // 遍历分区,存在index_file_name_val,创建表失败 + for (const auto dd_part : *table_def->leaf_partitions()) { + dd::String_type index_file_name; + if(dd_part == nullptr){ + continue; + } + const dd::Properties &options = dd_part->options(); + if (options.exists(index_file_name_val_key)) { + options.get(index_file_name_val_key, &index_file_name); + } + if (!index_file_name.empty()) { + my_error(ER_ILLEGAL_HA, MYF(0), table_share != nullptr ? table_share->table_name.str : " "); + return true; + } + } + return false; +} + +EXTER_ATTACK int ha_tsepart::create(const char *name, TABLE *form, HA_CREATE_INFO *create_info, + dd::Table *table_def) { + THD *thd = ha_thd(); + if(table_def != nullptr && check_unsupported_index(table_def)){ + tse_log_system("Unsupported operation. sql = %s", thd->query().str); + return HA_ERR_WRONG_COMMAND; + } + return ha_tse::create(name, form, create_info, table_def); +} + diff --git a/storage/tianchi/ha_tsepart.h b/storage/tianchi/ha_tsepart.h index 0cb07598720f23133f582e2fed514bc1518a1ff7..ed534549cb82dde42815e9e6fe7074104d379cd7 100644 --- a/storage/tianchi/ha_tsepart.h +++ b/storage/tianchi/ha_tsepart.h @@ -24,6 +24,7 @@ #include "tse_srv.h" #include "tse_util.h" #include "sql/partitioning/partition_handler.h" +#include "sql/dd/string_type.h" class Tsepart_share : public Partition_share { public: @@ -64,6 +65,8 @@ class ha_tsepart : public ha_tse, */ int truncate_partition_low(dd::Table *dd_table) override; + bool check_unsupported_index(dd::Table *table_def); + /** Write a row in specific partition. Stores a row in an TSE database, to the table specified in this handle. @@ -368,6 +371,9 @@ class ha_tsepart : public ha_tse, int optimize(THD *thd, HA_CHECK_OPT *check_opt) override; + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info, + dd::Table *table_def) override; + /* Get partition row type @param[in] partition_table partition table @param[in] part_id Id of partition for which row type to be retrieved