Different results between PostgreSQL and Oracle for "for update" statement - Mailing list pgsql-hackers

From Andy Fan
Subject Different results between PostgreSQL and Oracle for "for update" statement
Date
Msg-id CAKU4AWq3rfjZQJBSvmbEsRp6ENArgMmzW4MHVDQ9UTic6p2pcA@mail.gmail.com
Whole thread Raw
Responses Re: Different results between PostgreSQL and Oracle for "for update" statement
List pgsql-hackers
We can reproduce this difference with the following steps. 

create table su (a int, b int);
insert into su values(1, 1);

- session 1:
begin;
update su set b = 2 where b = 1;

- sess 2:
select * from su where a in (select a from su where b = 1) for update;

- sess 1:
commit;

Then session 2 can get the result. 

PostgreSQL:

 a | b
---+---
 1 | 2
(1 row)


Oracle:  It gets 0 rows.

Oracle's plan is pretty similar to Postgres. 

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 2828511618

-----------------------------------------------------------------------------
| Id  | Operation     | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |    |  1 | 52 |  4   (0)| 00:00:01 |
|   1 |  FOR UPDATE     |    |    |    | |    |
|   2 |   BUFFER SORT     |    |    |    | |    |
|*  3 |    HASH JOIN SEMI    |    |  1 | 52 |  4   (0)| 00:00:01 |
|   4 |     TABLE ACCESS FULL| SU   |  1 | 26 |  2   (0)| 00:00:01 |
|*  5 |     TABLE ACCESS FULL| SU   |  1 | 26 |  2   (0)| 00:00:01 |

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
-----------------------------------------------------------------------------

Any thoughts on who is wrong? 


--
Best Regards
Andy Fan

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: scram-sha-256 broken with FIPS and OpenSSL 1.0.2
Next
From: Amit Kapila
Date:
Subject: Re: [HACKERS] logical decoding of two-phase transactions