diff --git a/src/sql/engine/expr/ob_expr_extract.cpp b/src/sql/engine/expr/ob_expr_extract.cpp index 671a195718..9b049f8039 100644 --- a/src/sql/engine/expr/ob_expr_extract.cpp +++ b/src/sql/engine/expr/ob_expr_extract.cpp @@ -29,7 +29,7 @@ using namespace common; namespace sql { ObExprExtract::ObExprExtract(ObIAllocator &alloc) - : ObFuncExprOperator(alloc, T_FUN_SYS_EXTRACT, N_EXTRACT, 2, NOT_VALID_FOR_GENERATED_COL, NOT_ROW_DIMENSION) + : ObFuncExprOperator(alloc, T_FUN_SYS_EXTRACT, N_EXTRACT, 2, VALID_FOR_GENERATED_COL, NOT_ROW_DIMENSION) { } diff --git a/src/sql/engine/expr/ob_expr_oracle_to_char.cpp b/src/sql/engine/expr/ob_expr_oracle_to_char.cpp index c818681ca8..8f52721fd3 100644 --- a/src/sql/engine/expr/ob_expr_oracle_to_char.cpp +++ b/src/sql/engine/expr/ob_expr_oracle_to_char.cpp @@ -152,7 +152,7 @@ int ObExprOracleToChar::calc_result_typeN(ObExprResType &type, if (type_array[0].is_oracle_temporal_type()) { type_array[1].set_calc_type(ObVarcharType); type_array[1].set_calc_collation_type(nls_param.nls_collation_); - } else { + } else if (!type_array[1].is_varchar_or_char()) { type_array[1].set_calc_type_default_varchar(); } } diff --git a/src/sql/resolver/expr/ob_raw_expr_util.cpp b/src/sql/resolver/expr/ob_raw_expr_util.cpp index 808bdc7858..6d19c8001c 100644 --- a/src/sql/resolver/expr/ob_raw_expr_util.cpp +++ b/src/sql/resolver/expr/ob_raw_expr_util.cpp @@ -1985,17 +1985,6 @@ int ObRawExprUtils::build_generated_column_expr(const obrpc::ObCreateIndexArg *a if (OB_SUCC(ret)) { if (OB_FAIL(expr->formalize(&session_info))) { LOG_WARN("formalize expr failed", K(ret), KPC(expr)); - } else if (ObResolverUtils::CHECK_FOR_FUNCTION_INDEX == check_status || - ObResolverUtils::CHECK_FOR_GENERATED_COLUMN == check_status) { - if (OB_FAIL(ObRawExprUtils::check_is_valid_generated_col(expr, expr_factory.get_allocator()))) { - if (OB_ERR_ONLY_PURE_FUNC_CANBE_VIRTUAL_COLUMN_EXPRESSION == ret - && ObResolverUtils::CHECK_FOR_FUNCTION_INDEX == check_status) { - ret = OB_ERR_ONLY_PURE_FUNC_CANBE_INDEXED; - LOG_WARN("sysfunc in expr is not valid for generated column", K(ret), K(*expr)); - } else { - LOG_WARN("fail to check if the sysfunc exprs are valid in generated columns", K(ret)); - } - } } } diff --git a/src/sql/rewrite/ob_transform_pre_process.cpp b/src/sql/rewrite/ob_transform_pre_process.cpp index 2aa04e7376..0001f77bbe 100644 --- a/src/sql/rewrite/ob_transform_pre_process.cpp +++ b/src/sql/rewrite/ob_transform_pre_process.cpp @@ -8450,7 +8450,9 @@ int ObTransformPreProcess::transform_rollup_exprs(ObDMLStmt *stmt, bool &trans_h } else if (expr->has_flag(CNT_VOLATILE_CONST) || !expr->is_const_expr()) { //do nothing } else if (expr->is_static_const_expr()) { //static const expr - if (OB_FAIL(ObRawExprUtils::build_remove_const_expr( + if (ObOptimizerUtil::find_item(static_const_exprs, expr)) { + //do nothing, skip dup exprs + } else if (OB_FAIL(ObRawExprUtils::build_remove_const_expr( *ctx_->expr_factory_, *ctx_->session_info_, expr, @@ -8467,6 +8469,8 @@ int ObTransformPreProcess::transform_rollup_exprs(ObDMLStmt *stmt, bool &trans_h stmt->get_rollup_exprs().at(i) = remove_const_expr; trans_happened = true; } + } else if (ObOptimizerUtil::find_item(exec_param_exprs, expr)) { + //do nothing, skip dup exprs } else if (OB_FAIL(ObRawExprUtils::build_remove_const_expr( *ctx_->expr_factory_, *ctx_->session_info_,