Skip to content

Commit f736e18

Browse files
committed
Standardize usages of appendStringInfo and appendPQExpBuffer
Fix a few places that were using appendStringInfo() when they should have been using appendStringInfoString(). Also some cases of appendPQExpBuffer() that would have been better suited to use appendPQExpBufferChar(), and finally, some places that used appendPQExpBuffer() when appendPQExpBufferStr() would have suited better. There are no bugs are being fixed here. The aim is just to make the code use the most optimal function for the job. All the code being changed here is new to PG14. It makes sense to fix these before we branch for PG15. There are a few other places that we could fix, but those cases are older code so fixing those seems less worthwhile as it may cause unnecessary back-patching pain in the future. Author: Hou Zhijie Discussion: https://postgr.es/m/OS0PR01MB5716732158B1C4142C6FE375943D9@OS0PR01MB5716.jpnprd01.prod.outlook.com
1 parent 8279f68 commit f736e18

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Diff for: src/backend/access/brin/brin_minmax_multi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3084,7 +3084,7 @@ brin_minmax_multi_summary_out(PG_FUNCTION_ARGS)
30843084

30853085
a = FunctionCall1(&fmgrinfo, ranges_deserialized->values[idx++]);
30863086

3087-
appendStringInfo(&str, "%s", DatumGetPointer(a));
3087+
appendStringInfoString(&str, DatumGetPointer(a));
30883088

30893089
b = cstring_to_text(str.data);
30903090

Diff for: src/backend/access/heap/vacuumlazy.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -783,18 +783,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
783783
msgfmt = _(" %u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n");
784784

785785
if (vacrel->nindexes == 0 || vacrel->num_index_scans == 0)
786-
appendStringInfo(&buf, _("index scan not needed:"));
786+
appendStringInfoString(&buf, _("index scan not needed:"));
787787
else
788-
appendStringInfo(&buf, _("index scan needed:"));
788+
appendStringInfoString(&buf, _("index scan needed:"));
789789
}
790790
else
791791
{
792792
msgfmt = _(" %u pages from table (%.2f%% of total) have %lld dead item identifiers\n");
793793

794794
if (!vacrel->do_failsafe)
795-
appendStringInfo(&buf, _("index scan bypassed:"));
795+
appendStringInfoString(&buf, _("index scan bypassed:"));
796796
else
797-
appendStringInfo(&buf, _("index scan bypassed by failsafe:"));
797+
appendStringInfoString(&buf, _("index scan bypassed by failsafe:"));
798798
}
799799
orig_rel_pages = vacrel->rel_pages + vacrel->pages_removed;
800800
appendStringInfo(&buf, msgfmt,

Diff for: src/bin/pg_amcheck/pg_amcheck.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ prepare_heap_command(PQExpBuffer sql, RelationInfo *rel, PGconn *conn)
844844
if (opts.endblock >= 0)
845845
appendPQExpBuffer(sql, ", endblock := " INT64_FORMAT, opts.endblock);
846846

847-
appendPQExpBuffer(sql, ")");
847+
appendPQExpBufferChar(sql, ')');
848848
}
849849

850850
/*

Diff for: src/bin/psql/describe.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,7 @@ describeOneTableDetails(const char *schemaname,
29342934

29352935
if (has_some && !has_all)
29362936
{
2937-
appendPQExpBuffer(&buf, " (");
2937+
appendPQExpBufferStr(&buf, " (");
29382938

29392939
/* options */
29402940
if (has_ndistinct)
@@ -2954,7 +2954,7 @@ describeOneTableDetails(const char *schemaname,
29542954
appendPQExpBuffer(&buf, "%smcv", gotone ? ", " : "");
29552955
}
29562956

2957-
appendPQExpBuffer(&buf, ")");
2957+
appendPQExpBufferChar(&buf, ')');
29582958
}
29592959

29602960
appendPQExpBuffer(&buf, " ON %s FROM %s",
@@ -3577,7 +3577,7 @@ describeOneTableDetails(const char *schemaname,
35773577
child_relkind == RELKIND_PARTITIONED_INDEX)
35783578
appendPQExpBufferStr(&buf, ", PARTITIONED");
35793579
if (strcmp(PQgetvalue(result, i, 2), "t") == 0)
3580-
appendPQExpBuffer(&buf, " (DETACH PENDING)");
3580+
appendPQExpBufferStr(&buf, " (DETACH PENDING)");
35813581
if (i < tuples - 1)
35823582
appendPQExpBufferChar(&buf, ',');
35833583

0 commit comments

Comments
 (0)