Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
46ef8617
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
46ef8617
编写于
10月 25, 2020
作者:
T
tavplubix
提交者:
GitHub
10月 25, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16008 from zhang2014/fix/ISSUES-15883
ISSUES-15883 try fix collate name
上级
31b56b92
37de8727
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
29 addition
and
49 deletion
+29
-49
src/DataTypes/DataTypeString.cpp
src/DataTypes/DataTypeString.cpp
+1
-1
src/Parsers/MySQL/ASTAlterCommand.cpp
src/Parsers/MySQL/ASTAlterCommand.cpp
+3
-3
src/Parsers/MySQL/ASTDeclareColumn.cpp
src/Parsers/MySQL/ASTDeclareColumn.cpp
+2
-2
src/Parsers/MySQL/ASTDeclareOption.cpp
src/Parsers/MySQL/ASTDeclareOption.cpp
+10
-29
src/Parsers/MySQL/ASTDeclareOption.h
src/Parsers/MySQL/ASTDeclareOption.h
+3
-4
src/Parsers/MySQL/ASTDeclareTableOptions.cpp
src/Parsers/MySQL/ASTDeclareTableOptions.cpp
+4
-4
src/Parsers/MySQL/tests/gtest_column_parser.cpp
src/Parsers/MySQL/tests/gtest_column_parser.cpp
+4
-4
src/Parsers/MySQL/tests/gtest_table_options_parser.cpp
src/Parsers/MySQL/tests/gtest_table_options_parser.cpp
+2
-2
未找到文件。
src/DataTypes/DataTypeString.cpp
浏览文件 @
46ef8617
...
...
@@ -384,7 +384,7 @@ static DataTypePtr create(const ASTPtr & arguments)
throw
Exception
(
"String data type family mustn't have more than one argument - size in characters"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
auto
*
argument
=
arguments
->
children
[
0
]
->
as
<
ASTLiteral
>
();
if
(
!
argument
||
argument
->
value
.
getType
()
!=
Field
::
Types
::
UInt64
||
argument
->
value
.
get
<
UInt64
>
()
==
0
)
if
(
!
argument
||
argument
->
value
.
getType
()
!=
Field
::
Types
::
UInt64
)
throw
Exception
(
"String data type family may have only a number (positive integer) as its argument"
,
ErrorCodes
::
UNEXPECTED_AST_STRUCTURE
);
}
...
...
src/Parsers/MySQL/ASTAlterCommand.cpp
浏览文件 @
46ef8617
...
...
@@ -303,9 +303,9 @@ static inline bool parseOtherCommand(IParser::Pos & pos, ASTPtr & node, Expected
OptionDescribe
(
"ENABLE KEYS"
,
"enable_keys"
,
std
::
make_shared
<
ParserAlwaysTrue
>
()),
OptionDescribe
(
"DISABLE KEYS"
,
"enable_keys"
,
std
::
make_shared
<
ParserAlwaysFalse
>
()),
/// TODO: with collate
OptionDescribe
(
"CONVERT TO CHARACTER SET"
,
"charset"
,
std
::
make_shared
<
ParserCharsetName
>
()),
OptionDescribe
(
"CHARACTER SET"
,
"charset"
,
std
::
make_shared
<
ParserCharsetName
>
()),
OptionDescribe
(
"DEFAULT CHARACTER SET"
,
"charset"
,
std
::
make_shared
<
ParserCharsetName
>
()),
OptionDescribe
(
"CONVERT TO CHARACTER SET"
,
"charset"
,
std
::
make_shared
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"CHARACTER SET"
,
"charset"
,
std
::
make_shared
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"DEFAULT CHARACTER SET"
,
"charset"
,
std
::
make_shared
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"LOCK"
,
"lock"
,
std
::
make_shared
<
ParserIdentifier
>
())
}
};
...
...
src/Parsers/MySQL/ASTDeclareColumn.cpp
浏览文件 @
46ef8617
...
...
@@ -51,8 +51,8 @@ static inline bool parseColumnDeclareOptions(IParser::Pos & pos, ASTPtr & node,
OptionDescribe
(
"UNIQUE"
,
"unique_key"
,
std
::
make_unique
<
ParserAlwaysTrue
>
()),
OptionDescribe
(
"KEY"
,
"primary_key"
,
std
::
make_unique
<
ParserAlwaysTrue
>
()),
OptionDescribe
(
"COMMENT"
,
"comment"
,
std
::
make_unique
<
ParserStringLiteral
>
()),
OptionDescribe
(
"CHARACTER SET"
,
"charset_name"
,
std
::
make_unique
<
ParserCharsetName
>
()),
OptionDescribe
(
"COLLATE"
,
"collate"
,
std
::
make_unique
<
ParserCharsetName
>
()),
OptionDescribe
(
"CHARACTER SET"
,
"charset_name"
,
std
::
make_unique
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"COLLATE"
,
"collate"
,
std
::
make_unique
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"COLUMN_FORMAT"
,
"column_format"
,
std
::
make_unique
<
ParserIdentifier
>
()),
OptionDescribe
(
"STORAGE"
,
"storage"
,
std
::
make_unique
<
ParserIdentifier
>
()),
OptionDescribe
(
"AS"
,
"generated"
,
std
::
make_unique
<
ParserExpression
>
()),
...
...
src/Parsers/MySQL/ASTDeclareOption.cpp
浏览文件 @
46ef8617
...
...
@@ -4,6 +4,7 @@
#include <IO/ReadHelpers.h>
#include <Parsers/ASTIdentifier.h>
#include <Parsers/ASTLiteral.h>
#include <Parsers/ExpressionElementParsers.h>
namespace
DB
{
...
...
@@ -94,41 +95,21 @@ bool ParserAlwaysFalse::parseImpl(IParser::Pos & /*pos*/, ASTPtr & node, Expecte
return
true
;
}
bool
ParserCharset
Name
::
parseImpl
(
IParser
::
Pos
&
pos
,
ASTPtr
&
node
,
Expected
&
)
bool
ParserCharset
OrCollateName
::
parseImpl
(
IParser
::
Pos
&
pos
,
ASTPtr
&
node
,
Expected
&
expected
)
{
/// Identifier in backquotes or in double quotes
if
(
pos
->
type
==
TokenType
::
QuotedIdentifier
)
{
ReadBufferFromMemory
buf
(
pos
->
begin
,
pos
->
size
());
String
s
;
if
(
*
pos
->
begin
==
'`'
)
readBackQuotedStringWithSQLStyle
(
s
,
buf
);
else
readDoubleQuotedStringWithSQLStyle
(
s
,
buf
);
ParserIdentifier
p_identifier
;
ParserStringLiteral
p_string_literal
;
if
(
s
.
empty
())
/// Identifiers "empty string" are not allowed.
return
false
;
node
=
std
::
make_shared
<
ASTIdentifier
>
(
s
);
++
pos
;
if
(
p_identifier
.
parse
(
pos
,
node
,
expected
))
return
true
;
}
else
if
(
pos
->
type
==
TokenType
::
BareWord
)
else
{
const
char
*
begin
=
pos
->
begin
;
while
(
true
)
if
(
p_string_literal
.
parse
(
pos
,
node
,
expected
))
{
if
(
!
isWhitespaceASCII
(
*
pos
->
end
)
&&
pos
->
type
!=
TokenType
::
EndOfStream
)
++
pos
;
else
break
;
const
auto
&
string_value
=
node
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
String
>
();
node
=
std
::
make_shared
<
ASTIdentifier
>
(
string_value
);
return
true
;
}
node
=
std
::
make_shared
<
ASTIdentifier
>
(
String
(
begin
,
pos
->
end
));
++
pos
;
return
true
;
}
return
false
;
...
...
src/Parsers/MySQL/ASTDeclareOption.h
浏览文件 @
46ef8617
...
...
@@ -59,12 +59,11 @@ public:
bool
parseImpl
(
Pos
&
pos
,
ASTPtr
&
node
,
Expected
&
expected
)
override
;
};
/// Copy and paste from ParserIdentifier,
/// the difference is that multiple tokens are glued if there is no whitespace ASCII between them
struct
ParserCharsetName
:
public
IParserBase
/// identifier, string literal, binary keyword
struct
ParserCharsetOrCollateName
:
public
IParserBase
{
protected:
const
char
*
getName
()
const
override
{
return
"charset name"
;
}
const
char
*
getName
()
const
override
{
return
"charset
or collate
name"
;
}
bool
parseImpl
(
Pos
&
pos
,
ASTPtr
&
node
,
Expected
&
)
override
;
};
...
...
src/Parsers/MySQL/ASTDeclareTableOptions.cpp
浏览文件 @
46ef8617
...
...
@@ -68,12 +68,12 @@ bool ParserDeclareTableOptions::parseImpl(IParser::Pos & pos, ASTPtr & node, Exp
{
OptionDescribe
(
"AUTO_INCREMENT"
,
"auto_increment"
,
std
::
make_shared
<
ParserLiteral
>
()),
OptionDescribe
(
"AVG_ROW_LENGTH"
,
"avg_row_length"
,
std
::
make_shared
<
ParserLiteral
>
()),
OptionDescribe
(
"CHARSET"
,
"character_set"
,
std
::
make_shared
<
ParserCharsetName
>
()),
OptionDescribe
(
"DEFAULT CHARSET"
,
"character_set"
,
std
::
make_shared
<
ParserCharsetName
>
()),
OptionDescribe
(
"CHARACTER SET"
,
"character_set"
,
std
::
make_shared
<
ParserCharsetName
>
()),
OptionDescribe
(
"CHARSET"
,
"character_set"
,
std
::
make_shared
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"DEFAULT CHARSET"
,
"character_set"
,
std
::
make_shared
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"CHARACTER SET"
,
"character_set"
,
std
::
make_shared
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"DEFAULT CHARACTER SET"
,
"character_set"
,
std
::
make_shared
<
ParserIdentifier
>
()),
OptionDescribe
(
"CHECKSUM"
,
"checksum"
,
std
::
make_shared
<
ParserBoolOption
<
false
>>
()),
OptionDescribe
(
"COLLATE"
,
"collate"
,
std
::
make_shared
<
ParserCharsetName
>
()),
OptionDescribe
(
"COLLATE"
,
"collate"
,
std
::
make_shared
<
ParserCharset
OrCollate
Name
>
()),
OptionDescribe
(
"DEFAULT COLLATE"
,
"collate"
,
std
::
make_shared
<
ParserIdentifier
>
()),
OptionDescribe
(
"COMMENT"
,
"comment"
,
std
::
make_shared
<
ParserStringLiteral
>
()),
OptionDescribe
(
"COMPRESSION"
,
"compression"
,
std
::
make_shared
<
ParserStringLiteral
>
()),
...
...
src/Parsers/MySQL/tests/gtest_column_parser.cpp
浏览文件 @
46ef8617
...
...
@@ -15,7 +15,7 @@ TEST(ParserColumn, AllNonGeneratedColumnOption)
{
ParserDeclareColumn
p_column
;
String
input
=
"col_01 VARCHAR(100) NOT NULL DEFAULT NULL AUTO_INCREMENT UNIQUE KEY PRIMARY KEY COMMENT 'column comment' COLLATE utf
-
8 "
String
input
=
"col_01 VARCHAR(100) NOT NULL DEFAULT NULL AUTO_INCREMENT UNIQUE KEY PRIMARY KEY COMMENT 'column comment' COLLATE utf8 "
"COLUMN_FORMAT FIXED STORAGE MEMORY REFERENCES tbl_name (col_01) CHECK 1"
;
ASTPtr
ast
=
parseQuery
(
p_column
,
input
.
data
(),
input
.
data
()
+
input
.
size
(),
""
,
0
,
0
);
EXPECT_EQ
(
ast
->
as
<
ASTDeclareColumn
>
()
->
name
,
"col_01"
);
...
...
@@ -29,7 +29,7 @@ TEST(ParserColumn, AllNonGeneratedColumnOption)
EXPECT_EQ
(
declare_options
->
changes
[
"unique_key"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_EQ
(
declare_options
->
changes
[
"primary_key"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_EQ
(
declare_options
->
changes
[
"comment"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
DB
::
String
>
(),
"column comment"
);
EXPECT_EQ
(
declare_options
->
changes
[
"collate"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"utf
-
8"
);
EXPECT_EQ
(
declare_options
->
changes
[
"collate"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"utf8"
);
EXPECT_EQ
(
declare_options
->
changes
[
"column_format"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"FIXED"
);
EXPECT_EQ
(
declare_options
->
changes
[
"storage"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"MEMORY"
);
EXPECT_TRUE
(
declare_options
->
changes
[
"reference"
]
->
as
<
ASTDeclareReference
>
());
...
...
@@ -40,7 +40,7 @@ TEST(ParserColumn, AllGeneratedColumnOption)
{
ParserDeclareColumn
p_column
;
String
input
=
"col_01 VARCHAR(100) NULL UNIQUE KEY PRIMARY KEY COMMENT 'column comment' COLLATE utf
-
8 "
String
input
=
"col_01 VARCHAR(100) NULL UNIQUE KEY PRIMARY KEY COMMENT 'column comment' COLLATE utf8 "
"REFERENCES tbl_name (col_01) CHECK 1 GENERATED ALWAYS AS (1) STORED"
;
ASTPtr
ast
=
parseQuery
(
p_column
,
input
.
data
(),
input
.
data
()
+
input
.
size
(),
""
,
0
,
0
);
EXPECT_EQ
(
ast
->
as
<
ASTDeclareColumn
>
()
->
name
,
"col_01"
);
...
...
@@ -52,7 +52,7 @@ TEST(ParserColumn, AllGeneratedColumnOption)
EXPECT_EQ
(
declare_options
->
changes
[
"unique_key"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_EQ
(
declare_options
->
changes
[
"primary_key"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_EQ
(
declare_options
->
changes
[
"comment"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
DB
::
String
>
(),
"column comment"
);
EXPECT_EQ
(
declare_options
->
changes
[
"collate"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"utf
-
8"
);
EXPECT_EQ
(
declare_options
->
changes
[
"collate"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"utf8"
);
EXPECT_EQ
(
declare_options
->
changes
[
"generated"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_EQ
(
declare_options
->
changes
[
"is_stored"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_TRUE
(
declare_options
->
changes
[
"reference"
]
->
as
<
ASTDeclareReference
>
());
...
...
src/Parsers/MySQL/tests/gtest_table_options_parser.cpp
浏览文件 @
46ef8617
...
...
@@ -11,7 +11,7 @@ using namespace DB::MySQLParser;
TEST
(
ParserTableOptions
,
AllSubpatitionOptions
)
{
String
input
=
"AUTO_INCREMENt = 1 AVG_ROW_LENGTh 3 CHARACTER SET utf
-
8 CHECKSUM 1 COLLATE utf8_bin"
String
input
=
"AUTO_INCREMENt = 1 AVG_ROW_LENGTh 3 CHARACTER SET utf8 CHECKSUM 1 COLLATE utf8_bin"
" COMMENT 'table option comment' COMPRESSION 'LZ4' CONNECTION 'connect_string' DATA DIRECTORY 'data_directory'"
" INDEX DIRECTORY 'index_directory' DELAY_KEY_WRITE 0 ENCRYPTION 'Y' ENGINE INNODB INSERT_METHOD NO KEY_BLOCK_SIZE 3"
" MAX_ROWS 1000 MIN_ROWS 0 PACK_KEYS DEFAULT PASSWORD 'password' ROW_FORMAT DYNAMIC STATS_AUTO_RECALC DEFAULT "
...
...
@@ -23,7 +23,7 @@ TEST(ParserTableOptions, AllSubpatitionOptions)
ASTDeclareOptions
*
declare_options
=
ast
->
as
<
ASTDeclareOptions
>
();
EXPECT_EQ
(
declare_options
->
changes
[
"auto_increment"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_EQ
(
declare_options
->
changes
[
"avg_row_length"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
3
);
EXPECT_EQ
(
declare_options
->
changes
[
"character_set"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"utf
-
8"
);
EXPECT_EQ
(
declare_options
->
changes
[
"character_set"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"utf8"
);
EXPECT_EQ
(
declare_options
->
changes
[
"checksum"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
UInt64
>
(),
1
);
EXPECT_EQ
(
declare_options
->
changes
[
"collate"
]
->
as
<
ASTIdentifier
>
()
->
name
(),
"utf8_bin"
);
EXPECT_EQ
(
declare_options
->
changes
[
"comment"
]
->
as
<
ASTLiteral
>
()
->
value
.
safeGet
<
String
>
(),
"table option comment"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录