Re: New form of index "persistent reference" - Mailing list pgsql-hackers

From Zeugswetter Andreas DAZ SD
Subject Re: New form of index "persistent reference"
Date
Msg-id 46C15C39FEB2C44BA555E356FBCD6FA40184D2EC@m0114.s-mxs.net
Whole thread Raw
In response to New form of index "persistent reference"  (pgsql@mohawksoft.com)
List pgsql-hackers
> I asked the question how do you get a record without going through an
> index, the answer was CTID, which unfortunately changes when the row is
> updated.

The ctid is a physical location of the row. On update a new tuple is written
in a new location, that is why the ctid changes. The old tuple has a system field
t_ctid which is then a forward pointer to the new tuple.

Thus you can follow that chain until the visible tuple is found.
The current tid = tid does not do that (I think because the ODBC driver
which was the first to use it (for result set modification) needed to notice when the
tuple was updated underneath).

But you can use:select * from atab where ctid = currtid2('atab', '(0,1)'); -- '(0,1)' is the old ctid

Of course the old ctid is only valid until (auto)vacuum marks it free.
Without vacuum you are currently safe to use the currtid functions.

Andreas


pgsql-hackers by date:

Previous
From: Sibtay Abbas
Date:
Subject: passing parameters by reference
Next
From: Oleg Bartunov
Date:
Subject: any presentation, tutorial on postgresql ?