Re: default to WITHOUT OIDS?

From: Ashley Cambrell <ash(at)freaky-namuh(dot)com>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: default to WITHOUT OIDS?
Date: 2003-01-11 03:14:33
Message-ID: 3E1F8C19.5090909@freaky-namuh.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neil Conway wrote:

>On Fri, 2003-01-10 at 18:17, Ashley Cambrell wrote:
>
>
>>The problem with getting rid of OIDs as default is there is then no way
>>to get the primary key of a just inserted row with out OIDs (as far as I
>>know)
>>
>>
>
>Use currval() on the PK sequence -- if you call it from within the query
>that inserted a row, it is guaranteed to give you the last sequence
>value that it generated.
>
>

First problem though is that you have to know the sequence name that is
autogenerated from the serial

secondly, I thought that sequences worked outside of transactions..

process 1

INSERT INTO testtable(text1) VALUES('blah1'); -- testid_seq now 1

process 2

INSERT INTO testtable(text1) VALUES('blah2'); -- testid_seq now 2
SELECT currval('testid_seq'); -- returns 2

process 1
SELECT currval('testid_seq'); -- returns 2

??

>However, I agree that one of the drawbacks of this scheme would be
>breaking the OID in the status string returned by INSERT and similar
>commands. Not too big a deal, IMHO (users can still get the same effect
>by specifying WITH OIDS, or toggling the GUC var)...
>
>
The users who don't know any better and expect that pg_getlastoid should
return the last oid will have trouble. There really should be
alternative first, like binding variables and RETURNING INTO. Is it on
the TODO list by any chance?

>Cheers,
>
>Neil
>
>
Ashley Cambrell

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mike Mascari 2003-01-11 03:20:58 Re: help with PL/PgSQL bug
Previous Message Bruce Momjian 2003-01-11 03:03:35 Re: 7.3 pg_dump with -Fc option crashes