From 05d841b95dd37796052a7f50c985f5726087318a Mon Sep 17 00:00:00 2001 From: JLY2015 <1623359870@qq.com> Date: Wed, 12 Nov 2025 12:17:49 +0000 Subject: [PATCH] [CP] [vctor index] fix show create table display index --- src/share/schema/ob_schema_printer.cpp | 2 +- .../vector_index/ob_vector_index_util.cpp | 23 +++++++++++++++++++ src/share/vector_index/ob_vector_index_util.h | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/share/schema/ob_schema_printer.cpp b/src/share/schema/ob_schema_printer.cpp index d2c518f488..6595487ed0 100644 --- a/src/share/schema/ob_schema_printer.cpp +++ b/src/share/schema/ob_schema_printer.cpp @@ -826,7 +826,7 @@ int ObSchemaPrinter::print_table_definition_indexes(const ObTableSchema &table_s // Do not print global index. } else if (index_schema->is_built_in_index()) { // For full-text or vector index search index, only inverted table can be printed, and others table will not be printed. - } else if (index_schema->is_vec_index() && index_schema->get_index_status() != INDEX_STATUS_AVAILABLE) { + } else if (index_schema->is_vec_index() && !ObVectorIndexUtil::check_index_is_all_ready(schema_guard_, table_schema, *index_schema)) { // Not show vec index which in unavaliable status } else if (OB_FAIL(print_single_index_definition(index_schema, table_schema, arena_allocator, buf, buf_len, pos, is_unique_index, is_oracle_mode, false, sql_mode, tz_info))) { diff --git a/src/share/vector_index/ob_vector_index_util.cpp b/src/share/vector_index/ob_vector_index_util.cpp index 2c52035d9f..fe1a91fb4f 100644 --- a/src/share/vector_index/ob_vector_index_util.cpp +++ b/src/share/vector_index/ob_vector_index_util.cpp @@ -4476,6 +4476,29 @@ int ObVectorIndexUtil::get_vector_index_column_name( return ret; } +bool ObVectorIndexUtil::check_index_is_all_ready( + ObSchemaGetterGuard &schema_guard, + const schema::ObTableSchema &table_schema, + const schema::ObTableSchema &index_schema) +{ + int ret = OB_SUCCESS; + bool is_all_ready = false; + + ObArray vec_column_names; + if (index_schema.is_built_in_index()) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected index type", K(ret), K(index_schema)); + } else if (OB_FAIL(get_vector_index_column_name(table_schema, index_schema, vec_column_names))) { + LOG_WARN("fail to get vector index column name", K(ret)); + } else if (vec_column_names.count() <= 0) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected vec column count", K(ret), K(index_schema)); + } else if (OB_FAIL(check_vector_index_by_column_name(schema_guard, table_schema, vec_column_names.at(0), is_all_ready))) { + LOG_WARN("fail to check vector index by column name", K(ret), K(vec_column_names)); + } + return is_all_ready; +} + bool ObVectorIndexUtil::is_match_index_column_name( const schema::ObTableSchema &table_schema, const schema::ObTableSchema &index_schema, diff --git a/src/share/vector_index/ob_vector_index_util.h b/src/share/vector_index/ob_vector_index_util.h index 38b2d47117..2c28a135a3 100644 --- a/src/share/vector_index/ob_vector_index_util.h +++ b/src/share/vector_index/ob_vector_index_util.h @@ -748,6 +748,10 @@ public: const uint64_t tenant_id, const int64_t tablet_row_count, int64_t &estimate_memory); + static bool check_index_is_all_ready( + ObSchemaGetterGuard &schema_guard, + const schema::ObTableSchema &table_schema, + const schema::ObTableSchema &index_schema); static int alter_vec_aux_column_schema(const ObTableSchema &aux_table_schema, const ObColumnSchemaV2 &new_column_schema, ObColumnSchemaV2 &new_aux_column_schema); -- GitLab