Re: BUG #19976: Internal planner error: ERROR: XX000: too late to create a new PlaceHolderInfo

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: 798604270(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19976: Internal planner error: ERROR: XX000: too late to create a new PlaceHolderInfo
Date: 2026-12-05 06:52:28
Message-ID: CAMbWs4_RoZU0xn_f0wvBxbBX6tbynxUqAfz3V-tSasRjbEbAxQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Dec 4, 2026 at 9:44 PM PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> -- Trigger (pure default GUCs -> ERROR: XX000: too late to create a new
> PlaceHolderInfo):
> BEGIN;
> SET LOCAL ROLE pg_v4s_001_user;
> SELECT t.k, COUNT(*) AS cnt, SUM(t.gv) AS sgv, MAX(s.v) AS msv
> FROM rt1 t
> LEFT JOIN rsrc s ON t.k = s.k AND s.tenant = 1
> GROUP BY GROUPING SETS ((t.k), ());
> ROLLBACK;
> ```

Thanks for the report. I can reproduce it on master.

The problem is that when the query has grouping sets,
expand_virtual_generated_columns() wraps the expansions in PHVs
everywhere in the query, including the table's securityQuals.
find_placeholders_in_jointree() never looks at securityQuals, so we
never build PlaceHolderInfos for those PHVs, and we error out when
createplan.c looks one up later.

I think we can fix it by processing the securityQuals at each
RangeTblRef; something like attached.

- Richard

Attachment Content-Type Size
v1-0001-Create-PlaceHolderInfos-for-PlaceHolderVars-in-se.patch application/octet-stream 3.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message shihao zhong 2026-12-05 05:06:29 Re: BUG #19968: ALTER COLUMN TYPE fails with internal errors if a dependent object is dropped concurrently