Skip to content

Commit f92d6a5

Browse files
committed
Use appendStringInfoString/Char et al where appropriate.
Patch by David Rowley. Backpatch to 9.5, as some of the calls were new in 9.5, and keeping the code in sync with master makes future backpatching easier.
1 parent 7931622 commit f92d6a5

File tree

17 files changed

+32
-32
lines changed

17 files changed

+32
-32
lines changed

contrib/postgres_fdw/postgres_fdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,7 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
27382738
}
27392739

27402740
/* Append ORDER BY at the end of query to ensure output ordering */
2741-
appendStringInfo(&buf, " ORDER BY c.relname, a.attnum");
2741+
appendStringInfoString(&buf, " ORDER BY c.relname, a.attnum");
27422742

27432743
/* Fetch the data */
27442744
res = PQexec(conn, buf.data);

src/backend/access/rmgrdesc/gindesc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ gin_desc(StringInfo buf, XLogReaderState *record)
113113
(ginxlogRecompressDataLeaf *) payload;
114114

115115
if (XLogRecHasBlockImage(record, 0))
116-
appendStringInfo(buf, " (full page image)");
116+
appendStringInfoString(buf, " (full page image)");
117117
else
118118
desc_recompress_leaf(buf, insertData);
119119
}
@@ -147,7 +147,7 @@ gin_desc(StringInfo buf, XLogReaderState *record)
147147
ginxlogVacuumDataLeafPage *xlrec = (ginxlogVacuumDataLeafPage *) rec;
148148

149149
if (XLogRecHasBlockImage(record, 0))
150-
appendStringInfo(buf, " (full page image)");
150+
appendStringInfoString(buf, " (full page image)");
151151
else
152152
desc_recompress_leaf(buf, &xlrec->data);
153153
}

src/backend/access/rmgrdesc/spgdesc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ spg_desc(StringInfo buf, XLogReaderState *record)
3030
{
3131
spgxlogAddLeaf *xlrec = (spgxlogAddLeaf *) rec;
3232

33-
appendStringInfo(buf, "add leaf to page");
33+
appendStringInfoString(buf, "add leaf to page");
3434
appendStringInfo(buf, "; off %u; headoff %u; parentoff %u",
3535
xlrec->offnumLeaf, xlrec->offnumHeadLeaf,
3636
xlrec->offnumParent);
3737
if (xlrec->newPage)
38-
appendStringInfo(buf, " (newpage)");
38+
appendStringInfoString(buf, " (newpage)");
3939
if (xlrec->storesNulls)
40-
appendStringInfo(buf, " (nulls)");
40+
appendStringInfoString(buf, " (nulls)");
4141
}
4242
break;
4343
case XLOG_SPGIST_MOVE_LEAFS:
@@ -63,9 +63,9 @@ spg_desc(StringInfo buf, XLogReaderState *record)
6363
appendStringInfo(buf, "ndel %u; nins %u",
6464
xlrec->nDelete, xlrec->nInsert);
6565
if (xlrec->innerIsParent)
66-
appendStringInfo(buf, " (innerIsParent)");
66+
appendStringInfoString(buf, " (innerIsParent)");
6767
if (xlrec->isRootSplit)
68-
appendStringInfo(buf, " (isRootSplit)");
68+
appendStringInfoString(buf, " (isRootSplit)");
6969
}
7070
break;
7171
case XLOG_SPGIST_VACUUM_LEAF:

src/backend/access/rmgrdesc/xactdesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ xact_desc_commit(StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId
232232
}
233233

234234
if (XactCompletionForceSyncCommit(parsed.xinfo))
235-
appendStringInfo(buf, "; sync");
235+
appendStringInfoString(buf, "; sync");
236236

237237
if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
238238
{

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ XLogInsertRecord(XLogRecData *rdata, XLogRecPtr fpw_lsn)
10971097

10981098
if (!debug_reader)
10991099
{
1100-
appendStringInfo(&buf, "error decoding record: out of memory");
1100+
appendStringInfoString(&buf, "error decoding record: out of memory");
11011101
}
11021102
else if (!DecodeXLogRecord(debug_reader, (XLogRecord *) recordBuf.data,
11031103
&errormsg))
@@ -9528,7 +9528,7 @@ xlog_outrec(StringInfo buf, XLogReaderState *record)
95289528
rnode.spcNode, rnode.dbNode, rnode.relNode,
95299529
blk);
95309530
if (XLogRecHasBlockImage(record, block_id))
9531-
appendStringInfo(buf, " FPW");
9531+
appendStringInfoString(buf, " FPW");
95329532
}
95339533
}
95349534
#endif /* WAL_DEBUG */

