Re: BUG #19493: Assertion failure in pg_plan_advice with EXISTS subquery and DO_NOT_SCAN advice

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, Калинин Никита <n(dot)kalinin(at)postgrespro(dot)ru>, Michael Paquier <michael(at)paquier(dot)xyz>, Pierre Forstmann <pierre(dot)forstmann(at)gmail(dot)com>
Subject: Re: BUG #19493: Assertion failure in pg_plan_advice with EXISTS subquery and DO_NOT_SCAN advice
Date: 2026-05-29 02:03:50
Message-ID: CAHewXNkVe1TQ1gi0_PzJhXw82AGK85Jc8+sLgC_CdtOzP_v+GA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi all,

Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> 于2026年5月27日周三 15:16写道:
>
> Hi,
>
> On Wed, 27 May 2026 at 09:20, Tender Wang <tndrwang(at)gmail(dot)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

Attachment Content-Type Size
0001-pg_plan_advice-fix-assertion-failure-with-ordered-li.patch application/octet-stream 5.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2026-05-29 04:00:01 Re: BUG #19494: Error on transaction commit inside pipeline triggers psql's Assert
Previous Message Tom Lane 2026-05-28 15:12:26 Re: BUG #19480: PL/Python SRF crashes (SIGSEGV) when function is replaced mid-iteration: use-after-free in PLy_funct