Getting the current transaction's xid

From: David Blasby <dblasby(at)refractions(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Getting the current transaction's xid
Date: 2003-07-24 18:55:19
Message-ID: 3F202B97.2010904@refractions.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-07-24 19:04:59 Re: odd behavior/possible bug
Previous Message Tom Lane 2003-07-24 18:36:54 Re: v7.3.4 bundled ...