Re: Re: Fwd: BUG #17017: Two versions of the same row of records are returned in one query

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: 李可强 <52194501011(at)stu(dot)ecnu(dot)edu(dot)cn>
Cc: tgl <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Re: Fwd: BUG #17017: Two versions of the same row of records are returned in one query
Date: 2022-10-06 16:06:46
Message-ID: CAH2-WzkHd2LApLxFqybz46tvgKcOp7vkE5uN5iV6jjpnMXcDOA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Oct 6, 2022 at 12:28 AM 李可强 <52194501011(at)stu(dot)ecnu(dot)edu(dot)cn> wrote:
> You have mentioned that "a predicate on the PK is not special in Postgres". Does it mean that PG takes PK as a common column instead of the identifier of rows if selecting rows by a predicate on the PK?

I'm not 100% sure that I understand this question, but I think that
the answer is yes.

> For example, in my mentioned bug case, the query on PG returns two rows which have the same PK. From my point of view, such a behavior violates the primary key unique constraint.

I believe that your argument is correct (it is wrong) according to some
interpretations of "repeatable read". What Postgres calls repeatable
read is actually snapshot isolation.

The simple fact is that the terminology in this area is confusing, and
it seems as if nobody agrees on all the details. It is generally
understood that the behavior that Postgres calls "repeatable read" is
actually snapshot isolation (same is true of Oracle). So the behavior
that you find surprising is not surprising to us, and is not
considered a bug. I am sympathetic, but it's not going to change now.

This point is made clear in the documentation:

https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ

"A Critique of ANSI SQL Isolation Levels" by Berenson et al explains
this controversy in great detail.

--
Peter Geoghegan

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2022-10-06 16:57:53 Re: v15rc2(/v15rc1/v15b4) shadowbuild fails when using src from symlink
Previous Message Frank van Vugt 2022-10-06 15:16:40 v15rc2(/v15rc1/v15b4) shadowbuild fails when using src from symlink