fix padding bug with function-based index
This commit is contained in:
@ -1371,6 +1371,46 @@ int ObRawExprUtils::build_generated_column_expr(const ObString& expr_str, ObRawE
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObRawExprUtils::build_pad_expr_recursively(ObRawExprFactory &expr_factory, const ObSQLSessionInfo &session,
|
||||
const ObTableSchema &table_schema, const ObColumnSchemaV2 &gen_col_schema, ObRawExpr *&expr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
CK(OB_NOT_NULL(expr));
|
||||
|
||||
if (OB_SUCC(ret) && expr->get_param_count() > 0) {
|
||||
for (int i = 0; OB_SUCC(ret) && i < expr->get_param_count(); i++) {
|
||||
OZ(SMART_CALL(
|
||||
build_pad_expr_recursively(expr_factory, session, table_schema, gen_col_schema, expr->get_param_expr(i))));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && expr->is_column_ref_expr()) {
|
||||
ObColumnRefRawExpr *b_expr = static_cast<ObColumnRefRawExpr *>(expr);
|
||||
uint64_t column_id = b_expr->get_column_id();
|
||||
if (OB_SUCC(ret)) {
|
||||
const ObColumnSchemaV2 *column_schema = table_schema.get_column_schema(column_id);
|
||||
if (NULL == column_schema) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get column schema fail", K(column_schema));
|
||||
} else if (ObObjMeta::is_binary(column_schema->get_data_type(), column_schema->get_collation_type())) {
|
||||
if (OB_FAIL(build_pad_expr(expr_factory, false, column_schema, expr, &session))) {
|
||||
LOG_WARN("fail to build pading expr for binary", K(ret));
|
||||
}
|
||||
} else if (ObCharType == column_schema->get_data_type() || ObNCharType == column_schema->get_data_type()) {
|
||||
if (gen_col_schema.has_column_flag(PAD_WHEN_CALC_GENERATED_COLUMN_FLAG)) {
|
||||
if (OB_FAIL(build_pad_expr(expr_factory, true, column_schema, expr, &session))) {
|
||||
LOG_WARN("fail to build pading expr for char", K(ret));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(build_trim_expr(column_schema, expr_factory, &session, expr))) {
|
||||
LOG_WARN("fail to build trime expr for char", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// compare two raw expressions
|
||||
bool ObRawExprUtils::is_same_raw_expr(const ObRawExpr* src, const ObRawExpr* dst)
|
||||
{
|
||||
@ -2665,7 +2705,7 @@ int ObRawExprUtils::build_null_expr(ObRawExprFactory& expr_factory, ObRawExpr*&
|
||||
}
|
||||
|
||||
int ObRawExprUtils::build_trim_expr(const ObColumnSchemaV2* column_schema, ObRawExprFactory& expr_factory,
|
||||
ObSQLSessionInfo* session_info, ObRawExpr*& expr)
|
||||
const ObSQLSessionInfo* session_info, ObRawExpr*& expr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSysFunRawExpr* trim_expr = NULL;
|
||||
@ -2716,7 +2756,7 @@ int ObRawExprUtils::build_trim_expr(const ObColumnSchemaV2* column_schema, ObRaw
|
||||
}
|
||||
|
||||
int ObRawExprUtils::build_pad_expr(ObRawExprFactory& expr_factory, bool is_char, const ObColumnSchemaV2* column_schema,
|
||||
ObRawExpr*& expr, sql::ObSQLSessionInfo* session_info)
|
||||
ObRawExpr*& expr, const sql::ObSQLSessionInfo* session_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSysFunRawExpr* pad_expr = NULL;
|
||||
|
||||
@ -195,6 +195,9 @@ public:
|
||||
const share::schema::ObColumnSchemaV2& gen_col_schema, ObRawExpr*& expr,
|
||||
const ObSchemaChecker* schema_checker = NULL,
|
||||
const ObResolverUtils::PureFunctionCheckStatus check_status = ObResolverUtils::DISABLE_CHECK);
|
||||
static int build_pad_expr_recursively(ObRawExprFactory& expr_factory, const ObSQLSessionInfo& session,
|
||||
const share::schema::ObTableSchema& table_schema, const share::schema::ObColumnSchemaV2& gen_col_schema,
|
||||
ObRawExpr*& expr);
|
||||
static int build_raw_expr(ObRawExprFactory& expr_factory, const ObSQLSessionInfo& session_info, const ParseNode& node,
|
||||
ObRawExpr*& expr, common::ObIArray<ObQualifiedName>& columns, common::ObIArray<ObVarInfo>& sys_vars,
|
||||
common::ObIArray<ObAggFunRawExpr*>& aggr_exprs, common::ObIArray<ObWinFunRawExpr*>& win_exprs,
|
||||
@ -273,10 +276,11 @@ public:
|
||||
static int create_param_expr(
|
||||
ObRawExprFactory& expr_factory, int64_t param_idx, ObRawExpr*& expr, bool is_exec_param = false);
|
||||
static int build_trim_expr(const share::schema::ObColumnSchemaV2* column_schema, ObRawExprFactory& expr_factory,
|
||||
ObSQLSessionInfo* session_info, ObRawExpr*& expr);
|
||||
const ObSQLSessionInfo* session_info, ObRawExpr*& expr);
|
||||
static bool need_column_conv(const ColumnItem& column, ObRawExpr& expr);
|
||||
static int build_pad_expr(ObRawExprFactory& expr_factory, bool is_char,
|
||||
const share::schema::ObColumnSchemaV2* column_schema, ObRawExpr*& expr, sql::ObSQLSessionInfo* session_info);
|
||||
const share::schema::ObColumnSchemaV2* column_schema, ObRawExpr*& expr,
|
||||
const sql::ObSQLSessionInfo* session_info);
|
||||
static bool need_column_conv(const ObExprResType& expected_type, const ObRawExpr& expr);
|
||||
static int build_column_conv_expr(ObRawExprFactory& expr_factory,
|
||||
const share::schema::ObColumnSchemaV2* column_schema, ObRawExpr*& expr,
|
||||
|
||||
Reference in New Issue
Block a user