Re: Oracle to Postgres training at PGConf US

From: Joshua D. Drake <jd_at_commandprompt.com>
Date: Sun, 23 Jul 2017 17:29:19 -0700
Message-ID: <20e551c0-cb31-8b8d-5d23-702d6d2b6dea_at_commandprompt.com>


On 07/22/2017 11:59 PM, Stefan Koehler wrote:
> Hey JD,
> to get back on a technical track and ignore all other on-going personal things here :-)
>
> What do you think about this? https://twitter.com/FranckPachot/status/888867529954820097
>
> This looks crazy to me (and possibly all other Oracle folks out there).
>

As a PostgreSQL person it makes sense to me and this is why:

Our first data set is:

1
0

Our first update sets the data to

0
1

Which means at the first update, there is no conflict and therefore the second update there is no conflict. However, when you try to update the data again:

update demo set n=n+1;

You are saying, set 0 = 1 and 1 = 2; The problem is that when you set 0 = 1, there is already a 1 in the tuple set. So you get a primary key violation.

It makes sense to me. I can see where someone would say... wait, what? You would assume that you could check the constraint at the end of the transaction. I would actually consider this a limitation of our primary keys as our other constraints (such as foreign keys) can be set deferred in which case a similar case would work.

Thanks,

JD

-- 
Command Prompt, Inc. || http://the.postgres.company/ || _at_cmdpromptinc

PostgreSQL Centered full stack support, consulting and development.
Advocate: _at_amplifypostgres || Learn: https://pgconf.us
*****     Unless otherwise stated, opinions are my own.   *****
--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jul 24 2017 - 02:29:19 CEST

Original text of this message