[json bugfix] json_table column field uses double quotes to indicate path causing coredump

This commit is contained in:
Carrot-77 2024-04-17 11:13:34 +00:00 committed by ob-robot
parent c01bae9728
commit 541a906e5a
5 changed files with 29 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -1230,7 +1230,7 @@ DEFINE_ERROR_EXT(OB_ERR_DEPRECATED_SYNTAX_NO_REP, -5518, ER_WARN_DEPRECATED_SYNT
DEFINE_ERROR(OB_ERR_CAST_ARRAY_SUPPORT, -5519, ER_NOT_SUPPORTED_YET, "42000", "This version of MySQL doesn't yet support %s");
DEFINE_ERROR(OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX, -5520, ER_CAST_INDEX_JSON_VALUE, "42000", "Invalid JSON value for CAST for functional index.");
DEFINE_ERROR(OB_ERR_JSON_CONTAINER_CAST_SCALAR, -5521, ER_ARRAY_CAST_INDEX_SCALAR, "42000", "Cannot store an array or an object in a scalar key part of the index.");
DEFINE_ORACLE_ERROR(OB_ERR_INVALID_IDENTIFIER_JSON_TABLE, -5522, -1, "22000", "invalid identifier used for path expression in JSON_TABLE", 40680, "invalid identifier used for path expression in JSON_TABLE");
//for changed solidify session vars of generated cols
DEFINE_ERROR_EXT_DEP(OB_ERR_SESSION_VAR_CHANGED, -5540, -1, "HY000", "System variables are different from the old values solidified.", "System variable '%.*s' is different from the old value solidified for '%.*s'(old value:%.*s).");

View File

@ -894,6 +894,7 @@ constexpr int OB_ERR_DEPRECATED_SYNTAX_NO_REP = -5518;
constexpr int OB_ERR_CAST_ARRAY_SUPPORT = -5519;
constexpr int OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX = -5520;
constexpr int OB_ERR_JSON_CONTAINER_CAST_SCALAR = -5521;
constexpr int OB_ERR_INVALID_IDENTIFIER_JSON_TABLE = -5522;
constexpr int OB_ERR_SP_ALREADY_EXISTS = -5541;
constexpr int OB_ERR_SP_DOES_NOT_EXIST = -5542;
constexpr int OB_ERR_SP_UNDECLARED_VAR = -5543;
@ -2945,6 +2946,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_CAST_ARRAY_SUPPORT__USER_ERROR_MSG "This version of MySQL doesn't yet support %s"
#define OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX__USER_ERROR_MSG "Invalid JSON value for CAST for functional index."
#define OB_ERR_JSON_CONTAINER_CAST_SCALAR__USER_ERROR_MSG "Cannot store an array or an object in a scalar key part of the index."
#define OB_ERR_INVALID_IDENTIFIER_JSON_TABLE__USER_ERROR_MSG "invalid identifier used for path expression in JSON_TABLE"
#define OB_ERR_SESSION_VAR_CHANGED__USER_ERROR_MSG "System variable '%.*s' is different from the old value solidified for '%.*s'(old value:%.*s)."
#define OB_ERR_SP_ALREADY_EXISTS__USER_ERROR_MSG "%s %.*s already exists"
#define OB_ERR_SP_DOES_NOT_EXIST__USER_ERROR_MSG "%s %.*s.%.*s does not exist"
@ -5196,6 +5198,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_CAST_ARRAY_SUPPORT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5519, This version of MySQL doesn't yet support %s"
#define OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5520, Invalid JSON value for CAST for functional index."
#define OB_ERR_JSON_CONTAINER_CAST_SCALAR__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5521, Cannot store an array or an object in a scalar key part of the index."
#define OB_ERR_INVALID_IDENTIFIER_JSON_TABLE__ORA_USER_ERROR_MSG "ORA-40680: invalid identifier used for path expression in JSON_TABLE"
#define OB_ERR_SESSION_VAR_CHANGED__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5540, System variable '%.*s' is different from the old value solidified for '%.*s'(old value:%.*s)."
#define OB_ERR_SP_ALREADY_EXISTS__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5541, %s %.*s already exists"
#define OB_ERR_SP_DOES_NOT_EXIST__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5542, %s %.*s.%.*s does not exist"
@ -6381,7 +6384,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_DATA_TOO_LONG_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-12899: value too large for column %.*s (actual: %ld, maximum: %ld)"
#define OB_ERR_INVALID_DATE_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-01861: Incorrect datetime value for column '%.*s' at row %ld"
extern int g_all_ob_errnos[2247];
extern int g_all_ob_errnos[2248];
const char *ob_error_name(const int oberr);
const char* ob_error_cause(const int oberr);

View File

@ -769,6 +769,9 @@ int RegularCol::check_item_method_json(ObRegCol &col_node, JtScanCtx* ctx)
&& col_node.expr_param_.dst_type_ != ObJsonType) {
ret = OB_ERR_INVALID_DATA_TYPE_RETURNING;
LOG_USER_ERROR(OB_ERR_INVALID_DATA_TYPE_RETURNING);
} else if (OB_ISNULL(col_node.expr_param_.json_path_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get expr param json path is null", K(ret));
} else if (col_node.expr_param_.json_path_->is_last_func()
&& OB_FAIL( ObJsonExprHelper::check_item_func_with_return(col_node.expr_param_.json_path_->get_last_node_type(),
col_node.expr_param_.dst_type_, expr->datum_meta_.cs_type_, 1))) {
@ -782,7 +785,10 @@ int RegularCol::check_item_method_json(ObRegCol &col_node, JtScanCtx* ctx)
LOG_WARN("fail to check item method with wrapper", K(ret));
}
} else if (col_node.type() == COL_TYPE_VALUE) {
if (col_node.expr_param_.json_path_->is_last_func()
if (OB_ISNULL(col_node.expr_param_.json_path_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get expr param json path is null", K(ret));
} else if (col_node.expr_param_.json_path_->is_last_func()
&& OB_FAIL( ObJsonExprHelper::check_item_func_with_return(col_node.expr_param_.json_path_->get_last_node_type(),
col_node.expr_param_.dst_type_, expr->datum_meta_.cs_type_, 0))) {
if (ret == OB_ERR_INVALID_DATA_TYPE_RETURNING) {

View File

@ -9603,6 +9603,9 @@ int ObDMLResolver::resolve_json_table_column_name_and_path(const ParseNode *name
} else if (((table_type == OB_ORA_JSON_TABLE_TYPE && *path_node->str_value_ != '$' && path_node->value_ != 1))
&& OB_FAIL(json_table_make_json_path(*path_node, allocator, col_def->col_base_info_.path_, table_type))) {
LOG_WARN("failed to make json path", K(ret));
} else if (table_type == OB_ORA_JSON_TABLE_TYPE && path_node->type_ == T_IDENT && path_node->is_input_quoted_ == 1) {
ret = OB_ERR_INVALID_IDENTIFIER_JSON_TABLE;
LOG_WARN("invalid identifier used for path expression in JSON_TABLE", K(ret), K(path_node->type_));
}
} else if (path_node->type_ == T_NULL
&& OB_FAIL(json_table_make_json_path(*name_node, allocator, col_def->col_base_info_.path_, table_type))) {