From 43306e5d3b365d3db3998a3821d31dcd73e6b127 Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 6 Jan 2025 16:15:14 +0000 Subject: [PATCH] [FTS][BUG.FIX] Inconsistent error when creating fts indexe on virtual columns or different character set columns --- src/share/ob_fts_index_builder_util.cpp | 12 ++++++++---- src/share/ob_rpc_struct.cpp | 3 ++- src/share/ob_rpc_struct.h | 6 +++++- src/sql/resolver/ddl/ob_alter_table_resolver.cpp | 1 + src/sql/resolver/ddl/ob_create_index_resolver.cpp | 1 + src/sql/resolver/ddl/ob_create_table_resolver.cpp | 1 + 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/share/ob_fts_index_builder_util.cpp b/src/share/ob_fts_index_builder_util.cpp index b58e916ed..24cc78a35 100644 --- a/src/share/ob_fts_index_builder_util.cpp +++ b/src/share/ob_fts_index_builder_util.cpp @@ -453,7 +453,7 @@ int ObFtsIndexBuilderUtil::adjust_fts_args( } } } - FLOG_INFO("adjust fts arg finished", K(index_arg)); + FLOG_INFO("adjust fts arg finished", K(ret), K(index_arg)); return ret; } @@ -1820,9 +1820,8 @@ int ObFtsIndexBuilderUtil::check_fulltext_index_allowed( if (OB_ISNULL(index_arg) || !data_schema.is_valid()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), KPC(index_arg), K(data_schema)); - } else if (!share::schema::is_fts_index_aux(index_arg->index_type_) - && !share::schema::is_fts_doc_word_aux(index_arg->index_type_)) { - } else { + } else if (static_cast(ObDDLResolver::INDEX_KEYNAME::FTS_KEY) == index_arg->index_key_) { + ObCollationType collation_type = CS_TYPE_INVALID; for (int64_t i = 0; OB_SUCC(ret) && i < index_arg->index_columns_.count(); ++i) { const ObString &column_name = index_arg->index_columns_.at(i).column_name_; const ObColumnSchemaV2 *col_schema = nullptr; @@ -1836,6 +1835,11 @@ int ObFtsIndexBuilderUtil::check_fulltext_index_allowed( } else if (OB_UNLIKELY(col_schema->is_virtual_generated_column())) { ret = OB_NOT_SUPPORTED; LOG_USER_ERROR(OB_NOT_SUPPORTED, "Fulltext index on virtual generated column is"); + } else if (CS_TYPE_INVALID == collation_type) { + collation_type = col_schema->get_collation_type(); + } else if (collation_type != col_schema->get_collation_type()) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "create fulltext index on columns with different collation"); } } } diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index 2a0dfd67a..d5f75fca8 100644 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -3491,7 +3491,8 @@ OB_SERIALIZE_MEMBER((ObCreateIndexArg, ObIndexArg), vidx_refresh_info_, is_rebuild_index_, is_index_scope_specified_, - is_offline_rebuild_); + is_offline_rebuild_, + index_key_); OB_SERIALIZE_MEMBER((ObIndexOfflineDdlArg, ObDDLArg), arg_, diff --git a/src/share/ob_rpc_struct.h b/src/share/ob_rpc_struct.h index c17db04f3..2705dc4b3 100644 --- a/src/share/ob_rpc_struct.h +++ b/src/share/ob_rpc_struct.h @@ -2802,7 +2802,8 @@ public: vidx_refresh_info_(), is_rebuild_index_(false), is_index_scope_specified_(false), - is_offline_rebuild_(false) + is_offline_rebuild_(false), + index_key_(-1) { index_action_type_ = ADD_INDEX; index_using_type_ = share::schema::USING_BTREE; @@ -2838,6 +2839,7 @@ public: is_rebuild_index_ = false; is_index_scope_specified_ = false; is_offline_rebuild_ = false; + index_key_ = -1; } void set_index_action_type(const IndexActionType type) { index_action_type_ = type; } bool is_valid() const; @@ -2879,6 +2881,7 @@ public: is_rebuild_index_ = other.is_rebuild_index_; is_index_scope_specified_ = other.is_index_scope_specified_; is_offline_rebuild_ = other.is_offline_rebuild_; + index_key_ = other.index_key_; } return ret; } @@ -2951,6 +2954,7 @@ public: bool is_rebuild_index_; bool is_index_scope_specified_; bool is_offline_rebuild_; + int64_t index_key_; }; struct ObIndexOfflineDdlArg : ObDDLArg diff --git a/src/sql/resolver/ddl/ob_alter_table_resolver.cpp b/src/sql/resolver/ddl/ob_alter_table_resolver.cpp index fb4c0e691..ac6218397 100644 --- a/src/sql/resolver/ddl/ob_alter_table_resolver.cpp +++ b/src/sql/resolver/ddl/ob_alter_table_resolver.cpp @@ -2030,6 +2030,7 @@ int ObAlterTableResolver::resolve_add_index(const ParseNode &node) } } if (OB_SUCC(ret)) { + create_index_arg->index_key_ = static_cast(index_keyname_); if (OB_FAIL(resolve_results.push_back(resolve_result))) { LOG_WARN("fail to push back index_stmt_list", K(ret), K(resolve_result)); diff --git a/src/sql/resolver/ddl/ob_create_index_resolver.cpp b/src/sql/resolver/ddl/ob_create_index_resolver.cpp index 4bbc2ea6d..d9115a2aa 100644 --- a/src/sql/resolver/ddl/ob_create_index_resolver.cpp +++ b/src/sql/resolver/ddl/ob_create_index_resolver.cpp @@ -883,6 +883,7 @@ int ObCreateIndexResolver::set_table_option_to_stmt(const uint64_t data_table_id } else { // set type to fts_index_aux first, append other fts arg later index_arg.index_type_ = INDEX_TYPE_FTS_INDEX_LOCAL; + index_arg.index_key_ = static_cast(index_keyname_); } } else if (MULTI_KEY == index_keyname_ || MULTI_UNIQUE_KEY == index_keyname_) { uint64_t tenant_data_version = 0; diff --git a/src/sql/resolver/ddl/ob_create_table_resolver.cpp b/src/sql/resolver/ddl/ob_create_table_resolver.cpp index 88f6a619d..1bcf28994 100644 --- a/src/sql/resolver/ddl/ob_create_table_resolver.cpp +++ b/src/sql/resolver/ddl/ob_create_table_resolver.cpp @@ -3182,6 +3182,7 @@ int ObCreateTableResolver::resolve_index_node(const ParseNode *node) ObCreateIndexArg &create_index_arg = create_index_stmt.get_create_index_arg(); ObSArray &resolve_results = create_table_stmt->get_index_partition_resolve_results(); ObSArray &index_arg_list = create_table_stmt->get_index_arg_list(); + index_arg_.index_key_ = static_cast(index_keyname_); if (OB_FAIL(create_index_arg.assign(index_arg_))) { LOG_WARN("fail to assign create index arg", K(ret)); } else if (is_index_part_specified) {