Re: retrieve the rowid of a row

From: Neil Conway <neilc(at)samurai(dot)com>
To: sydpug(at)postgresql(dot)org
Subject: Re: retrieve the rowid of a row
Date: 2005-05-13 05:42:36
Message-ID: 42843E4C.60005@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sydpug

users jtech softwares wrote:
> How can we retrieve the rowid of a row, which is currently locked by a
> user using 'SELECT FOR UPDATE'.

There is no real concept of a "rowid" in PostgreSQL. There is a "tuple
ID" that is not meant for use by user applications (it can be unstable
in the face of VACUUM, for example), and a per-row OID that is
deprecated and shouldn't be used for this purpose.

I would suggest having the SELECT FOR UPDATE return the value of the
row's primary key, and then using that to select the row in the future.
If the table has no primary key, create an artificial one via a serial
column. You could _probably_ get away with using the tuple id (ctid)
mentioned above, but I personally wouldn't recommend it.

-Neil

In response to

Browse sydpug by date

  From Date Subject
Next Message users jtech softwares 2005-05-14 10:08:00 rowid of a record being locked for updation
Previous Message users jtech softwares 2005-05-13 05:31:55 retrieve the rowid of a row