Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
clmforever
oceanbase
提交
cb791d88
O
oceanbase
项目概览
clmforever
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cb791d88
编写于
8月 25, 2021
作者:
D
ds0
提交者:
wangzelin.wzl
8月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adaptive comment
上级
61b6d056
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
47448 addition
and
118542 deletion
+47448
-118542
src/sql/parser/ob_parser.cpp
src/sql/parser/ob_parser.cpp
+8
-0
src/sql/parser/parse_node.h
src/sql/parser/parse_node.h
+2
-0
src/sql/parser/sql_parser_mysql_mode.l
src/sql/parser/sql_parser_mysql_mode.l
+43
-0
src/sql/parser/sql_parser_mysql_mode_lex.c
src/sql/parser/sql_parser_mysql_mode_lex.c
+47391
-47088
src/sql/parser/sql_parser_mysql_mode_lex.h
src/sql/parser/sql_parser_mysql_mode_lex.h
+3
-71453
src/sql/parser/type_name.c
src/sql/parser/type_name.c
+1
-1
未找到文件。
src/sql/parser/ob_parser.cpp
浏览文件 @
cb791d88
...
...
@@ -250,6 +250,14 @@ int ObParser::parse(
ObCharset
::
is_valid_collation
(
connection_collation_
)
?
(
ObCharset
::
charset_type_by_coll
(
connection_collation_
)
!=
CHARSET_UTF8MB4
)
:
false
;
parse_result
.
malloc_pool_
=
allocator_
;
parse_result
.
sql_mode_
=
sql_mode_
;
parse_result
.
need_parameterize_
=
(
FP_MODE
==
parse_mode
||
FP_PARAMERIZE_AND_FILTER_HINT_MODE
==
parse_mode
);
parse_result
.
minus_ctx_
.
pos_
=
-
1
;
parse_result
.
minus_ctx_
.
raw_sql_offset_
=
-
1
;
parse_result
.
charset_info_
=
ObCharset
::
get_charset
(
connection_collation_
);
parse_result
.
connection_collation_
=
connection_collation_
;
parse_result
.
mysql_compatible_comment_
=
false
;
if
(
parse_result
.
is_fp_
||
parse_result
.
is_dynamic_sql_
)
{
int64_t
new_length
=
parse_result
.
is_fp_
?
stmt
.
length
()
+
1
:
stmt
.
length
()
*
2
;
...
...
src/sql/parser/parse_node.h
浏览文件 @
cb791d88
...
...
@@ -249,6 +249,8 @@ typedef struct {
const
struct
ObCharsetInfo
*
charset_info_
;
int
last_well_formed_len_
;
bool
may_bool_value_
;
// used for true/false in sql parser
int
connection_collation_
;
// connection collation
bool
mysql_compatible_comment_
;
// whether the parser is parsing "/*! xxxx */"
#ifdef SQL_PARSER_COMPILATION
TokenPosInfo
*
comment_list_
;
...
...
src/sql/parser/sql_parser_mysql_mode.l
浏览文件 @
cb791d88
...
...
@@ -10,6 +10,9 @@
* See the Mulan PubL v2 for more details.
*/
/* unput() change the yyin but it doesn't change ParserResult->input_sql_.
// use unput() function may have unexpected result while copy string.
*/
%option noyywrap nounput noinput nodefault case-insensitive
%option noyyalloc noyyrealloc noyyfree
%option reentrant bison-bridge bison-locations
...
...
@@ -84,6 +87,10 @@ btend {backtick}
btdouble {backtick}{backtick}
btcontent [^`]+
mysql_compatible_comment_with_version \/\*\![0-9]{5}
mysql_compatible_comment_without_version \/\*\!
mysql_compatible_comment_end \*\/
rowidPattern (WITH{whitespace}ROWID)
%%
...
...
@@ -1139,6 +1146,14 @@ Timestamp{whitespace}?\"[^\"]*\" {
}
}
{mysql_compatible_comment_without_version} {
// if is a mysql comment without version. For example, /*!any sql str*/
// mysql_comment without version, processed as common sql str;
// place before `c_cmt_begin` to avoid (the '/*!') being hidden by '/*')
ParseResult *p = (ParseResult *)yyextra;
p->mysql_compatible_comment_ = true;
}
{c_cmt_begin} {
BEGIN(in_c_comment);
#ifdef SQL_PARSER_COMPILATION
...
...
@@ -1171,6 +1186,25 @@ BEGIN(in_c_comment);
#endif
}
{mysql_compatible_comment_end} {
//for mysql compatible comment:
// only "*/" should be matched, duplicated '*' (e.g., "***/") will report a error.
ParseResult *p = (ParseResult *)yyextra;
if (p->mysql_compatible_comment_){
p->mysql_compatible_comment_ = false;
BEGIN(INITIAL);
} else {
// The sql could be "select */*!xxx*/ from t1;". We can't directly raise a syntax
// error here. We should treat the "*/" as '*' and '/' by return '*' and unput '/';
// yyless will change the yytext and yyleng.
char c_ret = yytext[0];
yyless(1);
p->yycolumn_ = p->yycolumn_ - 1;
return c_ret;
}
}
<in_c_comment><<EOF>> {
yyerror(yylloc, yyextra, "unterminated log_level string\n");
return PARSER_SYNTAX_ERROR;
...
...
@@ -1401,6 +1435,15 @@ BEGIN(in_c_comment);
}
}
{mysql_compatible_comment_with_version} {
// comment with version: /*!50600 any sql str*/
// comment without version: /*!any sql str*/
// we do not add a start_condition, since some sql string need to be processed in INITIAL state.
// instead of a new start_condition, we use a extra field (mysql_compatible_comment_) to mark the adaptive comment.
ParseResult *p = (ParseResult *)yyextra;
p->mysql_compatible_comment_ = true;
}
[\n] {
yylineno ++;
if (IS_FAST_PARAMETERIZE) {
...
...
src/sql/parser/sql_parser_mysql_mode_lex.c
浏览文件 @
cb791d88
此差异已折叠。
点击以展开。
src/sql/parser/sql_parser_mysql_mode_lex.h
浏览文件 @
cb791d88
此差异已折叠。
点击以展开。
src/sql/parser/type_name.c
浏览文件 @
cb791d88
...
...
@@ -320,7 +320,6 @@ const char* get_type_name(int type)
case
T_FUN_SYS_TIME_TO_SEC
:
return
"T_FUN_SYS_TIME_TO_SEC"
;
case
T_FUN_SYS_SEC_TO_TIME
:
return
"T_FUN_SYS_SEC_TO_TIME"
;
case
T_FUN_SYS_INTERVAL
:
return
"T_FUN_SYS_INTERVAL"
;
case
T_FUN_SYS_CONVERT_TZ
:
return
"T_FUN_SYS_CONVERT_TZ"
;
case
T_FUN_UDF
:
return
"T_FUN_UDF"
;
case
T_FUN_SYS_SUBTIME
:
return
"T_FUN_SYS_SUBTIME"
;
case
T_FUN_SYS_SQRT
:
return
"T_FUN_SYS_SQRT"
;
...
...
@@ -520,6 +519,7 @@ const char* get_type_name(int type)
case
T_FUN_SYS_UTC_TIME
:
return
"T_FUN_SYS_UTC_TIME"
;
case
T_FUN_SYS_UTC_DATE
:
return
"T_FUN_SYS_UTC_DATE"
;
case
T_FUN_SYS_TIME_FORMAT
:
return
"T_FUN_SYS_TIME_FORMAT"
;
case
T_FUN_SYS_CONVERT_TZ
:
return
"T_FUN_SYS_CONVERT_TZ"
;
case
T_FUN_SYS_END
:
return
"T_FUN_SYS_END"
;
case
T_MAX_OP
:
return
"T_MAX_OP"
;
case
T_FUN_MATCH_AGAINST
:
return
"T_FUN_MATCH_AGAINST"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录