diff --git a/mysql-test/suite/ctc/r/ctc_ddl_func_index.result b/mysql-test/suite/ctc/r/ctc_ddl_func_index.result index 5c551745dbb573f9bdea5c9e70e2935c1b631f3a..d8e34ff627166fa30b46637369164ec6b8ad43fb 100644 --- a/mysql-test/suite/ctc/r/ctc_ddl_func_index.result +++ b/mysql-test/suite/ctc/r/ctc_ddl_func_index.result @@ -95,4 +95,8 @@ create table t5 (c1 int, c2 int, c3 varchar(10), index func_idx_1 ((abs(c1)))); drop table t5; create table t5 (c1 int, c2 int, c3 varchar(10), index func_idx_1 ((c1 + c2))); ERROR HY000: Cantian does not support function indexes with multiple columns of arguments. +create table t6 (c1 int, c2 int); +create index index_func_idx_1 on t6 ((if(c1 = 1, 1, 3))); +ERROR HY000: Function if is not indexable +drop table t6; drop database db1; diff --git a/mysql-test/suite/ctc/t/ctc_ddl_func_index.test b/mysql-test/suite/ctc/t/ctc_ddl_func_index.test index 0dedf2e8033f5adf68018127a478359c66805ffb..879c0c2cafaf0feeda52760154cc8d55b15faee2 100644 --- a/mysql-test/suite/ctc/t/ctc_ddl_func_index.test +++ b/mysql-test/suite/ctc/t/ctc_ddl_func_index.test @@ -51,5 +51,11 @@ drop table t5; --error ER_DISALLOWED_OPERATION create table t5 (c1 int, c2 int, c3 varchar(10), index func_idx_1 ((c1 + c2))); +# 创建包含条件表达式函数索引异常场景 +create table t6 (c1 int, c2 int); +--error ER_DISALLOWED_OPERATION +create index index_func_idx_1 on t6 ((if(c1 = 1, 1, 3))); + +drop table t6; drop database db1; diff --git a/storage/ctc/ctc_ddl_util.cc b/storage/ctc/ctc_ddl_util.cc index ef26c4645864c3f878547ae0d35c2188c0379852..a13e1a3f6be868329198ba9cae2895a45c06cc5a 100644 --- a/storage/ctc/ctc_ddl_util.cc +++ b/storage/ctc/ctc_ddl_util.cc @@ -89,6 +89,9 @@ bool check_data_file_name(const char *data_file_name) { } Field *ctc_get_field_by_name(TABLE *form, const char *name) { + if (name == nullptr) { + return nullptr; + } for (uint32_t i = 0; i < form->s->fields; i++) { if (strcasecmp(form->field[i]->field_name, name) == 0) { return form->field[i];