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);