I actually analyzed it once. I came to the conclusion that to do it right
it would be easier to make an almost entirely new db but use the same
external interfaces as PostgreSQL. To do a kludge of it, one might just
implement a tier that sits between the user and a bunch of standard
PostgreSQL b
Whenever I do inserts like yours, I do it in this kind of manner (I tried
to use your pseudocode style):
SELECT ID FROM ITEM WHERE URL='X' FOR UPDATE
IF (ROW RETURNED) {
$ID = ITEM.ID
} ELSE {
INSERT INTO ITEM ...
GET THE OID [via PQoidStatus or your environment's equivalent]
SELECT ID FR