[cp]: fix 4 bugs for NO_BACKSLASH_ESCAPES mode.
This commit is contained in:
@ -274,7 +274,13 @@ int ObLoadDataResolver::resolve(const ParseNode& parse_tree)
|
||||
if (OB_SUCC(ret)) {
|
||||
/* 5. opt_field */
|
||||
ObDataInFileStruct& data_struct_in_file = load_stmt->get_data_struct_in_file();
|
||||
const ParseNode* child_node = node->children_[ENUM_OPT_FIELD];
|
||||
bool no_default_escape = false;
|
||||
IS_NO_BACKSLASH_ESCAPES(session_info_->get_sql_mode(), no_default_escape);
|
||||
if (no_default_escape) {
|
||||
data_struct_in_file.field_escaped_char_ = INT64_MAX;
|
||||
data_struct_in_file.field_escaped_str_ = "";
|
||||
}
|
||||
const ParseNode *child_node = node->children_[ENUM_OPT_FIELD];
|
||||
if (NULL != child_node) {
|
||||
if (T_INTO_FIELD_LIST != child_node->type_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
|
||||
@ -2275,11 +2275,25 @@ int ObRawExprResolverImpl::process_like_node(const ParseNode* node, ObRawExpr*&
|
||||
escape_node.str_value_ = "\\";
|
||||
escape_node.text_len_ = 0;
|
||||
escape_node.raw_text_ = NULL;
|
||||
|
||||
/*
|
||||
bugfix:https://work.aone.alibaba-inc.com/issue/36691548
|
||||
in NO_BACKSLASH_ESCAPES mode, 'like BINARY xxx' stmt should also set the escapes as null, instead of '\'
|
||||
*/
|
||||
bool no_escapes = false;
|
||||
if (node->children_[1]->type_ == T_FUN_SYS && node->children_[1]->num_child_ == 2 &&
|
||||
node->children_[1]->children_[0]->str_len_ == 4 &&
|
||||
(0 == strcmp(node->children_[1]->children_[0]->str_value_, "cast")) &&
|
||||
node->children_[1]->children_[1]->num_child_ == 2 // T_EXPR_LIST node
|
||||
&& node->children_[1]->children_[1]->children_[1]->int16_values_[OB_NODE_CAST_TYPE_IDX] == T_VARCHAR &&
|
||||
node->children_[1]->children_[1]->children_[1]->int16_values_[OB_NODE_CAST_COLL_IDX] == BINARY_COLLATION) {
|
||||
IS_NO_BACKSLASH_ESCAPES(ctx_.session_info_->get_sql_mode(), no_escapes);
|
||||
}
|
||||
if (OB_FAIL(process_datatype_or_questionmark(escape_node, escape_expr))) {
|
||||
LOG_WARN("fail to resolver defalut excape node", K(ret));
|
||||
} else if (OB_FAIL(t_expr->add_param_expr(escape_expr))) {
|
||||
LOG_WARN("fail to set param expr");
|
||||
} else if (lib::is_oracle_mode()) {
|
||||
} else if (lib::is_oracle_mode() || no_escapes) {
|
||||
// Oracle mode, if not specify escape, then no escape, but the implementation of like must contain escape
|
||||
// so we rewrite like without escape
|
||||
// c1 like '%x\x%' --> c1 like replace('%x\x%', '\','\\') escape '\' -> c1 like '%x\\x%' escape '\'
|
||||
|
||||
Reference in New Issue
Block a user