Re: An oversight in ExecInitAgg for grouping sets

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: An oversight in ExecInitAgg for grouping sets
Date: 2022-12-27 07:12:17
Message-ID: CAMbWs49nMd1up4BOq=gXutTJintTUpe1u3qxvhRhPj9=9h5U=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 22, 2022 at 2:02 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

> I happened to notice $subject. It happens when we build eqfunctions for
> each grouping set.
>
> /* for each grouping set */
> for (int k = 0; k < phasedata->numsets; k++)
> {
> int length = phasedata->gset_lengths[k];
>
> if (phasedata->eqfunctions[length - 1] != NULL)
> continue;
>
> phasedata->eqfunctions[length - 1] =
> execTuplesMatchPrepare(scanDesc,
> length,
> aggnode->grpColIdx,
> aggnode->grpOperators,
> aggnode->grpCollations,
> (PlanState *) aggstate);
> }
>
> If it is an empty grouping set, its length will be zero, and accessing
> phasedata->eqfunctions[length - 1] is not right.
>
> I think we can just skip building the eqfunctions for empty grouping
> set.
>

Attached is a trivial patch for the fix.

Thanks
Richard

Attachment Content-Type Size
v1-0001-Skip-building-eqfunctions-for-empty-grouping-set.patch application/octet-stream 783 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2022-12-27 07:30:25 Re: New strategies for freezing, advancing relfrozenxid early
Previous Message Hayato Kuroda (Fujitsu) 2022-12-27 07:09:31 RE: Time delayed LR (WAS Re: logical replication restrictions)