Re: 8.1, OID's and plpgsql

From: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
To: "Uwe C(dot) Schroeder" <uwe(at)oss4u(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: 8.1, OID's and plpgsql
Date: 2005-12-02 23:46:16
Message-ID: 20051202234616.GW13642@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Thu, Dec 01, 2005 at 07:18:10PM -0800, Uwe C. Schroeder wrote:
> Why not have something like the rowid in oracle?

http://www.postgresql.org/docs/8.1/interactive/datatype-oid.html, search
on ctid. And
http://www.postgresql.org/docs/8.1/interactive/ddl-system-columns.html.

From the 2nd URL:
ctid

The physical location of the row version within its table. Note that
although the ctid can be used to locate the row version very
quickly, a row's ctid will change each time it is updated or moved
by VACUUM FULL. Therefore ctid is useless as a long-term row
identifier. The OID, or even better a user-defined serial number,
should be used to identify logical rows.

Though I think that a lazy vacuum can change (well, technically remove)
a ctid. AFAIK, it's not safe to use a ctid outside of the transaction
you got it in. Though come to think about it, I don't think there's any
way to get the ctid of a row you just inserted anyway...

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?
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gary Horton 2005-12-02 23:49:47 Re: createuser ignores stdin in 8.1.0?
Previous Message Tom Lane 2005-12-02 23:38:01 Re: Numeric 508 datatype

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-12-02 23:53:46 Re: strange behavior (corruption?) of large production database
Previous Message Tom Lane 2005-12-02 23:44:59 Re: Spam 508