Re: [SPAM] Current transaction ID?
| От | Marek Lewczuk |
|---|---|
| Тема | Re: [SPAM] Current transaction ID? |
| Дата | |
| Msg-id | 42AFC3D5.5010702@lewczuk.com обсуждение исходный текст |
| Ответ на | Current transaction ID? ("Steve - DND" <postgres@digitalnothing.com>) |
| Список | pgsql-general |
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!!
В списке pgsql-general по дате отправления: