agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: marlene.brandstaetter@cargonet.software
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: Mistake in statement example
Date: Fri, 1 Nov 2024 16:38:39 -0400
Message-ID: <ZyU8T1Ru7m7feTcj@momjian.us> (raw)
In-Reply-To: <ZRS5XbHrqhqJQt99@momjian.us>
References: <167765529052.987840.12345375075704447735@wrigleys.postgresql.org>
	<1522262.1677688451@sss.pgh.pa.us>
	<CAKFQuwadh0Q9WgQjRL=Uq8Fdm8pi6gfVpjX=ZWHNNTVkRpnvkg@mail.gmail.com>
	<ZRS5XbHrqhqJQt99@momjian.us>

On Wed, Sep 27, 2023 at 07:23:09PM -0400, Bruce Momjian wrote:
> On Wed, Mar  1, 2023 at 09:45:00AM -0700, David G. Johnston wrote:
> > That may be, but the descriptive text and point of the example (which isn't
> > atomicity, but concurrency) doesn't even require the second update command to
> > be present.  What the example could use is a more traditional two-session
> > depiction of the commands instead of having a single transaction and letting
> > the user envision the correct concurrency.
> > 
> > Something like:
> > 
> > S1: SELECT balance FROM accounts WHERE acctnum = 12345; //100
> > S1: BEGIN;
> > S2: BEGIN;
> > S1: UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345; //200
> > S2: UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345; //
> > WAITING ON S1
> > S1: COMMIT;
> > S2: UPDATED; balance = 300
> > S2: COMMIT;
> > 
> > Though maybe "balance" isn't a good example domain, the incrementing example
> > used just after this one seems more appropriate along with the added benefit of
> > consistency.
> 
> I developed the attached patch.  I explained the example, I mentioned a
> "second" transaciton, I changed the account number so I can talk about
> the second statement, because read committed changes the row visibility
> of the non-first statements, and I changed "transaction" to "statement".

Patch from September 2023 applied.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  When a patient asks the doctor, "Am I going to die?", he means 
  "Am I going to die soon?"





view thread (5+ messages)

Message-ID: <ZyU8T1Ru7m7feTcj@momjian.us>
Permalink:  ../ZyU8T1Ru7m7feTcj@momjian.us/
Also on:    postgresql.org/message-id/ZyU8T1Ru7m7feTcj@momjian.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: bruce@momjian.us, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us, marlene.brandstaetter@cargonet.software, pgsql-docs@lists.postgresql.org
  Subject: Re: Mistake in statement example
  In-Reply-To: <ZyU8T1Ru7m7feTcj@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox