diff --git a/mysql-test/suite/ctc/r/ctc_read_only.result b/mysql-test/suite/ctc/r/ctc_read_only.result index 09ebeb4c053d3896764fd446c04bb1c001f2b84d..ff81b09042117d18672eb09e6b46ef3fc8bb7ea1 100644 --- a/mysql-test/suite/ctc/r/ctc_read_only.result +++ b/mysql-test/suite/ctc/r/ctc_read_only.result @@ -3,14 +3,10 @@ set @orig_sql_mode= @@sql_mode; create user test@localhost; grant CREATE, INSERT, SELECT, DROP on *.* to test@localhost; set global read_only=0; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. create table table_11733 (a int); BEGIN; insert into table_11733 values(11733); set global read_only=1; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. select @@global.read_only; @@global.read_only 1 @@ -20,8 +16,6 @@ a COMMIT; ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement set global read_only=0; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. COMMIT; drop table table_11733 ; drop user test@localhost; @@ -30,8 +24,6 @@ GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (0), (1); SET GLOBAL read_only=1; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT * FROM t1; a 0 @@ -43,8 +35,6 @@ a 1 COMMIT; SET GLOBAL read_only=0; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. FLUSH TABLES WITH READ LOCK; SELECT * FROM t1; a @@ -70,8 +60,6 @@ INSERT INTO db1.t2 VALUES (2); GRANT CREATE TEMPORARY TABLES, DROP, INSERT, DELETE, UPDATE, SELECT, LOCK TABLES ON db1.* TO bug33669@localhost; SET GLOBAL READ_ONLY = ON; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. CREATE TEMPORARY TABLE temp (a INT); INSERT INTO temp VALUES (1); DROP TABLE temp; @@ -202,8 +190,6 @@ a a 5 10 DROP TABLE temp1, temp2; SET GLOBAL READ_ONLY = OFF; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. DROP USER bug33669@localhost; DROP DATABASE db1; SET @start_read_only = @@global.read_only; @@ -212,53 +198,35 @@ SELECT @start_read_only, @start_super_read_only; @start_read_only @start_super_read_only 0 0 SET @@global.super_read_only = 1; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SET @@global.super_read_only = DEFAULT; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 0 SET @@global.super_read_only = @start_super_read_only; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only = 0; @@global.super_read_only = 0 1 SET @@global.super_read_only = 0; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 0 SET @@global.super_read_only = 1; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 1 SET @@global.super_read_only = TRUE; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 1 SET @@global.super_read_only = FALSE; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 0 SET @@global.super_read_only = ON; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 1 SET @@global.super_read_only = OFF; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 0 @@ -313,8 +281,6 @@ WHERE VARIABLE_NAME='super_read_only'; IF(@@read_only, "ON", "OFF") = VARIABLE_VALUE 0 SET @@global.super_read_only = 1; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@super_read_only = @@global.super_read_only; @@super_read_only = @@global.super_read_only 1 @@ -334,11 +300,7 @@ ERROR 42S02: Unknown table 'global' in field list SELECT super_read_only = @@session.super_read_only; ERROR 42S22: Unknown column 'super_read_only' in 'field list' SET @@global.read_only = @start_read_only; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SET @@global.super_read_only = @start_super_read_only; -Warnings: -Warning 3655 CTC: This parameter will not be broadcast to other nodes. SELECT @@global.super_read_only; @@global.super_read_only 0 diff --git a/storage/ctc/ctc_meta_data.cc b/storage/ctc/ctc_meta_data.cc index dd96415dccfa411f772e185f751e267b31344c83..d5d2ea701c5fcb73cba0c6b402144af693ea3e49 100644 --- a/storage/ctc/ctc_meta_data.cc +++ b/storage/ctc/ctc_meta_data.cc @@ -583,6 +583,10 @@ static void ctc_init_mdl_request(ctc_lock_table_info *lock_info, MDL_request *md dd::Trigger::create_mdl_key(schema_name, name, &mdl_key); MDL_REQUEST_INIT_BY_KEY(mdl_request, &mdl_key, MDL_EXCLUSIVE, MDL_EXPLICIT); break; + case MDL_key::BACKUP_LOCK: + MDL_REQUEST_INIT(mdl_request, ctc_mdl_namespace, lock_info->db_name, lock_info->table_name, + MDL_SHARED, MDL_EXPLICIT); + break; default: MDL_REQUEST_INIT(mdl_request, ctc_mdl_namespace, lock_info->db_name, lock_info->table_name, MDL_EXCLUSIVE, MDL_EXPLICIT); diff --git a/storage/ctc/ctc_util.cc b/storage/ctc/ctc_util.cc index f082185f228ab0c56c62ef9f9039855723689f79..4a739d2aabf49b86147c09e54dd815dc5272eaae 100644 --- a/storage/ctc/ctc_util.cc +++ b/storage/ctc/ctc_util.cc @@ -817,4 +817,35 @@ void ctc_lock_table_post(MYSQL_THD thd, vector& ticket_list) { thd->mdl_context.release_lock(*it); } ticket_list.clear(); +} + +/** + Get int value from session variable if it's in a given range. + If the variable does not exist or is outside of the range, then a default value is returned. + + @param thd thread handler + @param variable_name the name of the session variable, without @ + @param min the min of the range + @param max the max of the range + @param default_value the default value returned if: + 1. The variable has not been defined + 2. The value in the variable is outside of the given range + @return the value of the session variable or default value, as discussed above +*/ +longlong get_session_variable_int_value_with_range(THD *thd, + const string &variable_name, + longlong min, + longlong max, + longlong default_value) +{ + user_var_entry *var_entry = find_or_nullptr(thd->user_vars, variable_name); + if (var_entry == nullptr || var_entry->ptr() == nullptr) { + return default_value; + } + bool is_var_null; + longlong var_value = var_entry->val_int(&is_var_null); + if ((is_var_null) || (var_value < min || var_value > max)) { + return default_value; + } + return var_value; } \ No newline at end of file diff --git a/storage/ctc/ctc_util.h b/storage/ctc/ctc_util.h index 2e3ff1e1e9dddca9b31a0c945b8967c5e00037de..12216ffd7baba7bbae981df6c07313dc411fe3fb 100644 --- a/storage/ctc/ctc_util.h +++ b/storage/ctc/ctc_util.h @@ -40,6 +40,11 @@ static unordered_set mysql_system_db{"information_schema", "mysql", "per #define OFFSET_VARCHAR_TYPE 2 +#define SESSION_VARIABLE_NAME_CREATE_INDEX_PARALLELISM "create_index_parallelism" +#define SESSION_VARIABLE_VALUE_MIN_CREATE_INDEX_PARALLELISM 0 +#define SESSION_VARIABLE_VALUE_MAX_CREATE_INDEX_PARALLELISM 10 +#define SESSION_VARIABLE_VALUE_DEFAULT_CREATE_INDEX_PARALLELISM -1 + void ctc_split_normalized_name(const char *file_name, char db[], size_t db_buf_len, char name[], size_t name_buf_len, bool *is_tmp_table); void ctc_copy_name(char to_name[], const char from_name[], size_t to_buf_len); @@ -72,6 +77,11 @@ int ctc_check_unlock_instance(MYSQL_THD thd); int ctc_record_sql(MYSQL_THD thd, bool need_select_db); int ctc_lock_table_pre(MYSQL_THD thd, vector& ticket_list, enum_mdl_type mdl_type); void ctc_lock_table_post(MYSQL_THD thd, vector& ticket_list); +longlong get_session_variable_int_value_with_range(THD *thd, + const string &variable_name, + longlong min, + longlong max, + longlong default_value); #pragma GCC visibility push(default) diff --git a/storage/ctc/ha_ctc_ddl.cc b/storage/ctc/ha_ctc_ddl.cc index 50e2a43b5fede2dd837d7f624d3039758d1242c8..26eeec8bbc784dcb3d9c4d40bb89929566d28f84 100644 --- a/storage/ctc/ha_ctc_ddl.cc +++ b/storage/ctc/ha_ctc_ddl.cc @@ -1284,125 +1284,172 @@ static uint32_t ctc_fill_func_key_part(TABLE *form, THD *thd, TcDb__CtcDDLTableK return CT_SUCCESS; } -static bool ctc_ddl_create_table_fill_add_key(TcDb__CtcDDLCreateTableDef *req, THD *thd, - const dd::Table *table_def, TABLE *form, char *user) { - if (req->n_key_list == 0) { - return true; +static inline longlong get_session_level_create_index_parallelism(THD *thd) +{ + return get_session_variable_int_value_with_range( + thd, SESSION_VARIABLE_NAME_CREATE_INDEX_PARALLELISM, + SESSION_VARIABLE_VALUE_MIN_CREATE_INDEX_PARALLELISM, + SESSION_VARIABLE_VALUE_MAX_CREATE_INDEX_PARALLELISM, + SESSION_VARIABLE_VALUE_DEFAULT_CREATE_INDEX_PARALLELISM); +} + +static inline int initialize_ddl_table_key_req_key_def(TcDb__CtcDDLTableKey *req_key_def, char* user, + TcDb__CtcDDLCreateTableDef *req, const char *name) +{ + req_key_def->user = user; + req_key_def->table = req->name; + CTC_RETURN_IF_NOT_ZERO(check_ctc_identifier_name(name)); + req_key_def->name = const_cast(name); + req_key_def->space = NULL; + return 0; +} + +static bool ctc_ddl_create_table_fill_add_key_table_def_null_fill_key_part(TcDb__CtcDDLTableKey *req_key_def, + THD *thd, TABLE *form, TcDb__CtcDDLTableKeyPart *req_key_part, KEY_PART_INFO *key_part) +{ + if (key_part->key_part_flag & HA_REVERSE_SORT) { + req_key_def->is_dsc = true; } + bool is_prefix_key = false; + cm_assert(key_part != NULL); + Field *fld = form->field[key_part->field->field_index()]; + cm_assert(fld != nullptr); + if (fld->is_field_for_functional_index()) { + req_key_def->is_func = true; + CTC_RETURN_IF_ERROR(ctc_fill_func_key_part(form, thd, req_key_part, fld->gcol_info) == CT_SUCCESS, false); + } else { + if (fld->is_virtual_gcol()) { + my_printf_error(ER_DISALLOWED_OPERATION, "%s", MYF(0), + "Cantian does not support index on virtual generated column."); + return false; + } - if (table_def == nullptr) { - for (uint i = 0; i < req->n_key_list; i++) { - TcDb__CtcDDLTableKey *req_key_def = req->key_list[i]; - const KEY *key = form->key_info + i; - if (key->key_length == 0) { - my_error(ER_WRONG_KEY_COLUMN, MYF(0), key->key_part->field->field_name); - return ER_WRONG_KEY_COLUMN; - } - req_key_def->user = user; - req_key_def->table = req->name; - CTC_RETURN_IF_NOT_ZERO(check_ctc_identifier_name(key->name)); - req_key_def->name = const_cast(key->name); - req_key_def->space = NULL; - CTC_RETURN_IF_ERROR(get_ctc_key_type(key, &req_key_def->key_type), false); - CTC_RETURN_IF_ERROR(get_ctc_key_algorithm(key->algorithm, &req_key_def->algorithm), false); - if (req_key_def->key_type == CTC_KEYTYPE_PRIMARY || req_key_def->key_type == CTC_KEYTYPE_UNIQUE) { - req_key_def->is_constraint = true; - } - for (uint j = 0; j < req_key_def->n_columns; j++) { - TcDb__CtcDDLTableKeyPart *req_key_part = req_key_def->columns[j]; - KEY_PART_INFO *key_part = key->key_part + j; - if (key_part->key_part_flag & HA_REVERSE_SORT) { - req_key_def->is_dsc = true; - } - bool is_prefix_key = false; - assert(key_part != NULL); - Field *fld = form->field[key_part->field->field_index()]; - assert(fld != nullptr); - if (fld->is_field_for_functional_index()) { - req_key_def->is_func = true; - CTC_RETURN_IF_ERROR(ctc_fill_func_key_part(form, thd, req_key_part, fld->gcol_info) == CT_SUCCESS, false); - } else { - if (fld->is_virtual_gcol()) { - my_printf_error(ER_DISALLOWED_OPERATION, "%s", MYF(0), - "Cantian does not support index on virtual generated column."); - return false; - } - - uint prefix_len = get_prefix_index_len(fld, key_part->length); - if (prefix_len) { - ctc_fill_prefix_func_key_part(req_key_part, fld, prefix_len); - is_prefix_key = true; - } else { - req_key_part->is_func = false; - req_key_part->func_text = nullptr; - } - req_key_part->name = const_cast(key_part->field->field_name); - } - req_key_part->length = key_part->length; - ctc_ddl_get_data_type_from_mysql_type(fld, fld->type(), &req_key_part->datatype); - ctc_set_unsigned_column(fld, &req_key_part->is_unsigned); - if (is_prefix_key && fld->is_flag_set(BLOB_FLAG)) { - req_key_part->datatype = CTC_DDL_TYPE_VARCHAR; - } + uint prefix_len = get_prefix_index_len(fld, key_part->length); + if (prefix_len) { + ctc_fill_prefix_func_key_part(req_key_part, fld, prefix_len); + is_prefix_key = true; + } else { + req_key_part->is_func = false; + req_key_part->func_text = nullptr; + } + req_key_part->name = const_cast(key_part->field->field_name); + } + req_key_part->length = key_part->length; + ctc_ddl_get_data_type_from_mysql_type(fld, fld->type(), &req_key_part->datatype); + ctc_set_unsigned_column(fld, &req_key_part->is_unsigned); + if (is_prefix_key && fld->is_flag_set(BLOB_FLAG)) { + req_key_part->datatype = CTC_DDL_TYPE_VARCHAR; + } + return true; +} + +static bool ctc_ddl_create_table_fill_add_key_table_def_null(TcDb__CtcDDLCreateTableDef *req, THD *thd, + TABLE *form, char *user) +{ + for (uint i = 0; i < req->n_key_list; i++) { + TcDb__CtcDDLTableKey *req_key_def = req->key_list[i]; + const KEY *key = form->key_info + i; + if (key->key_length == 0) { + my_error(ER_WRONG_KEY_COLUMN, MYF(0), key->key_part->field->field_name); + return ER_WRONG_KEY_COLUMN; + } + CTC_RETURN_IF_NOT_ZERO(initialize_ddl_table_key_req_key_def(req_key_def, user, req, key->name)); + CTC_RETURN_IF_ERROR(get_ctc_key_type(key, &req_key_def->key_type), false); + CTC_RETURN_IF_ERROR(get_ctc_key_algorithm(key->algorithm, &req_key_def->algorithm), false); + if (req_key_def->key_type == CTC_KEYTYPE_PRIMARY || req_key_def->key_type == CTC_KEYTYPE_UNIQUE) { + req_key_def->is_constraint = true; + } + for (uint j = 0; j < req_key_def->n_columns; j++) { + TcDb__CtcDDLTableKeyPart *req_key_part = req_key_def->columns[j]; + KEY_PART_INFO *key_part = key->key_part + j; + if (!ctc_ddl_create_table_fill_add_key_table_def_null_fill_key_part( + req_key_def, thd, form, req_key_part, key_part)) { + return false; } } - return true; + req_key_def->parallelism = get_session_level_create_index_parallelism(thd); } + return true; +} +static inline bool ctc_ddl_create_table_fill_add_key_table_def_not_null_fill_key_part(TcDb__CtcDDLTableKey *req_key_def, + THD *thd, TABLE *form, TcDb__CtcDDLTableKeyPart *req_key_part, const dd::Index_element *key_part) +{ + if (key_part->order() == dd::Index_element::ORDER_DESC) { + req_key_def->is_dsc = true; + } + bool is_prefix_key = false; + cm_assert(key_part != NULL); + Field *fld = ctc_get_field_by_name(form, key_part->column().name().data()); + cm_assert(fld != nullptr); + + if (fld->is_field_for_functional_index()) { + req_key_def->is_func = true; + CTC_RETURN_IF_ERROR(ctc_fill_func_key_part(form, thd, req_key_part, fld->gcol_info) == CT_SUCCESS, false); + } else { + if (fld->is_virtual_gcol()) { + my_printf_error(ER_DISALLOWED_OPERATION, "%s", MYF(0), + "Cantian does not support index on virtual generated column."); + return false; + } + + uint prefix_len = get_prefix_index_len(fld, key_part->length()); + if (prefix_len) { + ctc_fill_prefix_func_key_part(req_key_part, fld, prefix_len); + is_prefix_key = true; + } else { + req_key_part->is_func = false; + req_key_part->func_text = nullptr; + } + req_key_part->name = const_cast(key_part->column().name().data()); + } + req_key_part->length = key_part->length(); + ctc_ddl_get_data_type_from_mysql_type(fld, fld->type(), &req_key_part->datatype); + ctc_set_unsigned_column(fld, &req_key_part->is_unsigned); + if (is_prefix_key && fld->is_flag_set(BLOB_FLAG)) { + req_key_part->datatype = CTC_DDL_TYPE_VARCHAR; + } + return true; +} + +static inline bool ctc_ddl_create_table_fill_add_key_table_def_not_null(TcDb__CtcDDLCreateTableDef *req, THD *thd, + const dd::Table *table_def, TABLE *form, + char *user) +{ for (uint i = 0; i < req->n_key_list; i++) { TcDb__CtcDDLTableKey *req_key_def = req->key_list[i]; assert(table_def != nullptr); const dd::Index *idx = table_def->indexes().at(i); - req_key_def->user = user; - req_key_def->table = req->name; - CTC_RETURN_IF_NOT_ZERO(check_ctc_identifier_name(idx->name().data())); - req_key_def->name = const_cast(idx->name().data()); - req_key_def->space = NULL; + CTC_RETURN_IF_NOT_ZERO(initialize_ddl_table_key_req_key_def(req_key_def, user, req, idx->name().data())); CTC_RETURN_IF_ERROR(ctc_ddl_get_create_key_type(idx->type(), &req_key_def->key_type), false); CTC_RETURN_IF_ERROR(ctc_ddl_get_create_key_algorithm(idx->algorithm(), &req_key_def->algorithm), false); for (uint j = 0; j < req_key_def->n_columns; j++) { TcDb__CtcDDLTableKeyPart *req_key_part = req_key_def->columns[j]; const dd::Index_element *key_part = idx->elements().at(j); - if (key_part->order() == dd::Index_element::ORDER_DESC) { - req_key_def->is_dsc = true; - } - bool is_prefix_key = false; - assert(key_part != NULL); - Field *fld = ctc_get_field_by_name(form, key_part->column().name().data()); - assert(fld != nullptr); - - if (fld->is_field_for_functional_index()) { - req_key_def->is_func = true; - CTC_RETURN_IF_ERROR(ctc_fill_func_key_part(form, thd, req_key_part, fld->gcol_info) == CT_SUCCESS, false); - } else { - if (fld->is_virtual_gcol()) { - my_printf_error(ER_DISALLOWED_OPERATION, "%s", MYF(0), - "Cantian does not support index on virtual generated column."); - return false; - } - - uint prefix_len = get_prefix_index_len(fld, key_part->length()); - if (prefix_len) { - ctc_fill_prefix_func_key_part(req_key_part, fld, prefix_len); - is_prefix_key = true; - } else { - req_key_part->is_func = false; - req_key_part->func_text = nullptr; - } - req_key_part->name = const_cast(key_part->column().name().data()); - } - req_key_part->length = key_part->length(); - ctc_ddl_get_data_type_from_mysql_type(fld, fld->type(), &req_key_part->datatype); - ctc_set_unsigned_column(fld, &req_key_part->is_unsigned); - if (is_prefix_key && fld->is_flag_set(BLOB_FLAG)) { - req_key_part->datatype = CTC_DDL_TYPE_VARCHAR; + if (!ctc_ddl_create_table_fill_add_key_table_def_not_null_fill_key_part( + req_key_def, thd, form, req_key_part, key_part)) { + return false; } } + req_key_def->parallelism = get_session_level_create_index_parallelism(thd); } return true; } +static bool ctc_ddl_create_table_fill_add_key(TcDb__CtcDDLCreateTableDef *req, THD *thd, + const dd::Table *table_def, TABLE *form, char *user) +{ + if (req->n_key_list == 0) { + return true; + } + + if (table_def == nullptr) { + return ctc_ddl_create_table_fill_add_key_table_def_null(req, thd, form, user); + } + return ctc_ddl_create_table_fill_add_key_table_def_not_null(req, thd, table_def, form, user); +} + static int ctc_ddl_fill_partition_table_info(const dd::Partition *pt, char **mem_start, char *mem_end, TcDb__CtcDDLPartitionDef *part_def, uint32_t part_id) { @@ -1533,7 +1580,7 @@ static int ctc_ddl_init_foreign_key_def(TcDb__CtcDDLCreateTableDef *req, const d return 0; } -static int ctc_ddl_init_index_def(TcDb__CtcDDLCreateTableDef *req, const dd::Table *table_def, +static int ctc_ddl_init_index_def(TcDb__CtcDDLCreateTableDef *req, THD* thd, const dd::Table *table_def, char **mem_start, char *mem_end) { req->key_list = (TcDb__CtcDDLTableKey **)ctc_ddl_alloc_mem( mem_start, mem_end, sizeof(TcDb__CtcDDLTableKey*) * req->n_key_list); @@ -1566,12 +1613,13 @@ static int ctc_ddl_init_index_def(TcDb__CtcDDLCreateTableDef *req, const dd::Tab req_key->columns[j]->func_text = (char *)ctc_ddl_alloc_mem(mem_start, mem_end, FUNC_TEXT_MAX_LEN); assert(req_key->columns[j]->func_text != NULL); memset(req_key->columns[j]->func_text, 0, FUNC_TEXT_MAX_LEN); + req_key->parallelism = get_session_level_create_index_parallelism(thd); } } return 0; } -static int ctc_ddl_init_index_form(TcDb__CtcDDLCreateTableDef *req, TABLE *form, +static int ctc_ddl_init_index_form(TcDb__CtcDDLCreateTableDef *req, THD *thd, TABLE *form, char **mem_start, char *mem_end) { req->n_key_list = form->s->keys; @@ -1613,6 +1661,7 @@ static int ctc_ddl_init_index_form(TcDb__CtcDDLCreateTableDef *req, TABLE *form, assert(req_key->columns[j]->func_text != NULL); memset(req_key->columns[j]->func_text, 0, FUNC_TEXT_MAX_LEN); } + req_key->parallelism = get_session_level_create_index_parallelism(thd); } } return 0; @@ -1636,12 +1685,12 @@ static int ctc_ddl_init_create_table_def(TcDb__CtcDDLCreateTableDef *req, } if (table_def == nullptr) { - return ctc_ddl_init_index_form(req, form, mem_start, mem_end); + return ctc_ddl_init_index_form(req, thd, form, mem_start, mem_end); } req->n_key_list = table_def->indexes().size(); if (req->n_key_list > 0) { - CTC_RETURN_IF_NOT_ZERO(ctc_ddl_init_index_def(req, table_def, mem_start, mem_end)); + CTC_RETURN_IF_NOT_ZERO(ctc_ddl_init_index_def(req, thd, table_def, mem_start, mem_end)); } req->n_fk_list = table_def->foreign_keys().size(); @@ -2008,7 +2057,7 @@ static int init_create_list_4alter_table(TcDb__CtcDDLAlterTableDef *req, char ** return 0; } -static int init_add_key_list_4alter_table(TcDb__CtcDDLAlterTableDef *req, Alter_inplace_info *ha_alter_info, +static int init_add_key_list_4alter_table(TcDb__CtcDDLAlterTableDef *req, THD *thd, Alter_inplace_info *ha_alter_info, char **mem_start, char *mem_end) { req->add_key_list = (TcDb__CtcDDLTableKey **)ctc_ddl_alloc_mem( mem_start, mem_end, sizeof(TcDb__CtcDDLTableKey*) * req->n_add_key_list); @@ -2044,6 +2093,7 @@ static int init_add_key_list_4alter_table(TcDb__CtcDDLAlterTableDef *req, Alter_ } memset(req_key->columns[j]->func_text, 0, FUNC_TEXT_MAX_LEN); } + req_key->parallelism = get_session_level_create_index_parallelism(thd); } return 0; } @@ -2177,7 +2227,7 @@ static int init_ctc_ddl_alter_table_def(TcDb__CtcDDLAlterTableDef *req, Alter_in req->n_add_key_list = 0; } if (req->n_add_key_list > 0) { - CTC_RETURN_IF_NOT_ZERO(init_add_key_list_4alter_table(req, ha_alter_info, mem_start, mem_end)); + CTC_RETURN_IF_NOT_ZERO(init_add_key_list_4alter_table(req, thd, ha_alter_info, mem_start, mem_end)); } // 删除索引 @@ -2292,6 +2342,7 @@ bool ctc_ddl_fill_add_key(THD *thd, TABLE *form, TcDb__CtcDDLAlterTableDef *req, key_part) == CT_SUCCESS), false); } + req_key_def->parallelism = get_session_level_create_index_parallelism(thd); } return true; } diff --git a/storage/ctc/protobuf/tc_db.pb-c.c b/storage/ctc/protobuf/tc_db.pb-c.c index 2857a0474bb12c2ad3611624b30cc927bf7148e9..41cf5f7fe7caf39ed41a91e1457b9cdb291c6b5c 100644 --- a/storage/ctc/protobuf/tc_db.pb-c.c +++ b/storage/ctc/protobuf/tc_db.pb-c.c @@ -1727,7 +1727,7 @@ const ProtobufCMessageDescriptor tc_db__ctc_ddltable_key_part__descriptor = (ProtobufCMessageInit) tc_db__ctc_ddltable_key_part__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor tc_db__ctc_ddltable_key__field_descriptors[10] = +static const ProtobufCFieldDescriptor tc_db__ctc_ddltable_key__field_descriptors[11] = { { "user", @@ -1849,6 +1849,18 @@ static const ProtobufCFieldDescriptor tc_db__ctc_ddltable_key__field_descriptors 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "parallelism", + 11, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(TcDb__CtcDDLTableKey, parallelism), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned tc_db__ctc_ddltable_key__field_indices_by_name[] = { 5, /* field[5] = algorithm */ @@ -1858,6 +1870,7 @@ static const unsigned tc_db__ctc_ddltable_key__field_indices_by_name[] = { 6, /* field[6] = is_func */ 4, /* field[4] = key_type */ 2, /* field[2] = name */ + 10, /* field[10] = parallelism */ 3, /* field[3] = space */ 1, /* field[1] = table */ 0, /* field[0] = user */ @@ -1865,7 +1878,7 @@ static const unsigned tc_db__ctc_ddltable_key__field_indices_by_name[] = { static const ProtobufCIntRange tc_db__ctc_ddltable_key__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 10 } + { 0, 11 } }; const ProtobufCMessageDescriptor tc_db__ctc_ddltable_key__descriptor = { @@ -1875,7 +1888,7 @@ const ProtobufCMessageDescriptor tc_db__ctc_ddltable_key__descriptor = "TcDb__CtcDDLTableKey", "tc_db", sizeof(TcDb__CtcDDLTableKey), - 10, + 11, tc_db__ctc_ddltable_key__field_descriptors, tc_db__ctc_ddltable_key__field_indices_by_name, 1, tc_db__ctc_ddltable_key__number_ranges, diff --git a/storage/ctc/protobuf/tc_db.pb-c.h b/storage/ctc/protobuf/tc_db.pb-c.h index f4fbab2f121b9f0135b7991758058ba4ebb3de81..4ab70d31695937b9194c1e6ba31612feb863beef 100644 --- a/storage/ctc/protobuf/tc_db.pb-c.h +++ b/storage/ctc/protobuf/tc_db.pb-c.h @@ -171,10 +171,11 @@ struct TcDb__CtcDDLTableKey TcDb__CtcDDLTableKeyPart **columns; protobuf_c_boolean is_constraint; protobuf_c_boolean is_dsc; + int32_t parallelism; }; #define TC_DB__CTC_DDLTABLE_KEY__INIT \ { PROTOBUF_C_MESSAGE_INIT (&tc_db__ctc_ddltable_key__descriptor) \ - , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0, 0, 0, 0,NULL, 0, 0 } + , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0, 0, 0, 0,NULL, 0, 0, 0 } struct TcDb__CtcMsgCommDef diff --git a/storage/ctc/protobuf/tc_db.proto b/storage/ctc/protobuf/tc_db.proto index 5a9377785e5e6e56dd19bf398c4a4b319b8102fe..2393c0c1f1bfa9e938f0910f8baf6dac7345bfa8 100644 --- a/storage/ctc/protobuf/tc_db.proto +++ b/storage/ctc/protobuf/tc_db.proto @@ -67,6 +67,7 @@ message CtcDDLTableKey { repeated CtcDDLTableKeyPart columns = 8; bool is_constraint = 9; bool is_dsc = 10; + int32 parallelism = 11; } message CtcMsgCommDef { uint32 inst_id = 1;