Search Postgresql Archives

Re: [SPAM] Current transaction ID?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steve - DND napisał(a):
Simple question I'm sure, but how can I get the transaction ID that a query
is currently running in? I can find all kinds of documentation talking about
transaction ids, but nothing about how to get the current one.

You can compile attached function - this will return current transaction id.
#include "postgres.h"
#include "access/xact.h"

Datum getcurrenttransactionid(PG_FUNCTION_ARGS)
{
        TransactionId xid = GetCurrentTransactionId();
        PG_RETURN_INT32((int32) xid);
}
--
-- getCurrentTransactionId
--

SET search_path = public;

CREATE FUNCTION getCurrentTransactionId()
	RETURNS integer
	AS 'MODULE_PATHNAME'
	LANGUAGE 'c';

--
--	eof
--
# $PostgreSQL: pgsql/contrib/chkpass/Makefile,v 1.6 2004/08/20 20:13:02 momjian Exp $

MODULE_big = getcurrenttransactionid
OBJS = getcurrenttransactionid.o
SHLIB_LINK = $(filter -lcrypt, $(LIBS))
DATA_built = getcurrenttransactionid.sql
DOCS = README.getcurrenttransactionid

ifdef USE_PGXS
PGXS = $(shell pg_config --pgxs)
include $(PGXS)
else
subdir = contrib/getcurrenttransactionid
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
TO DO!!
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux