Fix: column_conv type inference set wrong collation_level
This commit is contained in:
		| @ -20,6 +20,7 @@ | ||||
| #include "sql/engine/ob_exec_context.h" | ||||
| #include "sql/engine/expr/ob_expr_lob_utils.h" | ||||
| #include "lib/geo/ob_geo_utils.h" | ||||
| #include "sql/resolver/expr/ob_raw_expr_util.h" | ||||
|  | ||||
| using namespace oceanbase::common; | ||||
|  | ||||
| @ -239,7 +240,9 @@ int ObExprColumnConv::calc_result_typeN(ObExprResType &type, | ||||
|   } else { | ||||
|     type.set_type(types[0].get_type()); | ||||
|     type.set_collation_type(types[1].get_collation_type()); | ||||
|     type.set_collation_level(common::CS_LEVEL_IMPLICIT); | ||||
|     // set collation level | ||||
|     ObCollationLevel coll_level = ObRawExprUtils::get_column_collation_level(types[0].get_type()); | ||||
|     type.set_collation_level(coll_level); | ||||
|     type.set_accuracy(types[2].get_accuracy()); | ||||
|     if (type.get_type() == ObUserDefinedSQLType) { | ||||
|       type.set_subschema_id(types[2].get_accuracy().get_accuracy()); | ||||
|  | ||||
| @ -6208,6 +6208,19 @@ bool ObRawExprUtils::is_same_column_ref(const ObRawExpr *column_ref1, const ObRa | ||||
|   return bret; | ||||
| } | ||||
|  | ||||
|  | ||||
| ObCollationLevel ObRawExprUtils::get_column_collation_level(const common::ObObjType &type) | ||||
| { | ||||
|   if (ob_is_string_type(type) | ||||
|       || ob_is_enumset_tc(type) | ||||
|       || ob_is_json_tc(type) | ||||
|       || ob_is_geometry_tc(type)) { | ||||
|     return CS_LEVEL_IMPLICIT; | ||||
|   } else { | ||||
|     return CS_LEVEL_NUMERIC; | ||||
|   } | ||||
| } | ||||
|  | ||||
| int ObRawExprUtils::init_column_expr(const ObColumnSchemaV2 &column_schema, ObColumnRefRawExpr &column_expr) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
| @ -6228,11 +6241,11 @@ int ObRawExprUtils::init_column_expr(const ObColumnSchemaV2 &column_schema, ObCo | ||||
|       || ob_is_json_tc(column_schema.get_data_type()) | ||||
|       || ob_is_geometry_tc(column_schema.get_data_type())) { | ||||
|     column_expr.set_collation_type(column_schema.get_collation_type()); | ||||
|     column_expr.set_collation_level(CS_LEVEL_IMPLICIT); | ||||
|   } else { | ||||
|     column_expr.set_collation_type(CS_TYPE_BINARY); | ||||
|     column_expr.set_collation_level(CS_LEVEL_NUMERIC); | ||||
|   } | ||||
|   // extract set collation level for reuse | ||||
|   column_expr.set_collation_level(get_column_collation_level(column_schema.get_data_type())); | ||||
|  | ||||
|   if (OB_SUCC(ret)) { | ||||
|     column_expr.set_accuracy(accuracy); | ||||
|  | ||||
| @ -798,6 +798,7 @@ public: | ||||
|                                     int64_t project_index, | ||||
|                                     ObAliasRefRawExpr *&alias_expr); | ||||
|   static int init_column_expr(const share::schema::ObColumnSchemaV2 &column_schema, ObColumnRefRawExpr &column_expr); | ||||
|   static ObCollationLevel get_column_collation_level(const common::ObObjType &type); | ||||
|   /* 计算基本列的flag */ | ||||
|   static uint32_t calc_column_result_flag(const share::schema::ObColumnSchemaV2 &column_schema); | ||||
|   static int expr_is_order_consistent(const ObRawExpr *from, const ObRawExpr *to, bool &is_consistent); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 yaojing624
					yaojing624