提交 1ad2554d 编写于 作者: O obdev 提交者: wangzelin.wzl

[CP] [CP] Fix enumset in-subquery missing wrap type to string expr

上级 bad0d4e3
......@@ -95,6 +95,8 @@ int ObRawExprDeduceType::visit(ObQueryRefRawExpr& expr)
}
}
} else {
// for enumset query ref `is_set`, need warp enum_to_str/set_to_str expr at
// `ObRawExprWrapEnumSet::visit_query_ref_expr`
expr.set_data_type(ObIntType);
}
return ret;
......
......@@ -230,6 +230,8 @@ int ObRawExprWrapEnumSet::visit(ObVarRawExpr& expr)
int ObRawExprWrapEnumSet::visit(ObQueryRefRawExpr& expr)
{
UNUSED(expr);
// QueryRef expr for the children of `ObOpRawExpr` will be visited at `visit_query_ref_expr`.
// because it depends on the input_type of the parent node.
return OB_SUCCESS;
}
......@@ -293,8 +295,14 @@ int ObRawExprWrapEnumSet::visit(ObOpRawExpr& expr)
ObRawExpr* param_expr = expr.get_param_expr(i);
ObObjType calc_type = expr.get_input_types().at(i).get_calc_type();
ObSysFunRawExpr* new_expr = NULL;
if (OB_FAIL(
wrap_type_to_str_if_necessary(param_expr, calc_type, get_current_level(), is_same_need, new_expr))) {
if (param_expr->is_query_ref_expr() && !ob_is_enumset_tc(param_expr->get_data_type())) {
ObQueryRefRawExpr *query_ref_expr = static_cast<ObQueryRefRawExpr *>(param_expr);
OZ(visit_query_ref_expr(*query_ref_expr, calc_type, is_same_need));
} else if (OB_FAIL(wrap_type_to_str_if_necessary(param_expr,
calc_type,
get_current_level(),
is_same_need,
new_expr))) {
LOG_WARN("failed to wrap_type_to_str_if_necessary", K(i), K(ret));
} else if ((NULL != new_expr) && OB_FAIL(expr.replace_param_expr(i, new_expr))) {
LOG_WARN("replace param expr failed", K(ret));
......@@ -830,5 +838,38 @@ int ObRawExprWrapEnumSet::wrap_nullif_expr(ObSysFunRawExpr& expr)
return ret;
}
int ObRawExprWrapEnumSet::visit_query_ref_expr(
ObQueryRefRawExpr &expr, const ObObjType dest_type, const bool is_same_need)
{
int ret = OB_SUCCESS;
if (!expr.has_enum_set_column()) {
// no-op if expr doesn't have enumset column
} else if (1 == expr.get_output_column() && expr.is_set() &&
ob_is_enumset_tc(expr.get_column_types().at(0).get_type())) {
ObSelectStmt *ref_stmt = expr.get_ref_stmt();
if (OB_ISNULL(ref_stmt)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("ref_stmt should not be NULL", K(expr), K(ret));
} else if (OB_UNLIKELY(1 != ref_stmt->get_select_item_size())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("select item size should be 1", "size", ref_stmt->get_select_item_size(), K(expr), K(ret));
} else if (OB_ISNULL(ref_stmt->get_select_item(0).expr_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr of select item is NULL", K(expr), K(ret));
} else {
ObRawExpr *enumset_expr = ref_stmt->get_select_item(0).expr_;
ObSysFunRawExpr *new_expr = NULL;
if (OB_FAIL(
wrap_type_to_str_if_necessary(enumset_expr, dest_type, get_current_level(), is_same_need, new_expr))) {
LOG_WARN("failed to wrap_type_to_str_if_necessary", K(ret));
} else if (NULL != new_expr) {
// replace with new wrapped expr
ref_stmt->get_select_item(0).expr_ = new_expr;
} else { /*do nothing*/
}
}
}
return ret;
}
} // namespace sql
} // namespace oceanbase
......@@ -60,6 +60,9 @@ private:
int wrap_sub_select(ObInsertStmt& stmt);
int wrap_value_vector(ObInsertStmt& stmt);
int wrap_nullif_expr(ObSysFunRawExpr& expr);
int visit_query_ref_expr(ObQueryRefRawExpr &expr,
const common::ObObjType dest_type,
const bool is_same_need);
private:
int32_t current_level_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册