Skip to content

Commit 928394b

Browse files
committed
Improve various new-to-v18 appendStringInfo calls
Similar to 8461424, here we adjust a few new locations which were not using the most suitable appendStringInfo* function for the intended purpose. Author: David Rowley <drowleyml@gmail.com Discussion: https://postgr.es/m/CAApHDvqJnNjueb=Eoj8K+8n0g7nj_AcPWSiCj5RNV4fDejAfqA@mail.gmail.com
1 parent 55ef7ab commit 928394b

File tree

9 files changed

+30
-30
lines changed

9 files changed

+30
-30
lines changed

contrib/dblink/dblink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3228,7 +3228,7 @@ appendSCRAMKeysInfo(StringInfo buf)
32283228

32293229
appendStringInfo(buf, "scram_client_key='%s' ", client_key);
32303230
appendStringInfo(buf, "scram_server_key='%s' ", server_key);
3231-
appendStringInfo(buf, "require_auth='scram-sha-256' ");
3231+
appendStringInfoString(buf, "require_auth='scram-sha-256' ");
32323232

32333233
pfree(client_key);
32343234
pfree(server_key);

contrib/pg_overexplain/pg_overexplain.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ overexplain_debug(PlannedStmt *plannedstmt, ExplainState *es)
292292
if (es->format == EXPLAIN_FORMAT_TEXT)
293293
{
294294
ExplainIndentText(es);
295-
appendStringInfo(es->str, "PlannedStmt:\n");
295+
appendStringInfoString(es->str, "PlannedStmt:\n");
296296
es->indent++;
297297
}
298298

@@ -329,19 +329,19 @@ overexplain_debug(PlannedStmt *plannedstmt, ExplainState *es)
329329
/* Print various properties as a comma-separated list of flags. */
330330
initStringInfo(&flags);
331331
if (plannedstmt->hasReturning)
332-
appendStringInfo(&flags, ", hasReturning");
332+
appendStringInfoString(&flags, ", hasReturning");
333333
if (plannedstmt->hasModifyingCTE)
334-
appendStringInfo(&flags, ", hasModifyingCTE");
334+
appendStringInfoString(&flags, ", hasModifyingCTE");
335335
if (plannedstmt->canSetTag)
336-
appendStringInfo(&flags, ", canSetTag");
336+
appendStringInfoString(&flags, ", canSetTag");
337337
if (plannedstmt->transientPlan)
338-
appendStringInfo(&flags, ", transientPlan");
338+
appendStringInfoString(&flags, ", transientPlan");
339339
if (plannedstmt->dependsOnRole)
340-
appendStringInfo(&flags, ", dependsOnRole");
340+
appendStringInfoString(&flags, ", dependsOnRole");
341341
if (plannedstmt->parallelModeNeeded)
342-
appendStringInfo(&flags, ", parallelModeNeeded");
342+
appendStringInfoString(&flags, ", parallelModeNeeded");
343343
if (flags.len == 0)
344-
appendStringInfo(&flags, ", none");
344+
appendStringInfoString(&flags, ", none");
345345
ExplainPropertyText("Flags", flags.data + 2, es);
346346

347347
/* Various lists of integers. */
@@ -763,7 +763,7 @@ overexplain_intlist(const char *qlabel, List *list, ExplainState *es)
763763
}
764764
else
765765
{
766-
appendStringInfo(&buf, " not an integer list");
766+
appendStringInfoString(&buf, " not an integer list");
767767
Assert(false);
768768
}
769769

src/backend/commands/explain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
18481848

