Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
d1aa3c5d
O
oceanbase
项目概览
Metz
/
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看板
提交
d1aa3c5d
编写于
5月 05, 2022
作者:
M
Monk-Liu
提交者:
wangzelin.wzl
5月 05, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CP] [bugfix][errcode]: avoid -4013 errcode being overwritten in parser.
上级
d647b8f1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
41 deletion
+50
-41
src/sql/parser/ob_non_reserved_keywords.c
src/sql/parser/ob_non_reserved_keywords.c
+1
-1
src/sql/parser/ob_sql_parser.cpp
src/sql/parser/ob_sql_parser.cpp
+9
-7
src/sql/parser/sql_parser_base.h
src/sql/parser/sql_parser_base.h
+17
-16
src/sql/parser/sql_parser_mysql_mode.l
src/sql/parser/sql_parser_mysql_mode.l
+20
-15
src/sql/parser/sql_parser_mysql_mode.y
src/sql/parser/sql_parser_mysql_mode.y
+3
-2
未找到文件。
src/sql/parser/ob_non_reserved_keywords.c
浏览文件 @
d1aa3c5d
...
...
@@ -63,7 +63,7 @@ int add_word(t_node* root, const char* str, const int32_t idx)
if
(
ch_id
>=
0
&&
NULL
==
pt
->
next
[
ch_id
])
{
t_node
*
new_node
=
(
t_node
*
)
calloc
(
1
,
sizeof
(
t_node
));
if
(
OB_UNLIKELY
(
NULL
==
new_node
))
{
ret
=
1
;
ret
=
OB_PARSER_ERR_NO_MEMORY
;
printf
(
"ERROR malloc memory failed!
\n
"
);
}
else
{
new_node
->
idx
=
-
1
;
...
...
src/sql/parser/ob_sql_parser.cpp
浏览文件 @
d1aa3c5d
...
...
@@ -59,13 +59,15 @@ int ObSQLParser::parse_and_gen_sqlid(
int64_t
new_length
=
str_len
+
1
;
char
*
buf
=
(
char
*
)
parse_malloc
(
new_length
,
parse_result
->
malloc_pool_
);
parse_result
->
param_nodes_
=
NULL
;
parse_result
->
tail_param_node_
=
NULL
;
parse_result
->
no_param_sql_
=
buf
;
parse_result
->
no_param_sql_buf_len_
=
new_length
;
ret
=
parse
(
str_ptr
,
new_length
,
*
parse_result
);
if
(
OB_UNLIKELY
(
NULL
==
buf
))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
}
else
{
parse_result
->
param_nodes_
=
NULL
;
parse_result
->
tail_param_node_
=
NULL
;
parse_result
->
no_param_sql_
=
buf
;
parse_result
->
no_param_sql_buf_len_
=
new_length
;
ret
=
parse
(
str_ptr
,
new_length
,
*
parse_result
);
}
if
(
OB_SUCC
(
ret
))
{
ret
=
gen_sqlid
(
parse_result
->
no_param_sql_
,
parse_result
->
no_param_sql_len_
,
len
,
sql_id
);
...
...
src/sql/parser/sql_parser_base.h
浏览文件 @
d1aa3c5d
...
...
@@ -377,7 +377,7 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
char* dest = NULL; \
size_t len = end - begin - 1; \
dest = parse_strndup(begin + 1, len, malloc_pool); \
check_
value(dest);
\
check_
malloc(dest);
\
node->str_value_ = dest; \
node->str_len_ = len; \
check_value(yylval); \
...
...
@@ -396,13 +396,13 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
} \
} while (0);
#define check_malloc(val_ptr
, nbyte)
\
do {
\
if (OB_UNLIKELY(NULL == val_ptr)) {
\
((ParseResult
*)yyextra)->extra_errno_ = OB_PARSER_ERR_NO_MEMORY;
\
yyerror(yylloc, yyextra, "No more space for malloc
(size: %ld)\n", (size_t)nbyte);
\
return ERROR;
\
}
\
#define check_malloc(val_ptr
)
\
do { \
if (OB_UNLIKELY(NULL == val_ptr)) { \
((ParseResult
*)yyextra)->extra_errno_ = OB_PARSER_ERR_NO_MEMORY;
\
yyerror(yylloc, yyextra, "No more space for malloc
\n");
\
return ERROR; \
} \
} while (0);
#define check_identifier_convert_result(errno) \
...
...
@@ -424,7 +424,7 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
} else { \
ParseResult* p = (ParseResult*)yyextra; \
dst = parse_strndup(src, src_len, p->malloc_pool_); \
check_
value(dst);
\
check_
malloc(dst);
\
} \
} while (0);
...
...
@@ -434,7 +434,7 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
char** tmp_literal = &(p->tmp_literal_); \
if (NULL == *tmp_literal) { \
*tmp_literal = (char*)parse_malloc(p->input_sql_len_ + 1, p->malloc_pool_); \
check_
value
(*tmp_literal); \
check_
malloc
(*tmp_literal); \
} \
if (str_node->str_value_ != NULL) { \
memmove(((ParseResult*)yyextra)->tmp_literal_, str_node->str_value_, str_node->str_len_); \
...
...
@@ -452,7 +452,7 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
char** tmp_literal = &(p->tmp_literal_); \
if (NULL == *tmp_literal) { \
*tmp_literal = (char*)parse_malloc(p->input_sql_len_ + 1, p->malloc_pool_); \
check_
value
(*tmp_literal); \
check_
malloc
(*tmp_literal); \
} \
memmove(*tmp_literal + str_node->str_len_, yytext, yyleng); \
str_node->str_len_ += yyleng; \
...
...
@@ -466,7 +466,7 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
char* tmp_literal = p->tmp_literal_; \
tmp_literal[yylval->node->str_len_] = '\0'; \
str_node->str_value_ = parse_strndup(tmp_literal, str_node->str_len_ + 1, p->malloc_pool_); \
check_
value(str_node->str_value_);
\
check_
malloc(str_node->str_value_);
\
} \
} while (0);
...
...
@@ -509,8 +509,8 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
} \
p->no_param_sql_[p->no_param_sql_len_] = '\0'; \
size_t alloc_len = sizeof(ParamList); \
ParamList
* param = (ParamList*)parse_malloc(alloc_len, p->malloc_pool_);
\
check_malloc(param
, alloc_len);
\
ParamList
*param = (ParamList *)parse_malloc(alloc_len, p->malloc_pool_);
\
check_malloc(param
);
\
check_value(yylval); \
check_value(yylval->node); \
yylval->node->pos_ = p->no_param_sql_len_ - 1; \
...
...
@@ -546,9 +546,9 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
yylval->node = node; \
yylval->node->raw_text_ = \
parse_strdup(yytext, ((ParseResult*)yyextra)->malloc_pool_, &(yylval->node->text_len_)); \
check_
value
(yylval->node->raw_text_); \
check_
malloc
(yylval->node->raw_text_); \
node->str_value_ = parse_strdup((char*)str_val, ((ParseResult*)yyextra)->malloc_pool_, &(node->str_len_)); \
check_
value
(node->str_value_); \
check_
malloc
(node->str_value_); \
node->value_ = strtoll(node->str_value_, NULL, 10); \
STORE_PARAM_NODE() \
} else { \
...
...
@@ -656,6 +656,7 @@ extern ParseNode* new_node(void* malloc_pool, ObItemType type, int num);
if ('-' == param_node->str_value_[0]) { \
char* copied_str = parse_strndup(param_node->str_value_, param_node->str_len_, malloc_pool); \
if (OB_ISNULL(copied_str)) { \
((ParseResult *)yyextra)->extra_errno_ = OB_PARSER_ERR_NO_MEMORY; \
yyerror(NULL, yyextra, "No more space for mallocing"); \
return ERROR; \
} else { \
...
...
src/sql/parser/sql_parser_mysql_mode.l
浏览文件 @
d1aa3c5d
...
...
@@ -435,7 +435,7 @@ NULL {
check_value(yylval);
yylval->node = node;
node->str_value_ = parse_strdup(yytext, p->malloc_pool_, &(node->str_len_));
check_
value
(node->str_value_);
check_
malloc
(node->str_value_);
int err_no = 0;
node->value_ = ob_strntoll(node->str_value_, node->str_len_, 10, NULL, &err_no);
if (ERANGE == err_no)
...
...
@@ -619,6 +619,7 @@ FALSE {
malloc_new_node(yylval->node->children_[0], p->malloc_pool_, T_CONCAT_STRING, 0);
(*yylval->node->children_)->str_value_ = parse_strndup(tmp_literal, yylval->node->str_len_ + 1,
p->malloc_pool_);
check_malloc((*yylval->node->children_)->str_value_);
(*yylval->node->children_)->str_len_ = yylval->node->str_len_;
yylval->node->num_child_ = 1;
}
...
...
@@ -648,7 +649,7 @@ FALSE {
if (*tmp_literal == NULL)
{
*tmp_literal = (char*) parse_malloc(p->input_sql_len_ + 1, p->malloc_pool_);
check_
value
(*tmp_literal);
check_
malloc
(*tmp_literal);
}
malloc_new_node(yylval->node, p->malloc_pool_, T_IDENT, 0);
yylval->node->str_len_ = 0;
...
...
@@ -660,7 +661,7 @@ FALSE {
if (*tmp_literal == NULL)
{
*tmp_literal = (char*) parse_malloc(p->input_sql_len_ + 1, p->malloc_pool_);
check_
value
(*tmp_literal);
check_
malloc
(*tmp_literal);
}
malloc_new_node(yylval->node, p->malloc_pool_, T_VARCHAR, 0);
yylval->node->str_len_ = 0;
...
...
@@ -679,8 +680,10 @@ FALSE {
check_value(yylval);
tmp_literal[yylval->node->str_len_] = '\0';
yylval->node->str_value_ = parse_strndup(tmp_literal, yylval->node->str_len_ + 1, p->malloc_pool_);
check_malloc(yylval->node->str_value_);
yylval->node->text_len_ = yylloc->last_column - p->start_col_ + 1;
yylval->node->raw_text_ = parse_strndup(p->input_sql_ + p->start_col_ - 1, yylval->node->text_len_, p->malloc_pool_);
check_malloc(yylval->node->raw_text_);
if (IS_FAST_PARAMETERIZE) {
STORE_PARAM_NODE();
} else {
...
...
@@ -755,6 +758,7 @@ FALSE {
malloc_new_node(yylval->node->children_[0], p->malloc_pool_, T_CONCAT_STRING, 0);
(*yylval->node->children_)->str_value_ = parse_strndup(tmp_literal, yylval->node->str_len_ + 1,
p->malloc_pool_);
check_malloc((*yylval->node->children_)->str_value_);
(*yylval->node->children_)->str_len_ = yylval->node->str_len_;
yylval->node->num_child_ = 1;
}
...
...
@@ -806,7 +810,7 @@ FALSE {
} else {
dup_value = parse_strndup(tmp_literal, yylval->node->str_len_ + 1, p->malloc_pool_);
}
check_
value
(dup_value);
check_
malloc
(dup_value);
yylval->node->str_value_ = dup_value;
setup_token_pos_info(yylval->node, yylloc->first_column, yylval->node->str_len_);
return NAME_OB;
...
...
@@ -830,7 +834,7 @@ FALSE {
if (NULL == *tmp_literal)
{
*tmp_literal = (char *)parse_malloc(p->input_sql_len_ + 1, p->malloc_pool_);
check_
value
(*tmp_literal);
check_
malloc
(*tmp_literal);
}
malloc_new_node(yylval->node, p->malloc_pool_, T_IDENT, 0);
yylval->node->str_len_ = 0;
...
...
@@ -875,7 +879,7 @@ FALSE {
} else {
dup_value = parse_strndup(tmp_literal, yylval->node->str_len_ + 1, p->malloc_pool_);
}
check_
value
(dup_value);
check_
malloc
(dup_value);
yylval->node->str_value_ = dup_value;
setup_token_pos_info(yylval->node, yylloc->first_column, yylval->node->str_len_);
return NAME_OB;
...
...
@@ -900,7 +904,7 @@ X'([0-9A-F])*'|0X([0-9A-F])+ {
if (len > 0) {
int64_t dest_len = ob_parse_binary_len(len);
char *dest = (char *)parse_malloc(dest_len, p->malloc_pool_);
check_
value
(dest);
check_
malloc
(dest);
ob_parse_binary(src, len, dest);
node->str_value_ = dest;
node->str_len_ = dest_len;
...
...
@@ -936,7 +940,7 @@ B'([01])*'|0B([01])+ {
{
int64_t dest_len = ob_parse_bit_string_len(len);
char *dest = (char*)parse_malloc(dest_len, p->malloc_pool_);
check_
value
(dest);
check_
malloc
(dest);
ob_parse_bit_string(src, len, dest);
node->str_value_ = dest;
node->str_len_ = dest_len;
...
...
@@ -1050,7 +1054,7 @@ Timestamp{whitespace}?\"[^\"]*\" {
ParseResult *p = (ParseResult *)yyextra;
malloc_new_node(node, p->malloc_pool_, T_HINT, 0);
dest = parse_strdup(yytext + 3, p->malloc_pool_, &out_len);
check_
value
(dest);
check_
malloc
(dest);
dest[out_len - 2] = '\0';
node->str_value_ = dest;
...
...
@@ -1208,7 +1212,7 @@ Timestamp{whitespace}?\"[^\"]*\" {
} else {
dup_value = parse_strdup(yytext, p->malloc_pool_, &out_len);
}
check_
value
(dup_value);
check_
malloc
(dup_value);
node->str_value_ = str_tolower(dup_value, strlen(dup_value));
node->str_len_ = out_len;
setup_token_pos_info(node, yylloc->first_column - 1, yylval->node->str_len_);
...
...
@@ -1306,7 +1310,7 @@ BEGIN(in_c_comment);
char *dup_value = NULL;
int64_t out_len = 0;
dup_value = parse_strdup(yytext, p->malloc_pool_, &out_len);
check_
value
(dup_value);
check_
malloc
(dup_value);
node->str_value_ = str_tolower(dup_value, strlen(dup_value));
node->str_len_ = out_len;
return STRING_VALUE;
...
...
@@ -1414,7 +1418,7 @@ BEGIN(in_c_comment);
}
if (IS_FAST_PARAMETERIZE) {
yylval->node->raw_text_ = parse_strdup(yytext, p->malloc_pool_, &(yylval->node->text_len_));
check_
value
(yylval->node->raw_text_);
check_
malloc
(yylval->node->raw_text_);
STORE_PARAM_NODE();
} else {
return QUESTIONMARK;
...
...
@@ -1428,7 +1432,7 @@ BEGIN(in_c_comment);
yylval->node->value_ = get_question_mark(&p->question_mark_ctx_, p->malloc_pool_, yytext);
if (IS_FAST_PARAMETERIZE) {
yylval->node->raw_text_ = parse_strdup(yytext, p->malloc_pool_, &(yylval->node->text_len_));
check_
value
(yylval->node->raw_text_);
check_
malloc
(yylval->node->raw_text_);
STORE_PARAM_NODE();
} else {
return QUESTIONMARK;
...
...
@@ -1445,7 +1449,7 @@ BEGIN(in_c_comment);
yylval->node = node;
/* skip '@@' */
node->str_value_ = parse_strdup(yytext + 2, p->malloc_pool_, &(node->str_len_));
check_
value
(node->str_value_);
check_
malloc
(node->str_value_);
//node->value_ = 2;
node->value_ = 0;
} else {
...
...
@@ -1465,6 +1469,7 @@ BEGIN(in_c_comment);
yylval->node = node;
/* skip '@' and quotes like '/"/` */
node->str_value_ = parse_strdup(yytext + 1, p->malloc_pool_, &(node->str_len_));
check_malloc(node->str_value_);
if (NULL != node->str_value_
&& node->str_len_ > 1
&& *(yytext + 1) == *(yytext + node->str_len_)
...
...
@@ -1512,7 +1517,7 @@ BEGIN(in_c_comment);
} else {
node->str_value_ = parse_strdup(yytext, p->malloc_pool_, &(node->str_len_));
}
check_
value
(node->str_value_);
check_
malloc
(node->str_value_);
setup_token_pos_info(node, yylloc->first_column - 1, node->str_len_);
ret = NAME_OB;
//CHECK_NODE_STRING_VALUE_ASCII(ret, node->str_value_, node->str_len_);
...
...
src/sql/parser/sql_parser_mysql_mode.y
浏览文件 @
d1aa3c5d
...
...
@@ -9549,8 +9549,9 @@ SHOW opt_full TABLES opt_from_or_in_database_clause opt_show_condition
value->str_value_ = parse_strndup("SYS", strlen("SYS") + 1, result->malloc_pool_);
if (NULL == value->str_value_)
{
yyerror(NULL, result, "No more space for mallocing string\n");
YYABORT;
((ParseResult *)yyextra)->extra_errno_ = OB_PARSER_ERR_NO_MEMORY;
yyerror(NULL, result, "No more space for mallocing string\n");
YYABORT;
}
value->str_len_ = strlen("SYS");
malloc_non_terminal_node(sub_where, result->malloc_pool_, T_OP_NE, 2, column, value);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录