src/backend/lib/pairingheap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pairingheap_dump_recurse(StringInfo buf,
306306

307307
appendStringInfoSpaces(buf, depth * 4);
308308
dumpfunc(node, buf, opaque);
309-
appendStringInfoString(buf, "\n");
309+
appendStringInfoChar(buf, '\n');
310310
if (node->first_child)
311311
pairingheap_dump_recurse(buf, node->first_child, dumpfunc, opaque, depth + 1, node);
312312
prev_or_parent = node;

src/backend/utils/adt/ruleutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5487,7 +5487,7 @@ get_insert_query_def(Query *query, deparse_context *context)
54875487
{
54885488
OnConflictExpr *confl = query->onConflict;
54895489

5490-
appendStringInfo(buf, " ON CONFLICT");
5490+
appendStringInfoString(buf, " ON CONFLICT");
54915491

54925492
if (confl->arbiterElems)
54935493
{

src/backend/utils/adt/xml.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,7 +2473,7 @@ query_to_xml_internal(const char *query, char *tablename,
24732473
{
24742474
xmldata_root_element_start(result, xmltn, xmlschema,
24752475
targetns, top_level);
2476-
appendStringInfoString(result, "\n");
2476+
appendStringInfoChar(result, '\n');
24772477
}
24782478

24792479
if (xmlschema)
@@ -2637,7 +2637,7 @@ schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls,
26372637
result = makeStringInfo();
26382638

26392639
xmldata_root_element_start(result, xmlsn, xmlschema, targetns, top_level);
2640-
appendStringInfoString(result, "\n");
2640+
appendStringInfoChar(result, '\n');
26412641

26422642
if (xmlschema)
26432643
appendStringInfo(result, "%s\n\n", xmlschema);
@@ -2815,7 +2815,7 @@ database_to_xml_internal(const char *xmlschema, bool nulls,
28152815
result = makeStringInfo();
28162816

28172817
xmldata_root_element_start(result, xmlcn, xmlschema, targetns, true);
2818-
appendStringInfoString(result, "\n");
2818+
appendStringInfoChar(result, '\n');
28192819

28202820
if (xmlschema)
28212821
appendStringInfo(result, "%s\n\n", xmlschema);

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ GenerateRecoveryConf(PGconn *conn)
15161516

15171517
/* Separate key-value pairs with spaces */
15181518
if (conninfo_buf.len != 0)
1519-
appendPQExpBufferStr(&conninfo_buf, " ");
1519+
appendPQExpBufferChar(&conninfo_buf, ' ');
15201520

15211521
/*
15221522
* Write "keyword=value" pieces, the value string is escaped and/or

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ RestoreArchive(Archive *AHX)
533533
* search for hardcoded "DROP CONSTRAINT" instead.
534534
*/
535535
if (strcmp(te->desc, "DEFAULT") == 0)
536-
appendPQExpBuffer(ftStmt, "%s", dropStmt);
536+
appendPQExpBufferStr(ftStmt, dropStmt);
537537
else
538538
{
539539
if (strcmp(te->desc, "CONSTRAINT") == 0 ||

src/bin/pg_dump/pg_dump.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext)
16591659
/* append the list of column names if required */
16601660
if (dopt->column_inserts)
16611661
{
1662-
appendPQExpBufferStr(insertStmt, "(");
1662+
appendPQExpBufferChar(insertStmt, '(');
16631663
for (field = 0; field < nfields; field++)
16641664
{
16651665
if (field > 0)
@@ -11332,7 +11332,7 @@ dumpOpclass(Archive *fout, DumpOptions *dopt, OpclassInfo *opcinfo)
1133211332
appendPQExpBufferStr(q, " FAMILY ");
1133311333
if (strcmp(opcfamilynsp, opcinfo->dobj.namespace->dobj.name) != 0)
1133411334
appendPQExpBuffer(q, "%s.", fmtId(opcfamilynsp));
11335-
appendPQExpBuffer(q, "%s", fmtId(opcfamilyname));
11335+
appendPQExpBufferStr(q, fmtId(opcfamilyname));
1133611336
}
1133711337
appendPQExpBufferStr(q, " AS\n ");
1133811338

@@ -13844,7 +13844,7 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
1384413844
if (actual_atts == 0)
1384513845
appendPQExpBufferStr(q, " (");
1384613846
else
13847-
appendPQExpBufferStr(q, ",");
13847+
appendPQExpBufferChar(q, ',');
1384813848
appendPQExpBufferStr(q, "\n ");
1384913849
actual_atts++;
1385013850

src/bin/psql/describe.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,15 +1611,15 @@ describeOneTableDetails(const char *schemaname,
16111611
if (!PQgetisnull(res, i, 5))
16121612
{
16131613
if (tmpbuf.len > 0)
1614-
appendPQExpBufferStr(&tmpbuf, " ");
1614+
appendPQExpBufferChar(&tmpbuf, ' ');
16151615
appendPQExpBuffer(&tmpbuf, _("collate %s"),
16161616
PQgetvalue(res, i, 5));
16171617
}
16181618

16191619
if (strcmp(PQgetvalue(res, i, 3), "t") == 0)
16201620
{
16211621
if (tmpbuf.len > 0)
1622-
appendPQExpBufferStr(&tmpbuf, " ");
1622+
appendPQExpBufferChar(&tmpbuf, ' ');
16231623
appendPQExpBufferStr(&tmpbuf, _("not null"));
16241624
}
16251625

@@ -1628,7 +1628,7 @@ describeOneTableDetails(const char *schemaname,
16281628
if (strlen(PQgetvalue(res, i, 2)) != 0)
16291629
{
16301630
if (tmpbuf.len > 0)
1631-
appendPQExpBufferStr(&tmpbuf, " ");
1631+
appendPQExpBufferChar(&tmpbuf, ' ');
16321632
/* translator: default values of column definitions */
16331633
appendPQExpBuffer(&tmpbuf, _("default %s"),
16341634
PQgetvalue(res, i, 2));
@@ -2440,7 +2440,7 @@ describeOneTableDetails(const char *schemaname,
24402440
printfPQExpBuffer(&buf, "%*s %s",
24412441
sw, "", PQgetvalue(result, i, 0));
24422442
if (i < tuples - 1)
2443-
appendPQExpBufferStr(&buf, ",");
2443+
appendPQExpBufferChar(&buf, ',');
24442444

24452445
printTableAddFooter(&cont, buf.data);
24462446
}

src/bin/scripts/clusterdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ cluster_one_database(const char *dbname, bool verbose, const char *table,
201201
appendPQExpBufferStr(&sql, " VERBOSE");
202202
if (table)
203203
appendPQExpBuffer(&sql, " %s", table);
204-
appendPQExpBufferStr(&sql, ";");
204+
appendPQExpBufferChar(&sql, ';');
205205

206206
conn = connectDatabase(dbname, host, port, username, prompt_password,
207207
progname, false);

src/bin/scripts/createdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ main(int argc, char *argv[])
195195
if (lc_ctype)
196196
appendPQExpBuffer(&sql, " LC_CTYPE '%s'", lc_ctype);
197197

198-
appendPQExpBufferStr(&sql, ";");
198+
appendPQExpBufferChar(&sql, ';');
199199

200200
/* No point in trying to use postgres db when creating postgres db. */
201201
if (maintenance_db == NULL && strcmp(dbname, "postgres") == 0)
@@ -222,7 +222,7 @@ main(int argc, char *argv[])
222222
{
223223
printfPQExpBuffer(&sql, "COMMENT ON DATABASE %s IS ", fmtId(dbname));
224224
appendStringLiteralConn(&sql, comment, conn);
225-
appendPQExpBufferStr(&sql, ";");
225+
appendPQExpBufferChar(&sql, ';');
226226

227227
if (echo)
228228
printf("%s\n", sql.data);

src/bin/scripts/createuser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ main(int argc, char *argv[])
321321
appendPQExpBuffer(&sql, "%s", fmtId(cell->val));
322322
}
323323
}
324-
appendPQExpBufferStr(&sql, ";");
324+
appendPQExpBufferChar(&sql, ';');
325325

326326
if (echo)
327327
printf("%s\n", sql.data);

src/bin/scripts/reindexdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
295295
appendPQExpBuffer(&sql, " SCHEMA %s", name);
296296
else if (strcmp(type, "DATABASE") == 0)
297297
appendPQExpBuffer(&sql, " DATABASE %s", fmtId(name));
298-
appendPQExpBufferStr(&sql, ";");
298+
appendPQExpBufferChar(&sql, ';');
299299

300300
conn = connectDatabase(dbname, host, port, username, prompt_password,
301301
progname, false);

src/bin/scripts/vacuumdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
392392
ntups = PQntuples(res);
393393
for (i = 0; i < ntups; i++)
394394
{
395-
appendPQExpBuffer(&buf, "%s",
395+
appendPQExpBufferStr(&buf,
396396
fmtQualifiedId(PQserverVersion(conn),
397397
PQgetvalue(res, i, 1),
398398
PQgetvalue(res, i, 0)));
@@ -643,7 +643,7 @@ prepare_vacuum_command(PQExpBuffer sql, PGconn *conn, vacuumingOptions *vacopts,
643643
sep = comma;
644644
}
645645
if (sep != paren)
646-
appendPQExpBufferStr(sql, ")");
646+
appendPQExpBufferChar(sql, ')');
647647
}
648648
else
649649
{

0 commit comments

Comments
 (0)