Re: v17 Possible Union All Bug

Alexander Korotkov <aekorotkov@gmail.com>

From: Alexander Korotkov <aekorotkov@gmail.com>
To: Andrei Lepikhov <a.lepikhov@postgrespro.ru>
Cc: "David G. Johnston" <david.g.johnston@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, David Rowley <dgrowleyml@gmail.com>, Alexander Korotkov <akorotkov@postgresql.org>, PostgreSQL Bug List <pgsql-bugs@lists.postgresql.org>, Richard Guo <guofenglinux@gmail.com>
Date: 2024-02-07T09:28:32Z
Lists: pgsql-bugs

Attachments

On Sun, Feb 4, 2024 at 6:57 AM Andrei Lepikhov
<a.lepikhov@postgrespro.ru> wrote:
> The simple fix is in the attachment. But I'm not sure we should fix
> GROUP-BY optimization instead of the more general issue.
> The source of the problem is root->group_pathkeys, which contains
> grouping pathkeys and aggregate pathkeys. For now, their 'sortref'
> values could intersect, and we can differ which one references the query
> target list and which one the target list of the aggregate.
> So, I would like to get advice here: should we make a quick fix here, or
> is such a mess in the sortref values not a mess and designed for some
> purposes?

Thank you, Andrei.  I think we should apply this fix for now, while
better refactoring could be done in future.  I've revised your fix
with more comments and a commit message.  I'm going to push it if
there are no objections.

------
Regards,
Alexander Korotkov

Commits

  1. Fix usage of aggregate pathkeys in group_keys_reorder_by_pathkeys()

  2. Move is_valid_ascii() to ascii.h.

  3. Test EXPLAIN (FORMAT JSON) ... XMLTABLE

  4. Add test module injection_points

  5. Fix table name collision in tests in 0452b461bc

  6. Explore alternative orderings of group-by pathkeys during optimization.

  7. Generalize the common code of adding sort before processing of grouping

  8. Reorder actions in ProcArrayApplyRecoveryInfo()

  9. More documentation updates for incremental backup.

  10. Avoid useless ReplicationOriginExitCleanup locking