4242 *
4343 *
4444 * IDENTIFICATION
45- * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.196 2007/09/05 18:10:48 tgl Exp $
45+ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.197 2007/09/27 18:15:36 tgl Exp $
4646 *
4747 *-------------------------------------------------------------------------
4848 */
@@ -1636,10 +1636,9 @@ appendCSVLiteral(StringInfo buf, const char* data)
16361636
16371637/*
16381638 * Constructs the error message, depending on the Errordata it gets,
1639- * in CSV (commaseperated values) format. The COPY command
1639+ * in CSV (commaseparated values) format. The COPY command
16401640 * can then be used to load the messages into a table.
16411641 */
1642-
16431642static void
16441643write_csvlog (ErrorData * edata )
16451644{
@@ -1672,8 +1671,8 @@ write_csvlog(ErrorData *edata)
16721671 * The format of the log output in CSV format:
16731672 * timestamp with milliseconds, username, databasename, session id,
16741673 * host and port number, process id, process line number, command tag,
1675- * session start time, transaction id,error severity, sql state code,
1676- * statement or error message.
1674+ * session start time,virtual transaction id,regular transaction id,
1675+ * error severity, sql state code, error message.
16771676 */
16781677
16791678/* timestamp_with_milliseconds */
@@ -1737,29 +1736,25 @@ write_csvlog(ErrorData *edata)
17371736appendStringInfoChar (& buf ,',' );
17381737
17391738/* session id */
1740- appendStringInfo (& buf ,"%lx.%x" ,
1741- (long )MyStartTime ,MyProcPid );
1739+ appendStringInfo (& buf ,"%lx.%x" , (long )MyStartTime ,MyProcPid );
17421740appendStringInfoChar (& buf ,',' );
17431741
1744- /* Remote host and port */
1742+ /* Remote host and port(is it safe to not quote this?) */
17451743if (MyProcPort && MyProcPort -> remote_host )
17461744{
17471745appendStringInfo (& buf ,"%s" ,MyProcPort -> remote_host );
17481746if (MyProcPort -> remote_port && MyProcPort -> remote_port [0 ]!= '\0' )
17491747appendStringInfo (& buf ,":%s" ,MyProcPort -> remote_port );
17501748}
1751-
17521749appendStringInfoChar (& buf ,',' );
17531750
17541751/* Process id */
17551752if (MyProcPid != 0 )
17561753appendStringInfo (& buf ,"%d" ,MyProcPid );
1757-
17581754appendStringInfoChar (& buf ,',' );
17591755
17601756/* Line number */
17611757appendStringInfo (& buf ,"%ld" ,log_line_number );
1762-
17631758appendStringInfoChar (& buf ,',' );
17641759
17651760/* PS display */
@@ -1773,16 +1768,13 @@ write_csvlog(ErrorData *edata)
17731768appendCSVLiteral (& buf ,msgbuf .data );
17741769resetStringInfo (& msgbuf );
17751770}
1776-
17771771appendStringInfoChar (& buf ,',' );
17781772
17791773/* session start timestamp */
17801774if (formatted_start_time [0 ]== '\0' )
17811775{
17821776pg_time_t stamp_time = (pg_time_t )MyStartTime ;
1783- pg_tz * tz ;
1784-
1785- tz = log_timezone ?log_timezone :gmt_timezone ;
1777+ pg_tz * tz = log_timezone ?log_timezone :gmt_timezone ;
17861778
17871779pg_strftime (formatted_start_time ,FORMATTED_TS_LEN ,
17881780"%Y-%m-%d %H:%M:%S %Z" ,
@@ -1791,22 +1783,21 @@ write_csvlog(ErrorData *edata)
17911783appendStringInfoString (& buf ,formatted_start_time );
17921784appendStringInfoChar (& buf ,',' );
17931785
1786+ /* Virtual transaction id */
1787+ /* keep VXID format in sync with lockfuncs.c */
1788+ if (MyProc != NULL )
1789+ appendStringInfo (& buf ,"%d/%u" ,MyProc -> backendId ,MyProc -> lxid );
1790+ appendStringInfoChar (& buf ,',' );
1791+
17941792/* Transaction id */
17951793appendStringInfo (& buf ,"%u" ,GetTopTransactionIdIfAny ());
1796-
17971794appendStringInfoChar (& buf ,',' );
17981795
17991796/* Error severity */
1800- if (error_severity (edata -> elevel )!= NULL )
1801- appendStringInfo (& buf ,"%s," ,error_severity (edata -> elevel ));
1802- else
1803- appendStringInfoString (& buf ,"," );
1804-
1797+ appendStringInfo (& buf ,"%s," ,error_severity (edata -> elevel ));
1798+
18051799/* SQL state code */
1806- if (Log_error_verbosity >=PGERROR_VERBOSE )
1807- appendStringInfo (& buf ,"%s" ,
1808- unpack_sql_state (edata -> sqlerrcode ));
1809- appendStringInfoChar (& buf ,',' );
1800+ appendStringInfo (& buf ,"%s," ,unpack_sql_state (edata -> sqlerrcode ));
18101801
18111802/* Error message and cursor position if any */
18121803get_csv_error_message (& buf ,edata );
@@ -1830,7 +1821,7 @@ write_csvlog(ErrorData *edata)
18301821static void
18311822get_csv_error_message (StringInfo buf ,ErrorData * edata )
18321823{
1833- char * msg = edata -> message ?edata -> message :_ ("missing error text" );
1824+ char * msg = edata -> message ?edata -> message :_ ("missing error text" );
18341825char c ;
18351826
18361827appendStringInfoCharMacro (buf ,'"' );