#include "postgres.h" #include "access/xact.h" Datum getcurrenttransactionid(PG_FUNCTION_ARGS) { TransactionId xid = GetCurrentTransactionId(); PG_RETURN_INT32((int32) xid); }