@@ -667,8 +667,10 @@ errcode_for_socket_access(void)
667667/* Expand %m in format string */ \
668668fmtbuf = expand_fmt_string (fmt ,edata ); \
669669initStringInfo (& buf ); \
670- if ((appendval )&& edata -> targetfield ) \
671- appendStringInfo (& buf ,"%s\n" ,edata -> targetfield ); \
670+ if ((appendval )&& edata -> targetfield ) { \
671+ appendStringInfoString (& buf ,edata -> targetfield ); \
672+ appendStringInfoChar (& buf ,'\n' ); \
673+ } \
672674/* Generate actual output --- have to use appendStringInfoVA */ \
673675for (;;) \
674676{ \
@@ -708,8 +710,10 @@ errcode_for_socket_access(void)
708710/* Expand %m in format string */ \
709711fmtbuf = expand_fmt_string (fmt ,edata ); \
710712initStringInfo (& buf ); \
711- if ((appendval )&& edata -> targetfield ) \
712- appendStringInfo (& buf ,"%s\n" ,edata -> targetfield ); \
713+ if ((appendval )&& edata -> targetfield ) { \
714+ appendStringInfoString (& buf ,edata -> targetfield ); \
715+ appendStringInfoChar (& buf ,'\n' ); \
716+ } \
713717/* Generate actual output --- have to use appendStringInfoVA */ \
714718for (;;) \
715719{ \
@@ -1809,7 +1813,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
18091813
18101814if (appname == NULL || * appname == '\0' )
18111815appname = _ ("[unknown]" );
1812- appendStringInfo (buf , "%s" ,appname );
1816+ appendStringInfoString (buf ,appname );
18131817}
18141818break ;
18151819case 'u' :
@@ -1819,7 +1823,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
18191823
18201824if (username == NULL || * username == '\0' )
18211825username = _ ("[unknown]" );
1822- appendStringInfo (buf , "%s" ,username );
1826+ appendStringInfoString (buf ,username );
18231827}
18241828break ;
18251829case 'd' :
@@ -1829,7 +1833,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
18291833
18301834if (dbname == NULL || * dbname == '\0' )
18311835dbname = _ ("[unknown]" );
1832- appendStringInfo (buf , "%s" ,dbname );
1836+ appendStringInfoString (buf ,dbname );
18331837}
18341838break ;
18351839case 'c' :
@@ -1877,7 +1881,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
18771881case 'r' :
18781882if (MyProcPort && MyProcPort -> remote_host )
18791883{
1880- appendStringInfo (buf , "%s" ,MyProcPort -> remote_host );
1884+ appendStringInfoString (buf ,MyProcPort -> remote_host );
18811885if (MyProcPort -> remote_port &&
18821886MyProcPort -> remote_port [0 ]!= '\0' )
18831887appendStringInfo (buf ,"(%s)" ,
@@ -1886,7 +1890,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
18861890break ;
18871891case 'h' :
18881892if (MyProcPort && MyProcPort -> remote_host )
1889- appendStringInfo (buf , "%s" ,MyProcPort -> remote_host );
1893+ appendStringInfoString (buf ,MyProcPort -> remote_host );
18901894break ;
18911895case 'q' :
18921896/* in postmaster and friends, stop if %q is seen */
@@ -2004,9 +2008,12 @@ write_csvlog(ErrorData *edata)
20042008if (MyProcPort && MyProcPort -> remote_host )
20052009{
20062010appendStringInfoChar (& buf ,'"' );
2007- appendStringInfo (& buf , "%s" ,MyProcPort -> remote_host );
2011+ appendStringInfoString (& buf ,MyProcPort -> remote_host );
20082012if (MyProcPort -> remote_port && MyProcPort -> remote_port [0 ]!= '\0' )
2009- appendStringInfo (& buf ,":%s" ,MyProcPort -> remote_port );
2013+ {
2014+ appendStringInfoChar (& buf ,':' );
2015+ appendStringInfoString (& buf ,MyProcPort -> remote_port );
2016+ }
20102017appendStringInfoChar (& buf ,'"' );
20112018}
20122019appendStringInfoChar (& buf ,',' );
@@ -2053,40 +2060,40 @@ write_csvlog(ErrorData *edata)
20532060appendStringInfoChar (& buf ,',' );
20542061
20552062/* Error severity */
2056- appendStringInfo (& buf , "%s" ,error_severity (edata -> elevel ));
2063+ appendStringInfoString (& buf ,error_severity (edata -> elevel ));
20572064appendStringInfoChar (& buf ,',' );
20582065
20592066/* SQL state code */
2060- appendStringInfo (& buf , "%s" ,unpack_sql_state (edata -> sqlerrcode ));
2067+ appendStringInfoString (& buf ,unpack_sql_state (edata -> sqlerrcode ));
20612068appendStringInfoChar (& buf ,',' );
20622069
20632070/* errmessage */
20642071appendCSVLiteral (& buf ,edata -> message );
2065- appendStringInfoCharMacro (& buf ,',' );
2072+ appendStringInfoChar (& buf ,',' );
20662073
20672074/* errdetail or errdetail_log */
20682075if (edata -> detail_log )
20692076appendCSVLiteral (& buf ,edata -> detail_log );
20702077else
20712078appendCSVLiteral (& buf ,edata -> detail );
2072- appendStringInfoCharMacro (& buf ,',' );
2079+ appendStringInfoChar (& buf ,',' );
20732080
20742081/* errhint */
20752082appendCSVLiteral (& buf ,edata -> hint );
2076- appendStringInfoCharMacro (& buf ,',' );
2083+ appendStringInfoChar (& buf ,',' );
20772084
20782085/* internal query */
20792086appendCSVLiteral (& buf ,edata -> internalquery );
2080- appendStringInfoCharMacro (& buf ,',' );
2087+ appendStringInfoChar (& buf ,',' );
20812088
20822089/* if printed internal query, print internal pos too */
20832090if (edata -> internalpos > 0 && edata -> internalquery != NULL )
20842091appendStringInfo (& buf ,"%d" ,edata -> internalpos );
2085- appendStringInfoCharMacro (& buf ,',' );
2092+ appendStringInfoChar (& buf ,',' );
20862093
20872094/* errcontext */
20882095appendCSVLiteral (& buf ,edata -> context );
2089- appendStringInfoCharMacro (& buf ,',' );
2096+ appendStringInfoChar (& buf ,',' );
20902097
20912098/* user query --- only reported if not disabled by the caller */
20922099if (is_log_level_output (edata -> elevel ,log_min_error_statement )&&
@@ -2095,10 +2102,10 @@ write_csvlog(ErrorData *edata)
20952102print_stmt = true;
20962103if (print_stmt )
20972104appendCSVLiteral (& buf ,debug_query_string );
2098- appendStringInfoCharMacro (& buf ,',' );
2105+ appendStringInfoChar (& buf ,',' );
20992106if (print_stmt && edata -> cursorpos > 0 )
21002107appendStringInfo (& buf ,"%d" ,edata -> cursorpos );
2101- appendStringInfoCharMacro (& buf ,',' );
2108+ appendStringInfoChar (& buf ,',' );
21022109
21032110/* file error location */
21042111if (Log_error_verbosity >=PGERROR_VERBOSE )
@@ -2117,7 +2124,7 @@ write_csvlog(ErrorData *edata)
21172124appendCSVLiteral (& buf ,msgbuf .data );
21182125pfree (msgbuf .data );
21192126}
2120- appendStringInfoCharMacro (& buf ,',' );
2127+ appendStringInfoChar (& buf ,',' );
21212128
21222129/* application name */
21232130if (application_name )