42
42
*
43
43
*
44
44
* IDENTIFICATION
45
- * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.216 2009/06/25 23:07:15 tgl Exp $
45
+ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.217 2009/07/03 19:14:25 petere Exp $
46
46
*
47
47
*-------------------------------------------------------------------------
48
48
*/
@@ -144,7 +144,7 @@ static char formatted_log_time[FORMATTED_TS_LEN];
144
144
} while (0)
145
145
146
146
147
- static void log_line_prefix (StringInfo buf );
147
+ static void log_line_prefix (StringInfo buf , ErrorData * edata );
148
148
static void send_message_to_server_log (ErrorData * edata );
149
149
static void send_message_to_frontend (ErrorData * edata );
150
150
static char * expand_fmt_string (const char * fmt , ErrorData * edata );
@@ -1677,7 +1677,7 @@ setup_formatted_start_time(void)
1677
1677
* Format tag info for log lines; append to the provided buffer.
1678
1678
*/
1679
1679
static void
1680
- log_line_prefix (StringInfo buf )
1680
+ log_line_prefix (StringInfo buf , ErrorData * edata )
1681
1681
{
1682
1682
/* static counter for line numbers */
1683
1683
static long log_line_number = 0 ;
@@ -1814,6 +1814,9 @@ log_line_prefix(StringInfo buf)
1814
1814
case 'x' :
1815
1815
appendStringInfo (buf , "%u" , GetTopTransactionIdIfAny ());
1816
1816
break ;
1817
+ case 'e' :
1818
+ appendStringInfoString (buf , unpack_sql_state (edata -> sqlerrcode ));
1819
+ break ;
1817
1820
case '%' :
1818
1821
appendStringInfoChar (buf , '%' );
1819
1822
break ;
@@ -2070,7 +2073,7 @@ send_message_to_server_log(ErrorData *edata)
2070
2073
2071
2074
formatted_log_time [0 ] = '\0' ;
2072
2075
2073
- log_line_prefix (& buf );
2076
+ log_line_prefix (& buf , edata );
2074
2077
appendStringInfo (& buf , "%s: " , error_severity (edata -> elevel ));
2075
2078
2076
2079
if (Log_error_verbosity >= PGERROR_VERBOSE )
@@ -2094,35 +2097,35 @@ send_message_to_server_log(ErrorData *edata)
2094
2097
{
2095
2098
if (edata -> detail_log )
2096
2099
{
2097
- log_line_prefix (& buf );
2100
+ log_line_prefix (& buf , edata );
2098
2101
appendStringInfoString (& buf , _ ("DETAIL: " ));
2099
2102
append_with_tabs (& buf , edata -> detail_log );
2100
2103
appendStringInfoChar (& buf , '\n' );
2101
2104
}
2102
2105
else if (edata -> detail )
2103
2106
{
2104
- log_line_prefix (& buf );
2107
+ log_line_prefix (& buf , edata );
2105
2108
appendStringInfoString (& buf , _ ("DETAIL: " ));
2106
2109
append_with_tabs (& buf , edata -> detail );
2107
2110
appendStringInfoChar (& buf , '\n' );
2108
2111
}
2109
2112
if (edata -> hint )
2110
2113
{
2111
- log_line_prefix (& buf );
2114
+ log_line_prefix (& buf , edata );
2112
2115
appendStringInfoString (& buf , _ ("HINT: " ));
2113
2116
append_with_tabs (& buf , edata -> hint );
2114
2117
appendStringInfoChar (& buf , '\n' );
2115
2118
}
2116
2119
if (edata -> internalquery )
2117
2120
{
2118
- log_line_prefix (& buf );
2121
+ log_line_prefix (& buf , edata );
2119
2122
appendStringInfoString (& buf , _ ("QUERY: " ));
2120
2123
append_with_tabs (& buf , edata -> internalquery );
2121
2124
appendStringInfoChar (& buf , '\n' );
2122
2125
}
2123
2126
if (edata -> context )
2124
2127
{
2125
- log_line_prefix (& buf );
2128
+ log_line_prefix (& buf , edata );
2126
2129
appendStringInfoString (& buf , _ ("CONTEXT: " ));
2127
2130
append_with_tabs (& buf , edata -> context );
2128
2131
appendStringInfoChar (& buf , '\n' );
@@ -2132,14 +2135,14 @@ send_message_to_server_log(ErrorData *edata)
2132
2135
/* assume no newlines in funcname or filename... */
2133
2136
if (edata -> funcname && edata -> filename )
2134
2137
{
2135
- log_line_prefix (& buf );
2138
+ log_line_prefix (& buf , edata );
2136
2139
appendStringInfo (& buf , _ ("LOCATION: %s, %s:%d\n" ),
2137
2140
edata -> funcname , edata -> filename ,
2138
2141
edata -> lineno );
2139
2142
}
2140
2143
else if (edata -> filename )
2141
2144
{
2142
- log_line_prefix (& buf );
2145
+ log_line_prefix (& buf , edata );
2143
2146
appendStringInfo (& buf , _ ("LOCATION: %s:%d\n" ),
2144
2147
edata -> filename , edata -> lineno );
2145
2148
}
@@ -2153,7 +2156,7 @@ send_message_to_server_log(ErrorData *edata)
2153
2156
debug_query_string != NULL &&
2154
2157
!edata -> hide_stmt )
2155
2158
{
2156
- log_line_prefix (& buf );
2159
+ log_line_prefix (& buf , edata );
2157
2160
appendStringInfoString (& buf , _ ("STATEMENT: " ));
2158
2161
append_with_tabs (& buf , debug_query_string );
2159
2162
appendStringInfoChar (& buf , '\n' );
0 commit comments