Re: BUG #19493: Assertion failure in pg_plan_advice with EXISTS subquery and DO_NOT_SCAN advice
Tender Wang <tndrwang@gmail.com>
From: Tender Wang <tndrwang@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Cc: Robert Haas <robertmhaas@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Ayush Tiwari <ayushtiwari.slg01@gmail.com>, Калинин Никита <n.kalinin@postgrespro.ru>, Michael Paquier <michael@paquier.xyz>, Pierre Forstmann <pierre.forstmann@gmail.com>
Date: 2026-05-29T02:03:50Z
Lists: pgsql-bugs
Attachments
- 0001-pg_plan_advice-fix-assertion-failure-with-ordered-li.patch (application/octet-stream) patch 0001
Hi all, Ayush Tiwari <ayushtiwari.slg01@gmail.com> 于2026年5月27日周三 15:16写道: > > Hi, > > On Wed, 27 May 2026 at 09:20, Tender Wang <tndrwang@gmail.com> wrote: >> >> Hi, all >> >> I find an easier way as follows: >> diff --git a/contrib/pg_plan_advice/pgpa_trove.c >> b/contrib/pg_plan_advice/pgpa_trove.c >> index ca69f3bd3df..64af4b1435b 100644 >> --- a/contrib/pg_plan_advice/pgpa_trove.c >> +++ b/contrib/pg_plan_advice/pgpa_trove.c >> @@ -179,7 +179,6 @@ pgpa_build_trove(List *advice_items) >> * but in the future this >> might not be true, e.g. a custom >> * scan could replace a join. >> */ >> - Assert(target->ttype == >> PGPA_TARGET_IDENTIFIER); >> pgpa_trove_add_to_slice(&trove->scan, >> >> item->tag, target); >> } > > > Thanks for checking this. > > I agree that removing the assertion looks like the better approach. I attached a patch to fix this issue. In syntax.sql, I saw this: " -- Tags like SEQ_SCAN and NO_GATHER don't allow sublists at all; other tags, -- except for JOIN_ORDER, allow at most one level of sublist. Hence, these -- examples should error out. " So 'DO_NOT_SCAN((x))' is valid syntax. The original codes in pgpa_build_trove() may forget about this case. I added this syntax case to the syntax.sql. I also added the query to scan.sql and adjusted the original comments. -- Thanks, Tender Wang
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pg_plan_advice: DO_NOT_SCAN is a simple tag, not a generic one.
- b1901e2895e0 19 (unreleased) landed
-
doc: add comma to UPDATE docs, for consistency
- 9a41b34a2870 19 (unreleased) cited
-
Add stack depth check to QueueFKConstraintValidation().
- 61ea5cc6a61f 19 (unreleased) cited