fix bug about dateadd func
This commit is contained in:
@ -5825,7 +5825,6 @@ int ObRawExprResolverImpl::process_fun_sys_node(const ParseNode *node, ObRawExpr
|
||||
int ret = OB_SUCCESS;
|
||||
ObSysFunRawExpr *func_expr = NULL;
|
||||
ObString func_name;
|
||||
ObString actual_name;
|
||||
if (OB_ISNULL(node) || OB_ISNULL(ctx_.session_info_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(node), KP(ctx_.session_info_));
|
||||
@ -5839,10 +5838,6 @@ int ObRawExprResolverImpl::process_fun_sys_node(const ParseNode *node, ObRawExpr
|
||||
LOG_WARN("func_expr is null");
|
||||
} else {
|
||||
ObString name(node->children_[0]->str_len_, node->children_[0]->str_value_);
|
||||
if (0 == name.case_compare("date_add_interval_date") || 0 == name.case_compare("date_add_date_interval")){
|
||||
actual_name = name;
|
||||
name = ObString::make_string("date_add");
|
||||
}
|
||||
if (OB_FAIL(check_internal_function(name))) {
|
||||
LOG_WARN("unexpected internal function", K(ret));
|
||||
}
|
||||
@ -5944,7 +5939,7 @@ int ObRawExprResolverImpl::process_fun_sys_node(const ParseNode *node, ObRawExpr
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(process_sys_func_params(*func_expr, current_columns_count, actual_name))) {
|
||||
if (OB_FAIL(process_sys_func_params(*func_expr, current_columns_count))) {
|
||||
LOG_WARN("fail process sys func params", K(ret));
|
||||
}
|
||||
}
|
||||
@ -5994,7 +5989,7 @@ int ObRawExprResolverImpl::process_fun_sys_node(const ParseNode *node, ObRawExpr
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObRawExprResolverImpl::process_sys_func_params(ObSysFunRawExpr &func_expr, int current_columns_count, ObString &node_name)
|
||||
int ObRawExprResolverImpl::process_sys_func_params(ObSysFunRawExpr &func_expr, int current_columns_count)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObExprOperatorType expr_type = ObExprOperatorFactory::get_type_by_name(func_expr.get_func_name());
|
||||
@ -6034,25 +6029,48 @@ int ObRawExprResolverImpl::process_sys_func_params(ObSysFunRawExpr &func_expr, i
|
||||
}
|
||||
break;
|
||||
case T_FUN_SYS_DATE_ADD:
|
||||
if (0 == node_name.case_compare("date_add_interval_date")) {
|
||||
if (3 == func_expr.get_param_count()) {
|
||||
ObRawExpr *expr0 = func_expr.get_param_expr(0);
|
||||
ObRawExpr *expr1 = func_expr.get_param_expr(1);
|
||||
if (OB_FAIL(func_expr.remove_param_expr(0))) {
|
||||
// Added a fourth parameter to distinguish between “date + interval” and “interval + date”
|
||||
// So you should use it to distinguish these two cases
|
||||
if(4 == func_expr.get_param_count()) {
|
||||
ObRawExpr *expr3 = func_expr.get_param_expr(3);
|
||||
if(OB_LIKELY(NULL != expr3 && expr3->is_const_raw_expr())) {
|
||||
ObConstRawExpr *const_expr = static_cast<ObConstRawExpr *>(expr3);
|
||||
int64_t expr3_val = OB_INVALID_ID;
|
||||
if(T_INT == const_expr->get_expr_type()) {
|
||||
if (OB_FAIL(const_expr->get_value().get_int(expr3_val))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get fourth para value from date_add func failed", K(ret));
|
||||
} else if (2 == expr3_val) {
|
||||
ObRawExpr *expr0 = func_expr.get_param_expr(0);
|
||||
ObRawExpr *expr1 = func_expr.get_param_expr(1);
|
||||
if (OB_FAIL(func_expr.remove_param_expr(3))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param3 is invalid", K(ret));
|
||||
} else if (OB_FAIL(func_expr.remove_param_expr(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
} else if (OB_FAIL(func_expr.remove_param_expr(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
} else if (OB_FAIL(func_expr.add_param_expr(expr0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
} else if (OB_FAIL(func_expr.add_param_expr(expr1))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
}
|
||||
} else if (1 == expr3_val) {
|
||||
if (OB_FAIL(func_expr.remove_param_expr(3))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param3 is invalid", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
} else if (OB_FAIL(func_expr.remove_param_expr(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
} else if (OB_FAIL(func_expr.add_param_expr(expr0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
} else if (OB_FAIL(func_expr.add_param_expr(expr1))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("the func expr param0 is invalid", K(ret));
|
||||
LOG_WARN("the func expr3 is null or not const expr", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@ -206,7 +206,7 @@ private:
|
||||
int process_xmlparse_node(const ParseNode *node, ObRawExpr *&expr);
|
||||
void get_special_func_ident_name(ObString &ident_name, const ObItemType func_type);
|
||||
private:
|
||||
int process_sys_func_params(ObSysFunRawExpr &func_expr, int current_columns_count, ObString &node_name);
|
||||
int process_sys_func_params(ObSysFunRawExpr &func_expr, int current_columns_count);
|
||||
int transform_ratio_afun_to_arg_div_sum(const ParseNode *ratio_to_report, ParseNode *&div);
|
||||
int convert_any_or_all_expr(ObRawExpr *&expr, bool &happened);
|
||||
int get_opposite_string(const common::ObString &orig_string, common::ObString &new_string, common::ObIAllocator &allocator);
|
||||
|
||||
Reference in New Issue
Block a user