Re: BUG #17983: Assert IsTransactionState() failed when empty string statement prepared in aborted transaction

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17983: Assert IsTransactionState() failed when empty string statement prepared in aborted transaction
Date: 2023-06-20 16:32:27
Message-ID: 3505791.1687278747@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Japin Li <japinli(at)hotmail(dot)com> writes:
> On Tue, 20 Jun 2023 at 03:00, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
>> The following psql script:
>> BEGIN;
>> ERROR;
>> ;
>> \gdesc
>> triggers an assertion failure with the following stack trace:

>> so maybe an empty input string is not legal for creating a cached plan
>> when the transaction is aborted?

> Yeah, SearchSysCache1() need in an transaction block, here is a patch
> fixed it.

I'm not sure if anyone out there is expecting that this case should
work, but it probably did work at one time. Rather than throwing
an error, it'd be better to fix plancache.c so it doesn't fail.
I looked at the code and found that that's pretty much a one-line
fix, because there are already code paths that avoid doing anything
extra for transaction control commands (e.g ROLLBACK, which'd
otherwise have this same issue). We just need to make a NULL
parsetree use those paths.

> Another question, why should we need to create a plan cache entry for
> empty input?

Well, we have to have something to support the wire protocol behavior
for this case. No doubt we could hack up postgres.c to handle it
without a plan cache entry, but it'd be far more invasive to do it
there.

regards, tom lane

Attachment Content-Type Size
dont-fail-on-preparing-empty-statement.patch text/x-diff 646 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2023-06-20 16:34:22 Re: BUG #17984: Service stopped and cannot restart
Previous Message PG Bug reporting form 2023-06-20 16:03:22 BUG #17985: Inconsistent results of SELECT comparing two CASE WHEN clause