Fix style warnings and review comments

This commit is contained in:
Igor Nikonov 2022-05-13 11:27:17 +00:00
parent f423e9bf40
commit 8d5cabc8f7
4 changed files with 49 additions and 12 deletions

View File

@ -98,6 +98,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ENGINE_REQUIRED;
extern const int UNKNOWN_STORAGE;
extern const int SYNTAX_ERROR;
}
namespace fs = std::filesystem;

View File

@ -209,7 +209,8 @@ bool IParserColumnDeclaration<NameParser>::parseImpl(Pos & pos, ASTPtr & node, E
{
default_specifier = s_auto_increment.getName();
/// if type is not provided for a column with AUTO_INCREMENT then using INT by default
if (!type) {
if (!type)
{
const String type_int("INT");
Tokens tokens(type_int.data(), type_int.data() + type_int.size());
Pos tmp_pos(tokens, 0);

View File

@ -1,11 +1,18 @@
disable AUTO_INCREMENT compatibility mode
create table with AUTO_INCREMENT, compatibility disabled
create table failed, column +type +AUTO_INCREMENT, compatibility disabled
enable AUTO_INCREMENT compatibility mode
create table with AUTO_INCREMENT
create table with AUTO_INCREMENT, without column type
create table, +type +AUTO_INCREMENT
create table, column +AUTO_INCREMENT -type
id Int32
create table with several AUTO_INCREMENT
create table, several columns +/-type +AUTO_INCREMENT
id Int32
di Int32
s String
disable AUTO_INCREMENT compatibility mode
create table, several columns with different default specifiers
di UInt8 DEFAULT 1
id Int32
s String EPHEMERAL \'\'
create table failed, column +type +DEFAULT +AUTO_INCREMENT
create table failed, column -type +DEFAULT +AUTO_INCREMENT
create table failed, column +type +AUTO_INCREMENT +DEFAULT
create table failed, column -type +AUTO_INCREMENT +DEFAULT

View File

@ -1,7 +1,7 @@
select 'disable AUTO_INCREMENT compatibility mode';
set compatibility_ignore_auto_increment_in_create_table=false;
select 'create table with AUTO_INCREMENT, compatibility disabled';
select 'create table failed, column +type +AUTO_INCREMENT, compatibility disabled';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id int AUTO_INCREMENT
@ -10,27 +10,55 @@ CREATE TABLE ignore_auto_increment (
select 'enable AUTO_INCREMENT compatibility mode';
set compatibility_ignore_auto_increment_in_create_table=true;
select 'create table with AUTO_INCREMENT';
select 'create table, +type +AUTO_INCREMENT';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id int AUTO_INCREMENT
) ENGINE=MergeTree() ORDER BY tuple();
select 'create table with AUTO_INCREMENT, without column type';
select 'create table, column +AUTO_INCREMENT -type';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id AUTO_INCREMENT
) ENGINE=MergeTree() ORDER BY tuple();
DESCRIBE TABLE ignore_auto_increment;
select 'create table with several AUTO_INCREMENT';
select 'create table, several columns +/-type +AUTO_INCREMENT';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id int AUTO_INCREMENT, di AUTO_INCREMENT, s String AUTO_INCREMENT
) ENGINE=MergeTree() ORDER BY tuple();
DESCRIBE TABLE ignore_auto_increment;
select 'disable AUTO_INCREMENT compatibility mode';
set compatibility_ignore_auto_increment_in_create_table=false;
select 'create table, several columns with different default specifiers';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
di DEFAULT 1, id int AUTO_INCREMENT, s String EPHEMERAL
) ENGINE=MergeTree() ORDER BY tuple();
DESCRIBE TABLE ignore_auto_increment;
select 'create table failed, column +type +DEFAULT +AUTO_INCREMENT';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id int DEFAULT 1 AUTO_INCREMENT
) ENGINE=MergeTree() ORDER BY tuple(); -- {serverError SYNTAX_ERROR}
select 'create table failed, column -type +DEFAULT +AUTO_INCREMENT';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id int DEFAULT 1 AUTO_INCREMENT
) ENGINE=MergeTree() ORDER BY tuple(); -- {serverError SYNTAX_ERROR}
select 'create table failed, column +type +AUTO_INCREMENT +DEFAULT';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id int AUTO_INCREMENT DEFAULT 1
) ENGINE=MergeTree() ORDER BY tuple(); -- {serverError SYNTAX_ERROR}
select 'create table failed, column -type +AUTO_INCREMENT +DEFAULT';
DROP TABLE IF EXISTS ignore_auto_increment SYNC;
CREATE TABLE ignore_auto_increment (
id int AUTO_INCREMENT DEFAULT 1
) ENGINE=MergeTree() ORDER BY tuple(); -- {serverError SYNTAX_ERROR}
DROP TABLE IF EXISTS ignore_auto_increment SYNC;