From: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> |
---|---|
To: | Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: outer joins and for update |
Date: | 2005-11-14 23:41:58 |
Message-ID: | 20051114234158.GV18570@pervasive.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Nov 15, 2005 at 02:22:15AM +1100, Gavin Sherry wrote:
> On Mon, 14 Nov 2005, Tom Lane wrote:
> > is that you have exclusive hold on the selected rows and they won't
> > change underneath you before the end of your transaction. In the case
> > of an outer join where the left-side row joined to nothing on the
> > right-side, we can't guarantee that: repeating the SELECT might find a
> > matching right-side row, thereby changing the allegedly-locked join row.
> > To guarantee a stable view of the data, we'd need a predicate lock that
> > prevents a matching right-side row from being inserted.
>
> Well.... we can guarantee that we wont see rows added by concurrent
> transactions if we're in serializable isolation level :-).
Do we really need to prevent inserts from happening under a SELECT FOR
UPDATE? ISTM that's trying to apply serializable concurrency to SELECT
FOR UPDATE even if it's running in a read committed transaction. In the
single table case we don't prevent someone from inserting a value...
# session 1
decibel=# insert into t values('1');
INSERT 633175 1
# session 2
decibel=# begin;
BEGIN
decibel=# select * from t where t='1' for update;
t
---
1
(1 row)
# session 1
decibel=# insert into t values('1');
INSERT 633176 1
decibel=# select * from t;
t
---
1
1
(2 rows)
decibel=# update t set t='2';
# Blocks on session 2
Am I missing something here?
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2005-11-15 00:00:23 | Re: PostgreSQL roadmap for 8.2 and beyond. |
Previous Message | Tom Lane | 2005-11-14 23:36:26 | Re: functions marked STABLE not allowed to do INSERT |