Re: confusing comment in tqual.c - Mailing list pgsql-hackers

From Tom Lane
Subject Re: confusing comment in tqual.c
Date
Msg-id 2330.1158336710@sss.pgh.pa.us
Whole thread Raw
In response to confusing comment in tqual.c  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
Gregory Stark <stark@enterprisedb.com> writes:
> I'm reading the code in tqual.c and find that this comment doesn't seem to
> match the code. CommandId always seems to be compared with >= or <= rather
> than equality as the comment says.

Yeah, you're right, the comment seems to be written on the assumption
that it's not possible to see cmin or cmax > curcid ... but that is
possible given sufficiently bizarre programming (eg, query fires a
function or trigger that updates the table again while outer query is
still scanning).  The actual rule for "now" is that a change made in the
current transaction is considered to have taken effect if its cmin or
cmax is strictly less than the current command's CID.

(Hmm ... actually, given the limited ways in which SnapshotNow is used,
I guess it's possible that indeed this can never happen.  The code is
made to be parallel to similar tests in SatisfiesSnapshot, which
definitely can see the sort of scenario mentioned above.)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: New version of money type
Next
From: Andrew - Supernews
Date:
Subject: Re: New version of money type