From 7bb0e8a6716f7d378b06cd03550cf911edb84ef1 Mon Sep 17 00:00:00 2001 From: chaotian Date: Thu, 30 Nov 2023 10:15:48 +0800 Subject: [PATCH v2] fix dump view fails with group by clause --- src/backend/utils/adt/ruleutils.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index ed7f40f053..eb5e28e279 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -6317,6 +6317,28 @@ get_rule_sortgroupclause(Index ref, List *tlist, bool force_colno, } else if (expr && IsA(expr, Const)) get_const_expr((Const *) expr, context, 1); + else if (expr && IsA(expr, OpExpr)) + { + OpExpr *opexpr = (OpExpr *)expr; + List *args = opexpr->args; + + /* + * Cost-folder the expression(opexpr plus const) to negative const, + * mainly there are two operators we need to worried about, namely + * in4um(558) and numeric_uminus(1751), and get_const_expr() is + * responsible for end up getting labeled with a typecast. + */ + if (list_length(args) == 1) + { + Node *arg = (Node *) linitial(args); + Oid opno = opexpr->opno; + + if ((opno == 558 || opno == 1751) && IsA(arg, Const)) + expr = (Node *)expression_planner((Expr *)expr); + } + + get_rule_expr(expr, context, true); + } else if (!expr || IsA(expr, Var)) get_rule_expr(expr, context, true); else -- 2.39.2 (Apple Git-143)