Getting the current transaction's xid - Mailing list pgsql-hackers

From David Blasby
Subject Getting the current transaction's xid
Date
Msg-id 3F202B97.2010904@refractions.net
Whole thread Raw
In response to Re: GiST index on data types that require compression  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I'm trying to keep a variable around for the duration of a transaction.

Unfortunately, the "SET LOCAL" command doesnt allow me to create my own 
variable.  Also, the "CREATE TEMP TABLE ... ON COMMIT DELETE ROWS" isnt 
yet implemented.

But, I believe I can implement it using a TEMP table like this:

CREATE TEMP TABLE my_variable (transId  xid, value in);

INSERT INTO my_variable ( getTransactionID(), 25);

And I can read from the table with:

SELECT value FROM my_variable WHERE transId = getTransactionID();

The question is, how to write the getTransactionID() function.

I'm comfortable writing "C" extensions to postgresql, but I'm not sure 
where to actually get the current transaction id.  Could someone give me 
pointers to where I can find this magic value?

dave



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: odd behavior/possible bug
Next
From: Tom Lane
Date:
Subject: Re: v7.3.4 bundled ...