Re: [PATCHES] Xid in log_line_prefix

2004-09-21 Thread Neil Conway
On Sat, 2004-09-11 at 13:44, Alvaro Herrera wrote:
 This trivial patch adds the transaction Id to the list of escapes
 available to log_line_prefix.

Patch applied to HEAD. Thanks.

Bruce, this patch was/is on the pending patches list. I don't know of a
way to remove items from that list myself -- can you remove it for me
when you get a chance?

-Neil



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[PATCHES] Xid in log_line_prefix

2004-09-10 Thread Alvaro Herrera
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 (alvherre[a]dcc.uchile.cl)
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 
  /row
  row
   entryliteral%x/literal/entry
+  entryTransaction ID/entry
+  entryYes/entry
+ /row
+ row
+  entryliteral%q/literal/entry
   entryDoes not produce any output, but tells non-session
   processes to stop at this point in the string. Ignored by
   session processes./entry
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
   

Re: [PATCHES] Xid in log_line_prefix

2004-09-10 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes:
 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.)

Looks reasonable to me ...

regards, tom lane

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html