fix: 1. rapidjson coredump bug when oom. 2. json_value support truncate clause

This commit is contained in:
obdev
2023-08-08 08:42:35 +00:00
committed by ob-robot
parent d1e5895cb8
commit cf6ace1f68
9 changed files with 265 additions and 156 deletions

View File

@ -1773,12 +1773,33 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
LOG_WARN("fail to print cast_type", K(ret));
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(3))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("pretty value isn't int value");
LOG_WARN("truncate value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(3))->get_value().get_int();
switch (type) {
case 0:
break;
case 1:
DATA_PRINTF(" TRUNCATE");
break;
default:
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid type value.", K(type));
break;
}
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("ascii value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF("");
@ -1794,11 +1815,11 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().is_int()) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(5))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("type value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().get_int();
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(5))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" error");
@ -1811,7 +1832,7 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
break;
case 2:
DATA_PRINTF(" default ");
PRINT_EXPR(expr->get_param_expr(5));
PRINT_EXPR(expr->get_param_expr(6));
break;
default:
ret = OB_ERR_UNEXPECTED;
@ -1824,11 +1845,11 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(7))->get_value().is_int()) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(8))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("type value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(7))->get_value().get_int();
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(8))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" error");
@ -1839,7 +1860,7 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
break;
case 2:
DATA_PRINTF(" default ");
PRINT_EXPR(expr->get_param_expr(8));
PRINT_EXPR(expr->get_param_expr(9));
break;
default:
ret = OB_ERR_UNEXPECTED;
@ -1854,7 +1875,7 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
if (lib::is_oracle_mode()) {
if (OB_SUCC(ret)) {
bool not_first_node = false;
for (size_t i = 10; OB_SUCC(ret) && i < expr->get_param_count(); i++) {
for (size_t i = 11; OB_SUCC(ret) && i < expr->get_param_count(); i++) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(i))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("type value isn't int value");

View File

@ -5507,7 +5507,7 @@ int ObRawExprResolverImpl::process_json_value_node(const ParseNode *node, ObRawE
CK(OB_NOT_NULL(node))
CK(T_FUN_SYS_JSON_VALUE == node->type_);
// node child_num is nine,
CK(9 == node->num_child_);
CK(10 == node->num_child_);
bool mismatch_vec = false;
int32_t num = 0;
ObSysFunRawExpr *func_expr = NULL;
@ -5519,9 +5519,9 @@ int ObRawExprResolverImpl::process_json_value_node(const ParseNode *node, ObRawE
}
// pl mode check whether has mismatch
if (lib::is_oracle_mode() && ctx_.current_scope_ == T_PL_SCOPE) {
if (node->children_[8]->num_child_ != 2
|| node->children_[8]->children_[0]->value_ != 3
|| node->children_[8]->children_[1]->value_ != 7) {
if (node->children_[9]->num_child_ != 2
|| node->children_[9]->children_[0]->value_ != 3
|| node->children_[9]->children_[1]->value_ != 7) {
ret = OB_ERR_PARSE_PLSQL;
LOG_USER_ERROR(OB_ERR_PARSE_PLSQL, "\"MISMATCH\"", "error empty");
}
@ -5553,16 +5553,16 @@ int ObRawExprResolverImpl::process_json_value_node(const ParseNode *node, ObRawE
ParseNode *empty_default_value = NULL;
ParseNode *error_type = NULL;
ParseNode *error_default_value = NULL;
if (node->children_[4]->is_input_quoted_ == 1) {
empty_type = node->children_[6];
empty_default_value = node->children_[7];
error_type = node->children_[4];
error_default_value = node->children_[5];
if (node->children_[5]->is_input_quoted_ == 1) {
empty_type = node->children_[7];
empty_default_value = node->children_[8];
error_type = node->children_[5];
error_default_value = node->children_[6];
} else {
empty_type = node->children_[4];
empty_default_value = node->children_[5];
error_type = node->children_[6];
error_default_value = node->children_[7];
empty_type = node->children_[5];
empty_default_value = node->children_[6];
error_type = node->children_[7];
error_default_value = node->children_[8];
}
// if use defualt, value should not be null , support
if (OB_SUCC(ret)) {
@ -5591,7 +5591,7 @@ int ObRawExprResolverImpl::process_json_value_node(const ParseNode *node, ObRawE
// judge input TODO object type can use ignore and match type
ObVector<const ParseNode*> mismatch_arr;
if (OB_SUCC(ret)) {
const ParseNode *on_mismatch = node->children_[8];
const ParseNode *on_mismatch = node->children_[9];
if (OB_ISNULL(on_mismatch)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("mismatch node is null", K(ret));
@ -5603,13 +5603,13 @@ int ObRawExprResolverImpl::process_json_value_node(const ParseNode *node, ObRawE
ParseNode *cur_node = NULL;
for (int32_t i = 0; OB_SUCC(ret) && i < num; i++) {
cur_node = node->children_[i];
if (i == 4) {
if (i == 5) {
cur_node = empty_type;
} else if (i == 5) {
cur_node = empty_default_value;
} else if (i == 6) {
cur_node = error_type;
cur_node = empty_default_value;
} else if (i == 7) {
cur_node = error_type;
} else if (i == 8) {
cur_node = error_default_value;
}
if (node->children_[i]->type_ == T_LINK_NODE || node->children_[i]->type_ == T_VALUE_VECTOR) {
@ -5620,7 +5620,7 @@ int ObRawExprResolverImpl::process_json_value_node(const ParseNode *node, ObRawE
CK(OB_NOT_NULL(para_expr));
OZ(func_expr->add_param_expr(para_expr));
}
if (OB_SUCC(ret) && (i == 5 || i == 7)) {
if (OB_SUCC(ret) && (i == 6 || i == 8)) {
ObRawExpr *para_expr = NULL;
CK(OB_NOT_NULL(cur_node));
OZ(SMART_CALL(recursive_resolve(cur_node, para_expr)));