From caed8cd474f207fdac34597e3601cb62094b811d Mon Sep 17 00:00:00 2001 From: bharatnc Date: Mon, 31 Aug 2020 08:58:31 -0700 Subject: [PATCH] change error code to BAD_ARGUMENTS (36) --- src/Interpreters/InterpreterCreateQuery.cpp | 3 ++- src/Storages/AlterCommands.cpp | 4 ++-- tests/queries/0_stateless/01462_test_codec_on_alias.sql | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Interpreters/InterpreterCreateQuery.cpp b/src/Interpreters/InterpreterCreateQuery.cpp index 51fecfc0936..06973ab029b 100644 --- a/src/Interpreters/InterpreterCreateQuery.cpp +++ b/src/Interpreters/InterpreterCreateQuery.cpp @@ -67,6 +67,7 @@ namespace ErrorCodes extern const int UNKNOWN_DATABASE_ENGINE; extern const int DUPLICATE_COLUMN; extern const int DATABASE_ALREADY_EXISTS; + extern const int BAD_ARGUMENTS; extern const int BAD_DATABASE_FOR_TEMPORARY_TABLE; extern const int SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY; extern const int DICTIONARY_ALREADY_EXISTS; @@ -414,7 +415,7 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription( if (col_decl.codec) { if (col_decl.default_specifier == "ALIAS") - throw Exception{"Cannot specify codec for column type ALIAS", ErrorCodes::ILLEGAL_SYNTAX_FOR_DATA_TYPE}; + throw Exception{"Cannot specify codec for column type ALIAS", ErrorCodes::BAD_ARGUMENTS}; column.codec = CompressionCodecFactory::instance().validateCodecAndGetPreprocessedAST( col_decl.codec, column.type, sanity_check_compression_codecs); } diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp index cb95e2bbdd1..9e79bb09811 100644 --- a/src/Storages/AlterCommands.cpp +++ b/src/Storages/AlterCommands.cpp @@ -41,7 +41,6 @@ namespace ErrorCodes extern const int LOGICAL_ERROR; extern const int DUPLICATE_COLUMN; extern const int NOT_IMPLEMENTED; - extern const int ILLEGAL_SYNTAX_FOR_DATA_TYPE; } @@ -77,7 +76,7 @@ std::optional AlterCommand::parse(const ASTAlterCommand * command_ if (ast_col_decl.codec) { if (ast_col_decl.default_specifier == "ALIAS") - throw Exception{ "Cannot specify codec for column type ALIAS", ErrorCodes::ILLEGAL_SYNTAX_FOR_DATA_TYPE}; + throw Exception{"Cannot specify codec for column type ALIAS", ErrorCodes::BAD_ARGUMENTS}; command.codec = ast_col_decl.codec; } if (command_ast->column) @@ -264,6 +263,7 @@ std::optional AlterCommand::parse(const ASTAlterCommand * command_ command.if_exists = command_ast->if_exists; return command; } + } else return {}; } diff --git a/tests/queries/0_stateless/01462_test_codec_on_alias.sql b/tests/queries/0_stateless/01462_test_codec_on_alias.sql index 7b93fb5b4d3..06a82c61b9e 100644 --- a/tests/queries/0_stateless/01462_test_codec_on_alias.sql +++ b/tests/queries/0_stateless/01462_test_codec_on_alias.sql @@ -5,7 +5,7 @@ select 'create table compression_codec_on_alias with CODEC on ALIAS type'; CREATE TABLE compression_codec_on_alias ( `c0` ALIAS c1 CODEC(ZSTD), c1 UInt64 -) ENGINE = MergeTree() PARTITION BY c0 ORDER BY c1; -- { serverError 377 } +) ENGINE = MergeTree() PARTITION BY c0 ORDER BY c1; -- { serverError 36 } select 'create table compression_codec_on_alias with proper CODEC'; @@ -14,11 +14,11 @@ CREATE TABLE compression_codec_on_alias ( c1 UInt64 ) ENGINE = MergeTree() PARTITION BY c0 ORDER BY c1; -- success -select 'alter table compression_codec_on_alias add column (ALIAS) with CODEC'; +select 'alter table compression_codec_on_alias add column (ALIAS type) with CODEC'; -ALTER TABLE compression_codec_on_alias ADD COLUMN `c3` ALIAS c2 CODEC(ZSTD) AFTER c2; -- { serverError 377} +ALTER TABLE compression_codec_on_alias ADD COLUMN `c3` ALIAS c2 CODEC(ZSTD) AFTER c2; -- { serverError 36 } -select 'alter table compression_codec_on_alias add column (NOT ALIAS) with CODEC'; +select 'alter table compression_codec_on_alias add column (NOT ALIAS type) with CODEC'; ALTER TABLE compression_codec_on_alias ADD COLUMN c2 UInt64 CODEC(ZSTD) AFTER c1; -- success