@@ -667,8 +667,10 @@ errcode_for_socket_access(void)
667
667
/* Expand %m in format string */ \
668
668
fmtbuf = expand_fmt_string (fmt , edata ); \
669
669
initStringInfo (& 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
+ } \
672
674
/* Generate actual output --- have to use appendStringInfoVA */ \
673
675
for (;;) \
674
676
{ \
@@ -708,8 +710,10 @@ errcode_for_socket_access(void)
708
710
/* Expand %m in format string */ \
709
711
fmtbuf = expand_fmt_string (fmt , edata ); \
710
712
initStringInfo (& 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
+ } \
713
717
/* Generate actual output --- have to use appendStringInfoVA */ \
714
718
for (;;) \
715
719
{ \
@@ -1809,7 +1813,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
1809
1813
1810
1814
if (appname == NULL || * appname == '\0' )
1811
1815
appname = _ ("[unknown]" );
1812
- appendStringInfo (buf , "%s" , appname );
1816
+ appendStringInfoString (buf , appname );
1813
1817
}
1814
1818
break ;
1815
1819
case 'u' :
@@ -1819,7 +1823,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
1819
1823
1820
1824
if (username == NULL || * username == '\0' )
1821
1825
username = _ ("[unknown]" );
1822
- appendStringInfo (buf , "%s" , username );
1826
+ appendStringInfoString (buf , username );
1823
1827
}
1824
1828
break ;
1825
1829
case 'd' :
@@ -1829,7 +1833,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
1829
1833
1830
1834
if (dbname == NULL || * dbname == '\0' )
1831
1835
dbname = _ ("[unknown]" );
1832
- appendStringInfo (buf , "%s" , dbname );
1836
+ appendStringInfoString (buf , dbname );
1833
1837
}
1834
1838
break ;
1835
1839
case 'c' :
@@ -1877,7 +1881,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
1877
1881
case 'r' :
1878
1882
if (MyProcPort && MyProcPort -> remote_host )
1879
1883
{
1880
- appendStringInfo (buf , "%s" , MyProcPort -> remote_host );
1884
+ appendStringInfoString (buf , MyProcPort -> remote_host );
1881
1885
if (MyProcPort -> remote_port &&
1882
1886
MyProcPort -> remote_port [0 ] != '\0' )
1883
1887
appendStringInfo (buf , "(%s)" ,
@@ -1886,7 +1890,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
1886
1890
break ;
1887
1891
case 'h' :
1888
1892
if (MyProcPort && MyProcPort -> remote_host )
1889
- appendStringInfo (buf , "%s" , MyProcPort -> remote_host );
1893
+ appendStringInfoString (buf , MyProcPort -> remote_host );
1890
1894
break ;
1891
1895
case 'q' :
1892
1896
/* in postmaster and friends, stop if %q is seen */
@@ -2004,9 +2008,12 @@ write_csvlog(ErrorData *edata)
2004
2008
if (MyProcPort && MyProcPort -> remote_host )
2005
2009
{
2006
2010
appendStringInfoChar (& buf , '"' );
2007
- appendStringInfo (& buf , "%s" , MyProcPort -> remote_host );
2011
+ appendStringInfoString (& buf , MyProcPort -> remote_host );
2008
2012
if (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
+ }
2010
2017
appendStringInfoChar (& buf , '"' );
2011
2018
}
2012
2019
appendStringInfoChar (& buf , ',' );
@@ -2053,40 +2060,40 @@ write_csvlog(ErrorData *edata)
2053
2060
appendStringInfoChar (& buf , ',' );
2054
2061
2055
2062
/* Error severity */
2056
- appendStringInfo (& buf , "%s" , error_severity (edata -> elevel ));
2063
+ appendStringInfoString (& buf , error_severity (edata -> elevel ));
2057
2064
appendStringInfoChar (& buf , ',' );
2058
2065
2059
2066
/* SQL state code */
2060
- appendStringInfo (& buf , "%s" , unpack_sql_state (edata -> sqlerrcode ));
2067
+ appendStringInfoString (& buf , unpack_sql_state (edata -> sqlerrcode ));
2061
2068
appendStringInfoChar (& buf , ',' );
2062
2069
2063
2070
/* errmessage */
2064
2071
appendCSVLiteral (& buf , edata -> message );
2065
- appendStringInfoCharMacro (& buf , ',' );
2072
+ appendStringInfoChar (& buf , ',' );
2066
2073
2067
2074
/* errdetail or errdetail_log */
2068
2075
if (edata -> detail_log )
2069
2076
appendCSVLiteral (& buf , edata -> detail_log );
2070
2077
else
2071
2078
appendCSVLiteral (& buf , edata -> detail );
2072
- appendStringInfoCharMacro (& buf , ',' );
2079
+ appendStringInfoChar (& buf , ',' );
2073
2080
2074
2081
/* errhint */
2075
2082
appendCSVLiteral (& buf , edata -> hint );
2076
- appendStringInfoCharMacro (& buf , ',' );
2083
+ appendStringInfoChar (& buf , ',' );
2077
2084
2078
2085
/* internal query */
2079
2086
appendCSVLiteral (& buf , edata -> internalquery );
2080
- appendStringInfoCharMacro (& buf , ',' );
2087
+ appendStringInfoChar (& buf , ',' );
2081
2088
2082
2089
/* if printed internal query, print internal pos too */
2083
2090
if (edata -> internalpos > 0 && edata -> internalquery != NULL )
2084
2091
appendStringInfo (& buf , "%d" , edata -> internalpos );
2085
- appendStringInfoCharMacro (& buf , ',' );
2092
+ appendStringInfoChar (& buf , ',' );
2086
2093
2087
2094
/* errcontext */
2088
2095
appendCSVLiteral (& buf , edata -> context );
2089
- appendStringInfoCharMacro (& buf , ',' );
2096
+ appendStringInfoChar (& buf , ',' );
2090
2097
2091
2098
/* user query --- only reported if not disabled by the caller */
2092
2099
if (is_log_level_output (edata -> elevel , log_min_error_statement ) &&
@@ -2095,10 +2102,10 @@ write_csvlog(ErrorData *edata)
2095
2102
print_stmt = true;
2096
2103
if (print_stmt )
2097
2104
appendCSVLiteral (& buf , debug_query_string );
2098
- appendStringInfoCharMacro (& buf , ',' );
2105
+ appendStringInfoChar (& buf , ',' );
2099
2106
if (print_stmt && edata -> cursorpos > 0 )
2100
2107
appendStringInfo (& buf , "%d" , edata -> cursorpos );
2101
- appendStringInfoCharMacro (& buf , ',' );
2108
+ appendStringInfoChar (& buf , ',' );
2102
2109
2103
2110
/* file error location */
2104
2111
if (Log_error_verbosity >= PGERROR_VERBOSE )
@@ -2117,7 +2124,7 @@ write_csvlog(ErrorData *edata)
2117
2124
appendCSVLiteral (& buf , msgbuf .data );
2118
2125
pfree (msgbuf .data );
2119
2126
}
2120
- appendStringInfoCharMacro (& buf , ',' );
2127
+ appendStringInfoChar (& buf , ',' );
2121
2128
2122
2129
/* application name */
2123
2130
if (application_name )
0 commit comments