18491849
if (es->format == EXPLAIN_FORMAT_TEXT)
18501850
{
1851-
appendStringInfo(es->str, " (actual ");
1851+
appendStringInfoString(es->str, " (actual ");
18521852

18531853
if (es->timing)
18541854
appendStringInfo(es->str, "time=%.3f..%.3f ", startup_ms, total_ms);
@@ -1917,7 +1917,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
19171917
if (es->format == EXPLAIN_FORMAT_TEXT)
19181918
{
19191919
ExplainIndentText(es);
1920-
appendStringInfo(es->str, "actual ");
1920+
appendStringInfoString(es->str, "actual ");
19211921
if (es->timing)
19221922
appendStringInfo(es->str, "time=%.3f..%.3f ", startup_ms, total_ms);
19231923

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ libpqrcv_alter_slot(WalReceiverConn *conn, const char *slotname,
10121012
*failover ? "true" : "false");
10131013

10141014
if (failover && two_phase)
1015-
appendStringInfo(&cmd, ", ");
1015+
appendStringInfoString(&cmd, ", ");
10161016

10171017
if (two_phase)
10181018
appendStringInfo(&cmd, "TWO_PHASE %s",

src/backend/replication/logical/conflict.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ errdetail_apply_conflict(EState *estate, ResultRelInfo *relinfo,
262262
break;
263263

264264
case CT_UPDATE_MISSING:
265-
appendStringInfo(&err_detail, _("Could not find the row to be updated."));
265+
appendStringInfoString(&err_detail, _("Could not find the row to be updated."));
266266
break;
267267

268268
case CT_DELETE_ORIGIN_DIFFERS:
@@ -281,7 +281,7 @@ errdetail_apply_conflict(EState *estate, ResultRelInfo *relinfo,
281281
break;
282282

283283
case CT_DELETE_MISSING:
284-
appendStringInfo(&err_detail, _("Could not find the row to be deleted."));
284+
appendStringInfoString(&err_detail, _("Could not find the row to be deleted."));
285285
break;
286286
}
287287

@@ -304,7 +304,7 @@ errdetail_apply_conflict(EState *estate, ResultRelInfo *relinfo,
304304
if (err_msg->len > 0)
305305
appendStringInfoChar(err_msg, '\n');
306306

307-
appendStringInfo(err_msg, "%s", err_detail.data);
307+
appendStringInfoString(err_msg, err_detail.data);
308308
}
309309

310310
/*

src/backend/replication/logical/relation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ logicalrep_get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
238238
{
239239
attcnt++;
240240
if (attcnt > 1)
241-
appendStringInfo(&attsbuf, _(", "));
241+
appendStringInfoString(&attsbuf, _(", "));
242242

243243
appendStringInfo(&attsbuf, _("\"%s\""), remoterel->attnames[i]);
244244
}

src/backend/replication/logical/tablesync.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -940,15 +940,15 @@ fetch_remote_table_info(char *nspname, char *relname, LogicalRepRelation *lrel,
940940
* Now fetch column names and types.
941941
*/
942942
resetStringInfo(&cmd);
943-
appendStringInfo(&cmd,
944-
"SELECT a.attnum,"
945-
" a.attname,"
946-
" a.atttypid,"
947-
" a.attnum = ANY(i.indkey)");
943+
appendStringInfoString(&cmd,
944+
"SELECT a.attnum,"
945+
" a.attname,"
946+
" a.atttypid,"
947+
" a.attnum = ANY(i.indkey)");
948948

949949
/* Generated columns can be replicated since version 18. */
950950
if (server_version >= 180000)
951-
appendStringInfo(&cmd, ", a.attgenerated != ''");
951+
appendStringInfoString(&cmd, ", a.attgenerated != ''");
952952

953953
appendStringInfo(&cmd,
954954
" FROM pg_catalog.pg_attribute a"

src/backend/utils/adt/ri_triggers.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,13 @@ RI_FKey_check(TriggerData *trigdata)
428428
{
429429
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[riinfo->nkeys - 1]);
430430

431-
appendStringInfo(&querybuf, ") x1 HAVING ");
431+
appendStringInfoString(&querybuf, ") x1 HAVING ");
432432
sprintf(paramname, "$%d", riinfo->nkeys);
433433
ri_GenerateQual(&querybuf, "",
434434
paramname, fk_type,
435435
riinfo->agged_period_contained_by_oper,
436436
"pg_catalog.range_agg", ANYMULTIRANGEOID);
437-
appendStringInfo(&querybuf, "(x1.r)");
437+
appendStringInfoString(&querybuf, "(x1.r)");
438438
}
439439

440440
/* Prepare and save the plan */
@@ -597,13 +597,13 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel,
597597
{
598598
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[riinfo->nkeys - 1]);
599599

600-
appendStringInfo(&querybuf, ") x1 HAVING ");
600+
appendStringInfoString(&querybuf, ") x1 HAVING ");
601601
sprintf(paramname, "$%d", riinfo->nkeys);
602602
ri_GenerateQual(&querybuf, "",
603603
paramname, fk_type,
604604
riinfo->agged_period_contained_by_oper,
605605
"pg_catalog.range_agg", ANYMULTIRANGEOID);
606-
appendStringInfo(&querybuf, "(x1.r)");
606+
appendStringInfoString(&querybuf, "(x1.r)");
607607
}
608608

609609
/* Prepare and save the plan */
@@ -838,12 +838,12 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
838838

839839
/* Intersect the fk with the old pk range */
840840
initStringInfo(&intersectbuf);
841-
appendStringInfoString(&intersectbuf, "(");
841+
appendStringInfoChar(&intersectbuf, '(');
842842
ri_GenerateQual(&intersectbuf, "",
843843
attname, fk_period_type,
844844
riinfo->period_intersect_oper,
845845
paramname, pk_period_type);
846-
appendStringInfoString(&intersectbuf, ")");
846+
appendStringInfoChar(&intersectbuf, ')');
847847

848848
/* Find the remaining history */
849849
initStringInfo(&replacementsbuf);

src/bin/pg_dump/pg_restore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ process_global_sql_commands(PGconn *conn, const char *dumpdirpath, const char *o
13121312
appendStringInfoString(&user_create, "CREATE ROLE ");
13131313
/* should use fmtId here, but we don't know the encoding */
13141314
appendStringInfoString(&user_create, PQuser(conn));
1315-
appendStringInfoString(&user_create, ";");
1315+
appendStringInfoChar(&user_create, ';');
13161316

13171317
/* Process file till EOF and execute sql statements. */
13181318
while (read_one_statement(&sqlstatement, pfile) != EOF)

0 commit comments

Comments
 (0)