From 3809d9261c2ca8f2c8de422a06228f3b20617ca4 Mon Sep 17 00:00:00 2001 From: lukeman Date: Thu, 1 Aug 2024 10:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A4=84=E7=90=868.0=20core=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=91blob=E5=AD=97=E7=AC=A6=E5=BA=8F=E6=96=AD?= =?UTF-8?q?=E8=A8=80=E5=AF=BC=E8=87=B4core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/nodes/nodeFuncs.cpp | 15 +++++++++++++-- src/gausskernel/optimizer/commands/view.cpp | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/common/backend/nodes/nodeFuncs.cpp b/src/common/backend/nodes/nodeFuncs.cpp index a1c04ce1a..17a9d9512 100644 --- a/src/common/backend/nodes/nodeFuncs.cpp +++ b/src/common/backend/nodes/nodeFuncs.cpp @@ -34,12 +34,14 @@ #endif /* FRONTEND_PARSER */ #include "storage/tcap.h" #include "parser/parse_utilcmd.h" +#include "parser/parse_type.h" static bool query_check_no_flt_walker(Node* node, void* context); static bool query_check_srf_walker(Node* node, void* context); static bool expression_returns_set_walker(Node* node, void* context); static bool expression_rownum_walker(Node* node, void* context); static int leftmostLoc(int loc1, int loc2); +static void AssertExprCollation(const Node* expr, Oid collation); Oid userSetElemTypeCollInfo(const Node* expr, Oid (*exprFunc)(const Node*)); /* @@ -1070,6 +1072,15 @@ Oid exprInputCollation(const Node* expr) return coll; } +static void AssertExprCollation(const Node* expr, Oid collation) +{ + Oid expr_collation = exprCollation(expr); + if (DB_IS_CMPT(B_FORMAT) && ENABLE_MULTI_CHARSET && IsBinaryType(exprType(expr))) { + expr_collation = BINARY_COLLATION_OID; + } + Assert(collation == expr_collation); +} + /* * exprSetCollation - * Assign collation information to an expression tree node. @@ -1114,7 +1125,7 @@ void exprSetCollation(Node* expr, Oid collation) ((FuncExpr*)expr)->funccollid = collation; break; case T_NamedArgExpr: - Assert(collation == exprCollation((Node*)((NamedArgExpr*)expr)->arg)); + AssertExprCollation((Node*)((NamedArgExpr*)expr)->arg, collation); break; case T_OpExpr: ((OpExpr*)expr)->opcollid = collation; @@ -1148,7 +1159,7 @@ void exprSetCollation(Node* expr, Oid collation) tent = (TargetEntry*)linitial(qtree->targetList); Assert(IsA(tent, TargetEntry)); Assert(!tent->resjunk); - Assert(collation == exprCollation((Node*)tent->expr)); + AssertExprCollation((Node*)tent->expr, collation); } else { /* for all other sublink types, result is boolean */ Assert(!OidIsValid(collation)); diff --git a/src/gausskernel/optimizer/commands/view.cpp b/src/gausskernel/optimizer/commands/view.cpp index d0a2b9aad..1d2f171fe 100644 --- a/src/gausskernel/optimizer/commands/view.cpp +++ b/src/gausskernel/optimizer/commands/view.cpp @@ -46,6 +46,7 @@ #include "utils/rel_gs.h" #include "utils/syscache.h" #include "foreign/foreign.h" +#include "parser/parse_type.h" #ifdef PGXC #include "pgxc/execRemote.h" #include "tcop/utility.h" @@ -158,8 +159,9 @@ static ObjectAddress DefineVirtualRelation(RangeVar* relation, List* tlist, bool (errcode(ERRCODE_INDETERMINATE_COLLATION), errmsg("could not determine which collation to use for view column \"%s\"", def->colname), errhint("Use the COLLATE clause to set the collation explicitly."))); - } else + } else if (!(DB_IS_CMPT(B_FORMAT) && ENABLE_MULTI_CHARSET && IsBinaryType(exprType((Node*)tle->expr)))) { Assert(!OidIsValid(def->collOid)); + } def->constraints = NIL; attrList = lappend(attrList, def);