While looking into a SSI bug, I noticed that we don't actually display
the pid of the holding transaction, even though we have that
information available.

The attached patch fixes that.

One note is that it will show the pid of the backend that executed the
transaction, even if that transaction has already committed. I have no
particular opinion about whether it's more useful to do that or return
null, so went with the smallest change. (The pid is null for PREPARED
or summarized transactions).

Dan

-- 
Dan R. K. Ports              MIT CSAIL                http://drkp.net/
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index c6c948c..6d7d4f4 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -368,7 +368,10 @@ pg_lock_status(PG_FUNCTION_ARGS)
 		/* lock holder */
 		values[10] = VXIDGetDatum(xact->vxid.backendId,
 								  xact->vxid.localTransactionId);
-		nulls[11] = true;		/* pid */
+		if (xact->pid != 0)
+			values[11] = Int32GetDatum(xact->pid);
+		else
+			nulls[11] = true;
 
 		/*
 		 * Lock mode. Currently all predicate locks are SIReadLocks, which are
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to