Improve various new-to-v18 appendStringInfo calls
authorDavid Rowley <[email protected]>
Thu, 10 Apr 2025 22:07:22 +0000 (10:07 +1200)
committerDavid Rowley <[email protected]>
Thu, 10 Apr 2025 22:07:22 +0000 (10:07 +1200)
Similar to 8461424fd, here we adjust a few new locations which were not
using the most suitable appendStringInfo* function for the intended
purpose.

Author: David Rowley <[email protected]
Discussion: https://postgr.es/m/CAApHDvqJnNjueb=Eoj8K+8n0g7nj_AcPWSiCj5RNV4fDejAfqA@mail.gmail.com

contrib/dblink/dblink.c
contrib/pg_overexplain/pg_overexplain.c
src/backend/commands/explain.c
src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
src/backend/replication/logical/conflict.c
src/backend/replication/logical/relation.c
src/backend/replication/logical/tablesync.c
src/backend/utils/adt/ri_triggers.c
src/bin/pg_dump/pg_restore.c

index c2e695e364e93857ef5a3346d4cfd18d1defed70..092f0753ff585b1cefbefd4613f5aba6b49d6f90 100644 (file)
@@ -3228,7 +3228,7 @@ appendSCRAMKeysInfo(StringInfo buf)
 
    appendStringInfo(buf, "scram_client_key='%s' ", client_key);
    appendStringInfo(buf, "scram_server_key='%s' ", server_key);
-   appendStringInfo(buf, "require_auth='scram-sha-256' ");
+   appendStringInfoString(buf, "require_auth='scram-sha-256' ");
 
    pfree(client_key);
    pfree(server_key);
index afc34ad5f2f184077cd40a603a4914f028341552..68c40fc98ea5b7135efe8fcadba426cf14a769a9 100644 (file)
@@ -292,7 +292,7 @@ overexplain_debug(PlannedStmt *plannedstmt, ExplainState *es)
    if (es->format == EXPLAIN_FORMAT_TEXT)
    {
        ExplainIndentText(es);
-       appendStringInfo(es->str, "PlannedStmt:\n");
+       appendStringInfoString(es->str, "PlannedStmt:\n");
        es->indent++;
    }
 
@@ -329,19 +329,19 @@ overexplain_debug(PlannedStmt *plannedstmt, ExplainState *es)
    /* Print various properties as a comma-separated list of flags. */
    initStringInfo(&flags);
    if (plannedstmt->hasReturning)
-       appendStringInfo(&flags, ", hasReturning");
+       appendStringInfoString(&flags, ", hasReturning");
    if (plannedstmt->hasModifyingCTE)
-       appendStringInfo(&flags, ", hasModifyingCTE");
+       appendStringInfoString(&flags, ", hasModifyingCTE");
    if (plannedstmt->canSetTag)
-       appendStringInfo(&flags, ", canSetTag");
+       appendStringInfoString(&flags, ", canSetTag");
    if (plannedstmt->transientPlan)
-       appendStringInfo(&flags, ", transientPlan");
+       appendStringInfoString(&flags, ", transientPlan");
    if (plannedstmt->dependsOnRole)
-       appendStringInfo(&flags, ", dependsOnRole");
+       appendStringInfoString(&flags, ", dependsOnRole");
    if (plannedstmt->parallelModeNeeded)
-       appendStringInfo(&flags, ", parallelModeNeeded");
+       appendStringInfoString(&flags, ", parallelModeNeeded");
    if (flags.len == 0)
-       appendStringInfo(&flags, ", none");
+       appendStringInfoString(&flags, ", none");
    ExplainPropertyText("Flags", flags.data + 2, es);
 
    /* Various lists of integers. */
@@ -763,7 +763,7 @@ overexplain_intlist(const char *qlabel, List *list, ExplainState *es)
    }
    else
    {
-       appendStringInfo(&buf, " not an integer list");
+       appendStringInfoString(&buf, " not an integer list");
        Assert(false);
    }
 
