Re: 8.1, OID's and plpgsql

From: "Uwe C(dot) Schroeder" <uwe(at)oss4u(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: 8.1, OID's and plpgsql
Date: 2005-12-03 23:07:19
Message-ID: 200512031507.19599.uwe@oss4u.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

the ctid seems to be the solution to my problem. I'm inserting the record in a
transaction so the ctid shouldn't change while the transaction isn't finished
(either rolled back or committed).
One question though. How would I get the ctid of the just inserted record. GET
DIAGNOSTICS only handles row count and oid per the docs.

THX

UC

On Friday 02 December 2005 15:58, Tom Lane wrote:
> "Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> > Maybe the docs should be changed to just say that you should never reuse
> > a ctid outside of the transaction you obtained the ctid in?
>
> That's not a sufficient rule either: someone else could still delete or
> update the row while your transaction runs. You'd really have to SELECT
> FOR UPDATE or FOR SHARE to be sure the ctid remains stable. (Of course,
> this isn't an issue for the case of a row you just inserted yourself,
> since no one else can see it yet to change it.)
>
> The paragraph defining ctid is not the place for a discussion of how it
> could be used ... I'm not quite sure where is, though.
>
> regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anton Nikiforov 2005-12-03 23:39:57 int to inet conversion
Previous Message Rodrigo Gonzalez 2005-12-03 22:38:20 Re: beginne' - inserting a record

Browse pgsql-hackers by date

  From Date Subject
Next Message Charlie Savage 2005-12-03 23:24:08 Re: Building Windows Server Extensions Using VC++ 2005
Previous Message Peter Eisentraut 2005-12-03 23:06:02 Re: SERIAL type feature request