Re: The documentation for READ COMMITTED may be incomplete or wrong

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Aleksander Alekseev <aleksander(at)timescale(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: The documentation for READ COMMITTED may be incomplete or wrong
Date: 2023-05-18 23:57:14
Message-ID: 4111741.1684454234@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Debian Code Search doesn't know of any outside code touching
> relsubs_done, so I think we are safe in dropping that code in
> ExecScanReScan. It seems quite pointless anyway considering
> that up to now, EvalPlanQualBegin has always zeroed the whole
> array.

Oh, belay that. What I'd forgotten is that it's possible that
the target relation is on the inside of a nestloop, meaning that
we might need to fetch the EPQ substitute tuple more than once.
So there are three possible states: blocked (never return a
tuple), ready to return a tuple, and done returning a tuple
for this scan. ExecScanReScan needs to reset "done" to "ready",
but not touch the "blocked" state. The attached v2 mechanizes
that using two bool arrays.

What I'm thinking about doing to back-patch this is to replace
one of the pointer fields in EPQState with a pointer to a
subsidiary palloc'd structure, where we can put the new fields
along with the cannibalized old one. We've done something
similar before, and it seems a lot safer than having basically
different logic in v16 than earlier branches.

regards, tom lane

Attachment Content-Type Size
v2-fix-EPQ-HEAD-only.patch text/x-diff 15.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2023-05-19 01:04:13 Re: Missing update of all_hasnulls in BRIN opclasses
Previous Message Stephen Frost 2023-05-18 23:53:58 Re: Adding SHOW CREATE TABLE