Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a3c53c8

Browse files
author
Neil Conway
committed
This patch from Alvaro Herrera adds transaction ID to the list of
log_line_prefix escapes. The escape sequence used for this is %x. %x previously meant "postmaster et al. stop here" -- this has been renamed to %q.
1 parent 665d373 commit a3c53c8

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

doc/src/sgml/runtime.sgml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.281 2004/09/17 22:40:46 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.282 2004/09/22 03:55:24 neilc Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -2394,6 +2394,11 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
23942394
</row>
23952395
<row>
23962396
<entry><literal>%x</literal></entry>
2397+
<entry>Transaction ID</entry>
2398+
<entry>Yes</entry>
2399+
</row>
2400+
<row>
2401+
<entry><literal>%q</literal></entry>
23972402
<entry>Does not produce any output, but tells non-session
23982403
processes to stop at this point in the string. Ignored by
23992404
session processes.</entry>

src/backend/utils/error/elog.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.150 2004/09/05 03:42:11 tgl Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.151 2004/09/22 03:55:26 neilc Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1421,12 +1421,21 @@ log_line_prefix(StringInfo buf)
14211421
MyProcPort->remote_port);
14221422
}
14231423
break;
1424-
case 'x':
1425-
/* in postmaster and friends, stop if %x is seen */
1424+
case 'q':
1425+
/* in postmaster and friends, stop if %q is seen */
14261426
/* in a backend, just ignore */
14271427
if (MyProcPort == NULL)
14281428
i = format_len;
14291429
break;
1430+
case 'x':
1431+
if (MyProcPort)
1432+
{
1433+
if (IsTransactionState())
1434+
appendStringInfo(buf, "%u", GetTopTransactionId());
1435+
else
1436+
appendStringInfo(buf, "%u", InvalidTransactionId);
1437+
}
1438+
break;
14301439
case '%':
14311440
appendStringInfoChar(buf, '%');
14321441
break;

src/backend/utils/misc/postgresql.conf.sample

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@
231231
# %r=remote host and port
232232
# %p=PID %t=timestamp %i=command tag
233233
# %c=session id %l=session line number
234-
# %s=session start timestamp
235-
# %x=stop here in non-session processes
234+
# %s=session start timestamp %x=transaction id
235+
# %q=stop here in non-session processes
236236
# %%='%'
237237
#log_statement = 'none' # none, mod, ddl, all
238238
#log_hostname = false

0 commit comments

Comments
 (0)