Re: [HACKERS] Confusing results with lateral references

2015-12-09 Thread Robert Haas
On Fri, Dec 4, 2015 at 10:23 AM, Tom Lane wrote: > Ashutosh Bapat writes: >> I am seeing different results with two queries which AFAIU have same >> semantics and hence are expected to give same results. > >> postgres=# select * from t1, (select distinct val, val2 from t2) t2ss where >> t1.val =

Re: [HACKERS] Confusing results with lateral references

2015-12-04 Thread Tom Lane
Ashutosh Bapat writes: > There's another seemingly wrong result, not with lateral, but with FOR > UPDATE. [ shrug... ] You're getting the post-update images of the two join rows that would have been reported without FOR UPDATE. This one is definitely not a bug. regards,

Re: [HACKERS] Confusing results with lateral references

2015-12-04 Thread Tom Lane
Ashutosh Bapat writes: > I am seeing different results with two queries which AFAIU have same > semantics and hence are expected to give same results. > postgres=# select * from t1, (select distinct val, val2 from t2) t2ss where > t1.val = t2ss.val for update of t1; > postgres=# select * from t

Re: [HACKERS] Confusing results with lateral references

2015-12-03 Thread Ashutosh Bapat
On Fri, Dec 4, 2015 at 10:58 AM, Amit Langote wrote: > On 2015/12/03 21:26, Ashutosh Bapat wrote: > > Session 1 > > postgres=# begin; > > BEGIN > > postgres=# update t1 set val = 2 where val2 = 1; > > UPDATE 1 > > > > Session 2 > > postgres=# select * from t1 left join t2 on (t1.val = t2.val) for

Re: [HACKERS] Confusing results with lateral references

2015-12-03 Thread Amit Langote
On 2015/12/03 21:26, Ashutosh Bapat wrote: > Session 1 > postgres=# begin; > BEGIN > postgres=# update t1 set val = 2 where val2 = 1; > UPDATE 1 > > Session 2 > postgres=# select * from t1 left join t2 on (t1.val = t2.val) for update of > t1; > > query waits > > Session 1 > postgres=# commit; >

Re: [HACKERS] Confusing results with lateral references

2015-12-03 Thread Ashutosh Bapat
There's another seemingly wrong result, not with lateral, but with FOR UPDATE. postgres=# select * from t1; val | val2 -+-- 1 |1 (1 row) postgres=# select * from t2; val | val2 -+-- 1 |1 2 |2 1 |1 (3 rows) Session 1 postgres=# begin; BEGIN postgres=#

[HACKERS] Confusing results with lateral references

2015-12-03 Thread Ashutosh Bapat
Hi, I am seeing different results with two queries which AFAIU have same semantics and hence are expected to give same results. postgres=# \d t1 Table "public.t1" Column | Type | Modifiers +-+--- val| integer | val2 | integer | postgres=# \d t2 Tab