From eade8a4b3474e63b20d3edddaba3fe47ec7cb06e Mon Sep 17 00:00:00 2001 From: Richard Guo Date: Mon, 25 Sep 2023 17:33:20 +0800 Subject: [PATCH v2] Fix a wrong comment in setrefs.c --- src/backend/optimizer/plan/setrefs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index fc3709510d..4bb68ac90e 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -2936,7 +2936,14 @@ search_indexed_tlist_for_sortgroupref(Expr *node, { TargetEntry *tle = (TargetEntry *) lfirst(lc); - /* The equal() check should be redundant, but let's be paranoid */ + /* + * Usually the equal() check is redundant, but in setop plans it may + * not be, since prepunion.c assigns ressortgroupref equal to the + * column resno without regard to whether that matches the topmost + * level's sortgrouprefs and without regard to whether any implicit + * coercions are added in the setop tree. We might have to clean that + * up someday; but for now, just ignore any false matches. + */ if (tle->ressortgroupref == sortgroupref && equal(node, tle->expr)) { -- 2.31.0