fix bug about dateadd when in normal parser
This commit is contained in:
		| @ -1362,7 +1362,7 @@ bit_expr '|' bit_expr %prec '|' | ||||
| { | ||||
|   ParseNode *params = NULL; | ||||
|   malloc_non_terminal_node(params, result->malloc_pool_, T_EXPR_LIST, 3, $1, $4, $5); | ||||
|   make_name_node($$, result->malloc_pool_, "date_add"); | ||||
|   make_name_node($$, result->malloc_pool_, "date_add_date_interval"); | ||||
|   malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS, 2, $$, params); | ||||
|   check_ret(setup_token_pos_info_and_dup_string($$, result, @1.first_column, @4.last_column), | ||||
|             &@1, result); | ||||
| @ -1370,8 +1370,8 @@ bit_expr '|' bit_expr %prec '|' | ||||
| | INTERVAL expr date_unit '+' bit_expr | ||||
| { | ||||
|   ParseNode *params = NULL; | ||||
|   malloc_non_terminal_node(params, result->malloc_pool_, T_EXPR_LIST, 3, $5, $2, $3); | ||||
|   make_name_node($$, result->malloc_pool_, "date_add"); | ||||
|   malloc_non_terminal_node(params, result->malloc_pool_, T_EXPR_LIST, 3, $2, $3, $5); | ||||
|   make_name_node($$, result->malloc_pool_, "date_add_interval_date"); | ||||
|   malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS, 2, $$, params); | ||||
|   check_ret(setup_token_pos_info_and_dup_string($$, result, @1.first_column, @4.last_column), | ||||
|             &@1, result); | ||||
|  | ||||
| @ -5814,6 +5814,7 @@ 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_)); | ||||
| @ -5827,6 +5828,10 @@ 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)); | ||||
|     } | ||||
| @ -5928,7 +5933,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))) { | ||||
|           if (OB_FAIL(process_sys_func_params(*func_expr, current_columns_count, actual_name))) { | ||||
|             LOG_WARN("fail process sys func params", K(ret)); | ||||
|           } | ||||
|         } | ||||
| @ -5978,7 +5983,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) | ||||
| int ObRawExprResolverImpl::process_sys_func_params(ObSysFunRawExpr &func_expr, int current_columns_count, ObString &node_name) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   const ObExprOperatorType expr_type = ObExprOperatorFactory::get_type_by_name(func_expr.get_func_name()); | ||||
| @ -6017,6 +6022,27 @@ 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))) { | ||||
|             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)); | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       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); | ||||
|   int process_sys_func_params(ObSysFunRawExpr &func_expr, int current_columns_count, ObString &node_name); | ||||
|   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
	 obdev
					obdev