Re: Functions and transactions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kris Kiger <kris(at)musicrebellion(dot)com>
Cc: "Pgsql-Admin (E-mail)" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Functions and transactions
Date: 2005-03-11 00:10:29
Message-ID: 27098.1110499829@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-hackers pgsql-patches

Kris Kiger <kris(at)musicrebellion(dot)com> writes:
> In your second paragraph, I think that you are saying that SELECT FOR
> UPDATE only locks one row, even though the select itself may return
> many. Am I mis-interpreting you?

No, I'm saying that plpgsql's SELECT INTO operation only reads one row.
The fact that the SELECT might have found more rows if allowed to run
to completion doesn't enter into it. If the first row read doesn't have
active = true then it won't conflict against concurrent UPDATEs, because
you are carefully not UPDATEing rows with active = false. It's the
combination of those two things that creates the hazard.

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message star star 2005-03-11 01:20:12 Unicode!
Previous Message Tom Lane 2005-03-11 00:06:49 Re: index creation in maintenance_work_mem or work_mem

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-03-11 00:21:41 Re: [pgsql-hackers-win32] snprintf causes regression tests
Previous Message Tom Lane 2005-03-10 23:55:06 Re: [pgsql-hackers-win32] snprintf causes regression tests to fail

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-03-11 00:21:41 Re: [pgsql-hackers-win32] snprintf causes regression tests
Previous Message Tom Lane 2005-03-10 23:55:06 Re: [pgsql-hackers-win32] snprintf causes regression tests to fail