Patches,
This trivial patch adds the transaction Id to the list of escapes
available to log_line_prefix. (Note that I used the top transaction Id,
not the current subtransaction Id, which is clearly useless for PITR
purposes.)
One important question is what letter to use for this. It seemed to me
that the most obvious letter was "x". So I used that, and changed the
"postmaster and friends stop here" to "q".
I also thought of using %t, but that is already taken too.
Anyone has a better idea?
--
Alvaro Herrera ()
Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green
stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'.
After collecting 500 such letters, he mused, a university somewhere in
Arizona would probably grant him a degree. (Don Knuth)
Index: src/backend/utils/error/elog.c
===
RCS file: /home/alvherre/cvs/pgsql-server/src/backend/utils/error/elog.c,v
retrieving revision 1.150
diff -c -r1.150 elog.c
*** src/backend/utils/error/elog.c 5 Sep 2004 03:42:11 - 1.150
--- src/backend/utils/error/elog.c 11 Sep 2004 03:31:14 -
***
*** 1421,1432
MyProcPort->remote_port);
}
break;
! case 'x':
! /* in postmaster and friends, stop if %x is seen */
/* in a backend, just ignore */
if (MyProcPort == NULL)
i = format_len;
break;
case '%':
appendStringInfoChar(buf, '%');
break;
--- 1421,1441
MyProcPort->remote_port);
}
break;
! case 'q':
! /* in postmaster and friends, stop if %q is seen */
/* in a backend, just ignore */
if (MyProcPort == NULL)
i = format_len;
break;
+ case 'x':
+ if (MyProcPort)
+ {
+ if (IsTransactionState())
+ appendStringInfo(buf, "%u",
GetTopTransactionId());
+ else
+ appendStringInfo(buf, "%u",
InvalidTransactionId);
+ }
+ break;
case '%':
appendStringInfoChar(buf, '%');
break;
Index: doc/src/sgml/runtime.sgml
===
RCS file: /home/alvherre/cvs/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.280
diff -c -r1.280 runtime.sgml
*** doc/src/sgml/runtime.sgml 31 Aug 2004 04:53:43 - 1.280
--- doc/src/sgml/runtime.sgml 11 Sep 2004 03:29:49 -
***
*** 2375,2380
--- 2375,2385
%x
+ Transaction ID
+ Yes
+
+
+ %q
Does not produce any output, but tells non-session
processes to stop at this point in the string. Ignored by
session processes.
Index: src/backend/utils/misc/postgresql.conf.sample
===
RCS file:
/home/alvherre/cvs/pgsql-server/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.127
diff -c -r1.127 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample 31 Aug 2004 04:53:44 -
1.127
--- src/backend/utils/misc/postgresql.conf.sample 11 Sep 2004 03:40:30 -
***
*** 227,234
# %r=remote host and port
# %p=PID %t=timestamp %i=command tag
# %c=session id %l=session line number
! # %s=session start timestamp
! # %x=stop here in non-session processes
# %%='%'
#log_statement = 'none' # none, mod, ddl, all
#log_hostname = false
--- 227,234
# %r=remote host and port
# %p=PID %t=timestamp %i=command tag
# %c=session id %l=session line number
! # %s=session start timestamp %x=t