From e0a30b9c24b683009f853f74b80ce5036d4aa2d3 Mon Sep 17 00:00:00 2001 From: GroundWu <1175416256@qq.com> Date: Wed, 24 May 2023 06:47:14 +0000 Subject: [PATCH] [xmlbugfix] fix core caused by window func partition-by-clause use xmltype column which cmp func is NULL --- src/share/datum/ob_datum_cmp_func_def.h | 12 ++++ src/share/datum/ob_datum_funcs.cpp | 57 +++++++++++++++---- .../code_generator/ob_static_engine_cg.cpp | 4 ++ 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/src/share/datum/ob_datum_cmp_func_def.h b/src/share/datum/ob_datum_cmp_func_def.h index 6ebc749b55..ba54a5914e 100644 --- a/src/share/datum/ob_datum_cmp_func_def.h +++ b/src/share/datum/ob_datum_cmp_func_def.h @@ -383,6 +383,18 @@ struct ObDatumGeoCmp : public ObDefined<> } }; +template +struct ObDatumUDTCmp : public ObDefined<> +{ + inline static int cmp(const ObDatum &l, const ObDatum &r, int &cmp_ret) + { + UNUSED(l); + UNUSED(r); + UNUSED(cmp_ret); + return OB_ERR_NO_ORDER_MAP_SQL; + } +}; + /////////////////////////////////////////////////////////////////////////////// // begin define string compare functions /////////////////////////////////////////////////////////////////////////////// diff --git a/src/share/datum/ob_datum_funcs.cpp b/src/share/datum/ob_datum_funcs.cpp index 24556f2244..4b6f7cb80c 100644 --- a/src/share/datum/ob_datum_funcs.cpp +++ b/src/share/datum/ob_datum_funcs.cpp @@ -167,6 +167,14 @@ struct ObNullSafeDatumGeoCmp } }; +template +struct ObNullSafeDatumUDTCmp +{ + inline static int cmp(const ObDatum &l, const ObDatum &r, int &cmp_ret) { + return datum_cmp::ObDatumUDTCmp::cmp(l, r, cmp_ret); + } +}; + template struct ObNullSafeFixedDoubleCmp { @@ -512,6 +520,25 @@ struct DatumGeoHashCalculator : public DefHashMethod } }; +template +struct DatumUDTHashCalculator : public DefHashMethod +{ + static int calc_datum_hash(const ObDatum &datum, const uint64_t seed, uint64_t &res) + { + UNUSED(datum); + UNUSED(seed); + UNUSED(res); + return OB_NOT_SUPPORTED; + } + + static int calc_datum_hash_v2(const ObDatum &datum, const uint64_t seed, uint64_t &res) + { + UNUSED(datum); + UNUSED(seed); + UNUSED(res); + return OB_NOT_SUPPORTED; + } +}; #define DEF_DATUM_TIMESTAMP_HASH_FUNCS(OBJTYPE, TYPE, DESC, VTYPE) \ template \ @@ -1085,26 +1112,32 @@ template struct InitUDTBasicFuncArray { // only for storage use, udt types are used as null bitmap in storage + // storage will use murmur_hash_ and null_last_cmp_ maybe, so keep the origin basic func define and others + // basic func return error code wheh is called: hash func return OB_NOT_SUPPORTED and cmp func return OB_ERR_NO_ORDER_MAP_SQL template - using Hash = DefHashFunc>; + using StrHash = DefHashFunc>; + template + using Hash = DefHashFunc>; + template + using TypeCmp = ObNullSafeDatumUDTCmp; template using StrCmp = ObNullSafeDatumStrCmp; using Def = datum_cmp::ObDatumStrCmp; static void init_array() { auto &basic_funcs = EXPR_BASIC_UDT_FUNCS; - basic_funcs[X].default_hash_ = NULL; - basic_funcs[X].default_hash_batch_= NULL; - basic_funcs[X].murmur_hash_ = Hash::hash; - basic_funcs[X].murmur_hash_batch_ = NULL; - basic_funcs[X].xx_hash_ = NULL; - basic_funcs[X].xx_hash_batch_ = NULL; - basic_funcs[X].wy_hash_ = NULL; - basic_funcs[X].wy_hash_batch_ = NULL; - basic_funcs[X].null_first_cmp_ = NULL; + basic_funcs[X].default_hash_ = Hash::hash; + basic_funcs[X].default_hash_batch_= Hash::hash_batch; + basic_funcs[X].murmur_hash_ = StrHash::hash; + basic_funcs[X].murmur_hash_batch_ = Hash::hash_batch; + basic_funcs[X].xx_hash_ = Hash::hash; + basic_funcs[X].xx_hash_batch_ = Hash::hash_batch; + basic_funcs[X].wy_hash_ = Hash::hash; + basic_funcs[X].wy_hash_batch_ = Hash::hash_batch; + basic_funcs[X].null_first_cmp_ = &TypeCmp<1, 1>::cmp; basic_funcs[X].null_last_cmp_ = Def::defined_ ? &StrCmp<0>::cmp : NULL; - basic_funcs[X].murmur_hash_v2_ = NULL; - basic_funcs[X].murmur_hash_v2_batch_ = NULL; + basic_funcs[X].murmur_hash_v2_ = Hash::hash_v2; + basic_funcs[X].murmur_hash_v2_batch_ = Hash::hash_v2_batch; } }; diff --git a/src/sql/code_generator/ob_static_engine_cg.cpp b/src/sql/code_generator/ob_static_engine_cg.cpp index 807db1727e..47077b19fb 100644 --- a/src/sql/code_generator/ob_static_engine_cg.cpp +++ b/src/sql/code_generator/ob_static_engine_cg.cpp @@ -6049,6 +6049,10 @@ int ObStaticEngineCG::fill_wf_info(ObIArray &all_expr, } else if (OB_ISNULL(expr)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("expr is null ", K(ret), K(expr)); + } else if (ob_is_user_defined_sql_type(expr->datum_meta_.type_) || ob_is_user_defined_pl_type(expr->datum_meta_.type_)) { + // partition by clause not support xmltype + ret = OB_ERR_NO_ORDER_MAP_SQL; + LOG_WARN("cannot ORDER objects without MAP or ORDER method", K(ret)); } else if (OB_FAIL(wf_info.partition_exprs_.push_back(expr))) { LOG_WARN("push_back failed", K(ret), K(expr)); }