index ef8aa489af8d23bf76278e95556e26b0ee1cd1f6..786ee865f147d72d1ac36da12016fcb6d90b75f1 100644 (file)
@@ -1848,7 +1848,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
 
        if (es->format == EXPLAIN_FORMAT_TEXT)
        {
-           appendStringInfo(es->str, " (actual ");
+           appendStringInfoString(es->str, " (actual ");
 
            if (es->timing)
                appendStringInfo(es->str, "time=%.3f..%.3f ", startup_ms, total_ms);
@@ -1917,7 +1917,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
            if (es->format == EXPLAIN_FORMAT_TEXT)
            {
                ExplainIndentText(es);
-               appendStringInfo(es->str, "actual ");
+               appendStringInfoString(es->str, "actual ");
                if (es->timing)
                    appendStringInfo(es->str, "time=%.3f..%.3f ", startup_ms, total_ms);
 
index 200e8f1aabd343e0f05864cf144877dea5a27b46..7b4ddf7a8f52fdf364018357ffbf0e3d4b461748 100644 (file)
@@ -1012,7 +1012,7 @@ libpqrcv_alter_slot(WalReceiverConn *conn, const char *slotname,
                         *failover ? "true" : "false");
 
    if (failover && two_phase)
-       appendStringInfo(&cmd, ", ");
+       appendStringInfoString(&cmd, ", ");
 
    if (two_phase)
        appendStringInfo(&cmd, "TWO_PHASE %s",
index f1e92f2fc1a35564e4acd1776c4f0aff95812cbe..97c4e26b58654cacef034776dd2bf8c4ab450625 100644 (file)
@@ -262,7 +262,7 @@ errdetail_apply_conflict(EState *estate, ResultRelInfo *relinfo,
            break;
 
        case CT_UPDATE_MISSING:
-           appendStringInfo(&err_detail, _("Could not find the row to be updated."));
+           appendStringInfoString(&err_detail, _("Could not find the row to be updated."));
            break;
 
        case CT_DELETE_ORIGIN_DIFFERS:
@@ -281,7 +281,7 @@ errdetail_apply_conflict(EState *estate, ResultRelInfo *relinfo,
            break;
 
        case CT_DELETE_MISSING:
-           appendStringInfo(&err_detail, _("Could not find the row to be deleted."));
+           appendStringInfoString(&err_detail, _("Could not find the row to be deleted."));
            break;
    }
 
@@ -304,7 +304,7 @@ errdetail_apply_conflict(EState *estate, ResultRelInfo *relinfo,
    if (err_msg->len > 0)
        appendStringInfoChar(err_msg, '\n');
 
-   appendStringInfo(err_msg, "%s", err_detail.data);
+   appendStringInfoString(err_msg, err_detail.data);
 }
 
 /*
index 46d15b824e380b54c57fd42a9655d0b3efc4084d..f59046ad620da00003394bd47886e2cf78b0f23e 100644 (file)
@@ -238,7 +238,7 @@ logicalrep_get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
    {
        attcnt++;
        if (attcnt > 1)
-           appendStringInfo(&attsbuf, _(", "));
+           appendStringInfoString(&attsbuf, _(", "));
 
        appendStringInfo(&attsbuf, _("\"%s\""), remoterel->attnames[i]);
    }
index 65b98aa905fe771961690046108481c9ebd3381f..8e1e8762f6258fd7e3a97623d60fa75e554bbb03 100644 (file)
@@ -940,15 +940,15 @@ fetch_remote_table_info(char *nspname, char *relname, LogicalRepRelation *lrel,
     * Now fetch column names and types.
     */
    resetStringInfo(&cmd);
-   appendStringInfo(&cmd,
-                    "SELECT a.attnum,"
-                    "       a.attname,"
-                    "       a.atttypid,"
-                    "       a.attnum = ANY(i.indkey)");
+   appendStringInfoString(&cmd,
+                          "SELECT a.attnum,"
+                          "       a.attname,"
+                          "       a.atttypid,"
+                          "       a.attnum = ANY(i.indkey)");
 
    /* Generated columns can be replicated since version 18. */
    if (server_version >= 180000)
-       appendStringInfo(&cmd, ", a.attgenerated != ''");
+       appendStringInfoString(&cmd, ", a.attgenerated != ''");
 
    appendStringInfo(&cmd,
                     "  FROM pg_catalog.pg_attribute a"
index c4ff18ce65ebe35840563e57b98d96c403c84474..6239900fa2892474cf6ff329c10fcd818338eb6d 100644 (file)
@@ -428,13 +428,13 @@ RI_FKey_check(TriggerData *trigdata)
        {
            Oid         fk_type = RIAttType(fk_rel, riinfo->fk_attnums[riinfo->nkeys - 1]);
 
-           appendStringInfo(&querybuf, ") x1 HAVING ");
+           appendStringInfoString(&querybuf, ") x1 HAVING ");
            sprintf(paramname, "$%d", riinfo->nkeys);
            ri_GenerateQual(&querybuf, "",
                            paramname, fk_type,
                            riinfo->agged_period_contained_by_oper,
                            "pg_catalog.range_agg", ANYMULTIRANGEOID);
-           appendStringInfo(&querybuf, "(x1.r)");
+           appendStringInfoString(&querybuf, "(x1.r)");
        }
 
        /* Prepare and save the plan */
@@ -597,13 +597,13 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel,
        {
            Oid         fk_type = RIAttType(fk_rel, riinfo->fk_attnums[riinfo->nkeys - 1]);
 
-           appendStringInfo(&querybuf, ") x1 HAVING ");
+           appendStringInfoString(&querybuf, ") x1 HAVING ");
            sprintf(paramname, "$%d", riinfo->nkeys);
            ri_GenerateQual(&querybuf, "",
                            paramname, fk_type,
                            riinfo->agged_period_contained_by_oper,
                            "pg_catalog.range_agg", ANYMULTIRANGEOID);
-           appendStringInfo(&querybuf, "(x1.r)");
+           appendStringInfoString(&querybuf, "(x1.r)");
        }
 
        /* Prepare and save the plan */
@@ -838,12 +838,12 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
 
            /* Intersect the fk with the old pk range */
            initStringInfo(&intersectbuf);
-           appendStringInfoString(&intersectbuf, "(");
+           appendStringInfoChar(&intersectbuf, '(');
            ri_GenerateQual(&intersectbuf, "",
                            attname, fk_period_type,
                            riinfo->period_intersect_oper,
                            paramname, pk_period_type);
-           appendStringInfoString(&intersectbuf, ")");
+           appendStringInfoChar(&intersectbuf, ')');
 
            /* Find the remaining history */
            initStringInfo(&replacementsbuf);
index dc1f4bfbbcd0c473a4f94ac2a61dd275926baad0..8748225976a6fb72501f3331699300d26d5545b9 100644 (file)
@@ -1312,7 +1312,7 @@ process_global_sql_commands(PGconn *conn, const char *dumpdirpath, const char *o
    appendStringInfoString(&user_create, "CREATE ROLE ");
    /* should use fmtId here, but we don't know the encoding */
    appendStringInfoString(&user_create, PQuser(conn));
-   appendStringInfoString(&user_create, ";");
+   appendStringInfoChar(&user_create, ';');
 
    /* Process file till EOF and execute sql statements. */
    while (read_one_statement(&sqlstatement, pfile) != EOF)