@ -177,7 +177,6 @@ static void write_csvlog(ErrorData *edata);
static void send_message_to_server_log ( ErrorData * edata ) ;
static void send_message_to_server_log ( ErrorData * edata ) ;
static void write_pipe_chunks ( char * data , int len , int dest ) ;
static void write_pipe_chunks ( char * data , int len , int dest ) ;
static void send_message_to_frontend ( ErrorData * edata ) ;
static void send_message_to_frontend ( ErrorData * edata ) ;
static char * expand_fmt_string ( const char * fmt , ErrorData * edata ) ;
static const char * error_severity ( int elevel ) ;
static const char * error_severity ( int elevel ) ;
static void append_with_tabs ( StringInfo buf , const char * str ) ;
static void append_with_tabs ( StringInfo buf , const char * str ) ;
static bool is_log_level_output ( int elevel , int log_min_level ) ;
static bool is_log_level_output ( int elevel , int log_min_level ) ;
@ -705,13 +704,10 @@ errcode_for_socket_access(void)
*/
*/
# define EVALUATE_MESSAGE(domain, targetfield, appendval, translateit) \
# define EVALUATE_MESSAGE(domain, targetfield, appendval, translateit) \
{ \
{ \
char * fmtbuf ; \
StringInfoData buf ; \
StringInfoData buf ; \
/* Internationalize the error format string */ \
/* Internationalize the error format string */ \
if ( ( translateit ) & & ! in_error_recursion_trouble ( ) ) \
if ( ( translateit ) & & ! in_error_recursion_trouble ( ) ) \
fmt = dgettext ( ( domain ) , fmt ) ; \
fmt = dgettext ( ( domain ) , fmt ) ; \
/* Expand %m in format string */ \
fmtbuf = expand_fmt_string ( fmt , edata ) ; \
initStringInfo ( & buf ) ; \
initStringInfo ( & buf ) ; \
if ( ( appendval ) & & edata - > targetfield ) { \
if ( ( appendval ) & & edata - > targetfield ) { \
appendStringInfoString ( & buf , edata - > targetfield ) ; \
appendStringInfoString ( & buf , edata - > targetfield ) ; \
@ -722,15 +718,14 @@ errcode_for_socket_access(void)
{ \
{ \
va_list args ; \
va_list args ; \
int needed ; \
int needed ; \
errno = edata - > saved_errno ; \
va_start ( args , fmt ) ; \
va_start ( args , fmt ) ; \
needed = appendStringInfoVA ( & buf , fmtbuf , args ) ; \
needed = appendStringInfoVA ( & buf , fmt , args ) ; \
va_end ( args ) ; \
va_end ( args ) ; \
if ( needed = = 0 ) \
if ( needed = = 0 ) \
break ; \
break ; \
enlargeStringInfo ( & buf , needed ) ; \
enlargeStringInfo ( & buf , needed ) ; \
} \
} \
/* Done with expanded fmt */ \
pfree ( fmtbuf ) ; \
/* Save the completed message into the stack item */ \
/* Save the completed message into the stack item */ \
if ( edata - > targetfield ) \
if ( edata - > targetfield ) \
pfree ( edata - > targetfield ) ; \
pfree ( edata - > targetfield ) ; \
@ -746,15 +741,12 @@ errcode_for_socket_access(void)
# define EVALUATE_MESSAGE_PLURAL(domain, targetfield, appendval) \
# define EVALUATE_MESSAGE_PLURAL(domain, targetfield, appendval) \
{ \
{ \
const char * fmt ; \
const char * fmt ; \
char * fmtbuf ; \
StringInfoData buf ; \
StringInfoData buf ; \
/* Internationalize the error format string */ \
/* Internationalize the error format string */ \
if ( ! in_error_recursion_trouble ( ) ) \
if ( ! in_error_recursion_trouble ( ) ) \
fmt = dngettext ( ( domain ) , fmt_singular , fmt_plural , n ) ; \
fmt = dngettext ( ( domain ) , fmt_singular , fmt_plural , n ) ; \
else \
else \
fmt = ( n = = 1 ? fmt_singular : fmt_plural ) ; \
fmt = ( n = = 1 ? fmt_singular : fmt_plural ) ; \
/* Expand %m in format string */ \
fmtbuf = expand_fmt_string ( fmt , edata ) ; \
initStringInfo ( & buf ) ; \
initStringInfo ( & buf ) ; \
if ( ( appendval ) & & edata - > targetfield ) { \
if ( ( appendval ) & & edata - > targetfield ) { \
appendStringInfoString ( & buf , edata - > targetfield ) ; \
appendStringInfoString ( & buf , edata - > targetfield ) ; \
@ -765,15 +757,14 @@ errcode_for_socket_access(void)
{ \
{ \
va_list args ; \
va_list args ; \
int needed ; \
int needed ; \
errno = edata - > saved_errno ; \
va_start ( args , n ) ; \
va_start ( args , n ) ; \
needed = appendStringInfoVA ( & buf , fmtbuf , args ) ; \
needed = appendStringInfoVA ( & buf , fmt , args ) ; \
va_end ( args ) ; \
va_end ( args ) ; \
if ( needed = = 0 ) \
if ( needed = = 0 ) \
break ; \
break ; \
enlargeStringInfo ( & buf , needed ) ; \
enlargeStringInfo ( & buf , needed ) ; \
} \
} \
/* Done with expanded fmt */ \
pfree ( fmtbuf ) ; \
/* Save the completed message into the stack item */ \
/* Save the completed message into the stack item */ \
if ( edata - > targetfield ) \
if ( edata - > targetfield ) \
pfree ( edata - > targetfield ) ; \
pfree ( edata - > targetfield ) ; \
@ -3328,59 +3319,6 @@ send_message_to_frontend(ErrorData *edata)
*/
*/
/*
* expand_fmt_string - - - process special format codes in a format string
*
* We must replace % m with the appropriate strerror string , since vsnprintf
* won ' t know what to do with it .
*
* The result is a palloc ' d string .
*/
static char *
expand_fmt_string ( const char * fmt , ErrorData * edata )
{
StringInfoData buf ;
const char * cp ;
initStringInfo ( & buf ) ;
for ( cp = fmt ; * cp ; cp + + )
{
if ( cp [ 0 ] = = ' % ' & & cp [ 1 ] ! = ' \0 ' )
{
cp + + ;
if ( * cp = = ' m ' )
{
/*
* Replace % m by system error string . If there are any % ' s in
* the string , we ' d better double them so that vsnprintf won ' t
* misinterpret .
*/
const char * cp2 ;
cp2 = strerror ( edata - > saved_errno ) ;
for ( ; * cp2 ; cp2 + + )
{
if ( * cp2 = = ' % ' )
appendStringInfoCharMacro ( & buf , ' % ' ) ;
appendStringInfoCharMacro ( & buf , * cp2 ) ;
}
}
else
{
/* copy % and next char --- this avoids trouble with %%m */
appendStringInfoCharMacro ( & buf , ' % ' ) ;
appendStringInfoCharMacro ( & buf , * cp ) ;
}
}
else
appendStringInfoCharMacro ( & buf , * cp ) ;
}
return buf . data ;
}
/*
/*
* error_severity - - - get string representing elevel
* error_severity - - - get string representing elevel
*
*