Re: Generating History

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rod Taylor" <rod(dot)taylor(at)inquent(dot)com>
Cc: "Hackers List" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Generating History
Date: 2001-01-23 01:56:20
Message-ID: 25206.980214980@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Rod Taylor" <rod(dot)taylor(at)inquent(dot)com> writes:
> Is there any easy method for getting a hold of the OID and XID for a
> given row within a plpgsql (or another type) of function?

> Statements like NEW.oid appear to fail, and xid isn't to be found.

The reason this doesn't work in plpgsql is that the underlying "SPI"
tuple-access routines don't support access to the system attributes
of a tuple. It'd be relatively straightforward to extend them to
do so, if someone cared to work on that.

I thought you could do it in an SQL-language function, but that doesn't
seem to work either, for reasons that may be strictly historical at
this point --- the relevant error message is coming out of this:

attno = get_attnum(relid, attname);

/* XXX Is there still a reason for this restriction? */
if (attno < 0)
elog(ERROR, "Cannot reference attribute '%s'"
" of tuple params/return values for functions", attname);

Think I'll look and see if this restriction could be dropped now.

For 7.0.* though, it seems the only way to get this data in a PL
function is to write a C-language function to extract it ...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-01-23 02:00:25 Re: int4 or int32
Previous Message Tatsuo Ishii 2001-01-23 01:54:53 Re: AW: like and optimization