Re: BUG #17564: Planner bug in combination of generate_series(), unnest() and ORDER BY
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Martijn van Oosterhout <kleptog@gmail.com>,
PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2022-08-03T14:09:12Z
Lists: pgsql-bugs
Richard Guo <guofenglinux@gmail.com> writes: > - if (IS_SRF_CALL((Node *) em->em_expr)) > + if (expression_returns_set((Node *) em->em_expr)) Yeah. I think we need to go further: placed in optimizer.h as it is, IS_SRF_CALL is just an invitation to writing broken code. I think the calls in tlist.c are legit because that code is precisely concerned with breaking down nests of SRFs; but everywhere else, if you write IS_SRF_CALL you're doing it wrong. We should take that macro out of the header altogether. I kind of wonder whether IS_SRF_CALL is a good idea at all. It'd be more maintainable to have an expression_returns_set_one_level, or something like that, placed beside expression_returns_set. regards, tom lane
Commits
-
Add proper regression test for the recent SRFs-in-pathkeys problem.
- cc116479917b 16.0 landed
- 8d38ccafca93 13.8 landed
- 1a9ac84923b8 14.5 landed
- 11e7d626cee4 15.0 landed
-
Fix incorrect tests for SRFs in relation_can_be_sorted_early().
- da4ed7588132 13.8 landed
- 445b9020c97f 14.5 landed
- 1aa8dad41ffa 16.0 landed
- 14168d57bb91 15.0 landed
-
Optimize order of GROUP BY keys
- db0d67db2401 15.0 cited