support expr WEIGHT_STRING() in mysql mode. master->3_1_opensource_release

This commit is contained in:
AntiTopQuark
2021-10-20 11:33:37 +08:00
committed by wangzelin.wzl
parent 0d3a41c33d
commit 4ca9eabca4
18 changed files with 28604 additions and 27442 deletions

View File

@ -538,7 +538,7 @@ int ObSqlParameterization::transform_tree(TransformTreeCtx& ctx, const ObSQLSess
}
if (OB_SUCC(ret)) {
if (OB_FAIL(mark_tree(ctx.tree_))) {
if (OB_FAIL(mark_tree(ctx.tree_ , *ctx.sql_info_))) {
SQL_PC_LOG(WARN, "fail to mark function tree", K(ctx.tree_), K(ret));
}
}
@ -593,12 +593,17 @@ int ObSqlParameterization::check_and_generate_param_info(
if (sql_info.total_ != raw_params.count()) {
ret = OB_NOT_SUPPORTED;
#if !defined(NDEBUG)
SQL_PC_LOG(ERROR,
if ( sql_info.sql_traits_.has_weight_string_func_stmt_ ) {
// do nothing
}
else {
SQL_PC_LOG(ERROR,
"const number of fast parse and normal parse is different",
"fast_parse_const_num",
raw_params.count(),
"normal_parse_const_num",
sql_info.total_);
}
#endif
}
ObPCParam* pc_param = NULL;
@ -1059,7 +1064,7 @@ int ObSqlParameterization::mark_args(ParseNode* arg_tree, const bool* mark_arr,
// After mark this node, it has following mechanism:
// If a node is marked as cannot be parameterized,
// CUREENT NODE AND ALL NODES OF IT'S SUBTREE cannot be parameterized.
int ObSqlParameterization::mark_tree(ParseNode* tree)
int ObSqlParameterization::mark_tree(ParseNode *tree ,SqlInfo &sql_info)
{
int ret = OB_SUCCESS;
if (NULL == tree) {
@ -1086,6 +1091,14 @@ int ObSqlParameterization::mark_tree(ParseNode* tree)
if (OB_FAIL(mark_args(node[1], mark_arr, ARGS_NUMBER_THREE))) {
SQL_PC_LOG(WARN, "fail to mark substr arg", K(ret));
}
}else if (0 == func_name.case_compare("weight_string")
&& (5 == node[1]->num_child_)) {
const int64_t ARGS_NUMBER_FIVE = 5;
bool mark_arr[ARGS_NUMBER_FIVE] = {0, 1, 1, 1, 1}; //0表示参数化, 1 表示不参数化
sql_info.sql_traits_.has_weight_string_func_stmt_ = true;
if (OB_FAIL(mark_args(node[1], mark_arr, ARGS_NUMBER_FIVE))) {
SQL_PC_LOG(WARN, "fail to mark weight_string arg", K(ret));
}
} else if ((0 == func_name.case_compare("str_to_date") // STR_TO_DATE(str,format)
|| 0 == func_name.case_compare("date_format") // DATE_FORMAT(date,format)
||