From: | Greg Stark <gsstark(at)mit(dot)edu> |
---|---|
To: | "Jim C(dot) Nasby" <jim(at)nasby(dot)net> |
Cc: | "Uwe C(dot) Schroeder" <uwe(at)oss4u(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [GENERAL] 8.1, OID's and plpgsql |
Date: | 2005-12-07 00:18:15 |
Message-ID: | 87vey1iwu0.fsf@stark.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
"Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> Right now you don't. :( ISTM there should be a way to get back the row
> you just inserted. Whether a ctid is the right way to do that I don't
> know...
>
> I'm going to move this over to -hackers to see what people over there
> have to say.
Perhaps the right thing to provide would be a data structure that bundled up
the ctid and the transaction id. It would only be valid if the transaction id
still matched the current transaction id it was used in. Any attempt to use it
in a later transaction would give an error, much like using sequence.currval
when nextval hasn't been used.
Many people would suggest the right thing to be using is the primary key. And
there ought to be an interface to fetch the current value (or values) of the
primary key of the last inserted record.
The benefits of providing something based on ctid is to avoid the inefficiency
of the index lookup on the primary key and it would work on tables without any
primary key. I'm not sure it's worth the effort it would entail for those
narrow use cases especially since I think some interface to retrieve the
primary will still be needed anyways.
--
greg
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-12-07 00:24:43 | Re: [GENERAL] 8.1, OID's and plpgsql |
Previous Message | Tom Lane | 2005-12-06 23:55:46 | Re: Letting a function return multiple columns instead of a single complex one |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-12-07 00:24:43 | Re: [GENERAL] 8.1, OID's and plpgsql |
Previous Message | Marc G. Fournier | 2005-12-06 23:21:57 | Re: Slow email caught in the act |