Revert "Revert "refine error code of duplicated index in create query""

This commit is contained in:
Han Fei 2023-10-10 15:44:15 +02:00 committed by GitHub
parent 5ded0005a3
commit 3757bcf2cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -96,6 +96,7 @@ namespace ErrorCodes
extern const int SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY; extern const int SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY;
extern const int ILLEGAL_SYNTAX_FOR_DATA_TYPE; extern const int ILLEGAL_SYNTAX_FOR_DATA_TYPE;
extern const int ILLEGAL_COLUMN; extern const int ILLEGAL_COLUMN;
extern const int ILLEGAL_INDEX;
extern const int LOGICAL_ERROR; extern const int LOGICAL_ERROR;
extern const int UNKNOWN_DATABASE; extern const int UNKNOWN_DATABASE;
extern const int PATH_ACCESS_DENIED; extern const int PATH_ACCESS_DENIED;
@ -698,6 +699,8 @@ InterpreterCreateQuery::TableProperties InterpreterCreateQuery::getTableProperti
for (const auto & index : create.columns_list->indices->children) for (const auto & index : create.columns_list->indices->children)
{ {
IndexDescription index_desc = IndexDescription::getIndexFromAST(index->clone(), properties.columns, getContext()); IndexDescription index_desc = IndexDescription::getIndexFromAST(index->clone(), properties.columns, getContext());
if (properties.indices.has(index_desc.name))
throw Exception(ErrorCodes::ILLEGAL_INDEX, "Duplicated index name {}", backQuoteIfNeed(index_desc.name));
const auto & settings = getContext()->getSettingsRef(); const auto & settings = getContext()->getSettingsRef();
if (index_desc.type == INVERTED_INDEX_NAME && !settings.allow_experimental_inverted_index) if (index_desc.type == INVERTED_INDEX_NAME && !settings.allow_experimental_inverted_index)
{ {
@ -712,6 +715,7 @@ InterpreterCreateQuery::TableProperties InterpreterCreateQuery::getTableProperti
properties.indices.push_back(index_desc); properties.indices.push_back(index_desc);
} }
if (create.columns_list->projections) if (create.columns_list->projections)
for (const auto & projection_ast : create.columns_list->projections->children) for (const auto & projection_ast : create.columns_list->projections->children)
{ {

View File

@ -0,0 +1,10 @@
DROP TABLE IF EXISTS test_dup_index;
CREATE TABLE test_dup_index
(
a Int64,
b Int64,
INDEX idx_a a TYPE minmax,
INDEX idx_a b TYPE minmax
) Engine = MergeTree()
ORDER BY a; -- { serverError ILLEGAL_INDEX }