pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13769: SELECT ... FROM a JOIN b FOR UPDATE a; BREAKS SNAPSHOT
2+ messages / 2 participants
[nested] [flat]

* BUG #13769: SELECT ... FROM a JOIN b FOR UPDATE a; BREAKS SNAPSHOT
@ 2015-11-11 15:10  konst583@mail.ru
  0 siblings, 1 reply; 2+ messages in thread

From: konst583@mail.ru @ 2015-11-11 15:10 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      13769
Logged by:          Konstantin Evteev
Email address:      konst583@mail.ru
PostgreSQL version: 9.2.13
Operating system:   Debian GNU/Linux 7.9 (wheezy)
Description:        

Select of 2-nd transaction will return new value from a and old value from
b

CREATE TABLE a
(
  id integer,
  val1 integer
);

CREATE TABLE b
(
  id integer,
  val1 integer
);

insert into a select 1,2;
insert into b select 1,3;

--FIRST TRANSACTION
begin

select * from a inner join b 
on 
    a.id = b.id 
where 
    a.id =1 for update of a;

update a set val1 = 0 where id = 1;
update b set val1 =0 where id = 1;

end

-- SECOND TRANSACTION (starts during executing of first transaction)
 select * from a
inner join 
b on a.id = b.id 
 where a.id =1 for update of a

 --result:
 1;0;1;3


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #13769: SELECT ... FROM a JOIN b FOR UPDATE a; BREAKS SNAPSHOT
@ 2015-11-11 15:23  Tom Lane <tgl@sss.pgh.pa.us>
  parent: konst583@mail.ru
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2015-11-11 15:23 UTC (permalink / raw)
  To: konst583@mail.ru; +Cc: pgsql-bugs

konst583@mail.ru writes:
> Select of 2-nd transaction will return new value from a and old value from
> b

That's what FOR UPDATE is designed to do.  If you don't like it, use
serializable mode.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-11-11 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-11-11 15:10 BUG #13769: SELECT ... FROM a JOIN b FOR UPDATE a; BREAKS SNAPSHOT konst583@mail.ru
2015-11-11 15:23 ` Tom Lane <tgl@sss.pgh.pa.us>

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