Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/6189~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/6189
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Dec 5, 2025

  1. Fix distinctness check for queries with grouping sets

    query_is_distinct_for() is intended to determine whether a query never
    returns duplicates of the specified columns.  For queries using
    grouping sets, if there are no grouping expressions, the query may
    contain one or more empty grouping sets.  The goal is to detect
    whether there is exactly one empty grouping set, in which case the
    query would return a single row and thus be distinct.
    
    The previous logic in query_is_distinct_for() was incomplete because
    the check was insufficiently thorough and could return false when it
    could have returned true.  It failed to consider cases where the
    DISTINCT clause is used on the GROUP BY, in which case duplicate empty
    grouping sets are removed, leaving only one.  It also did not
    correctly handle all possible structures of GroupingSet nodes that
    represent a single empty grouping set.
    
    To fix, add a check for the groupDistinct flag, and expand the query's
    groupingSets tree into a flat list, then verify that the expanded list
    contains only one element.
    
    No backpatch as this could result in plan changes.
    
    Author: Richard Guo <guofenglinux@gmail.com>
    Discussion: https://postgr.es/m/CAMbWs480Z04NtP8-O55uROq2Zego309+h3hhaZhz6ztmgWLEBw@mail.gmail.com
    guofengrichard authored and Commitfest Bot committed Dec 5, 2025
    Configuration menu
    Copy the full SHA
    9ac8bcc View commit details
    Browse the repository at this point in the history
  2. [CF 6189] v3 - Fix distinctness check for queries with grouping sets

    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/6189
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/CAMbWs49HrvGcVqX7YBFkU0o9ev_-9Xq=PySUfv-4winKye_6fg@mail.gmail.com
    Author(s): Richard Guo
    Commitfest Bot committed Dec 5, 2025
    Configuration menu
    Copy the full SHA
    6f161c9 View commit details
    Browse the repository at this point in the history
Loading