change error code to BAD_ARGUMENTS (36)

This commit is contained in:
bharatnc 2020-08-31 08:58:31 -07:00
parent 59edda2e94
commit caed8cd474
3 changed files with 8 additions and 7 deletions

View File

@ -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);
}

View File

@ -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> 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> AlterCommand::parse(const ASTAlterCommand * command_
command.if_exists = command_ast->if_exists;
return command;
}
}
else
return {};
}

View File

@ -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