Fixup various new-to-v18 usages of appendPQExpBuffer
authorDavid Rowley <drowley@postgresql.org>
Wed, 16 Apr 2025 23:37:55 +0000 (11:37 +1200)
committerDavid Rowley <drowley@postgresql.org>
Wed, 16 Apr 2025 23:37:55 +0000 (11:37 +1200)
Use appendPQExpBufferStr when there are no parameters and
appendPQExpBufferChar when the string length is 1.

Author: David Rowley <drowleyml@gmail.com>
Discussion: https://postgr.es/m/CAApHDvoARMvPeXTTC0HnpARBHn-WgVstc8XFCyMGOzvgu_1HvQ@mail.gmail.com

src/bin/pg_basebackup/pg_createsubscriber.c
src/bin/pg_dump/pg_dump.c
src/interfaces/libpq/fe-auth-oauth-curl.c
src/test/modules/test_escape/test_escape.c

index 42aaa428aed49d4cd5b8f5bc971927a66890cc82..b92a978a426718e7739705788abfc892c1cd881c 100644 (file)
@@ -1487,7 +1487,7 @@ start_standby_server(const struct CreateSubscriberOptions *opt, bool restricted_
    appendPQExpBuffer(pg_ctl_cmd, " -s -o \"-c sync_replication_slots=off\"");
 
    /* Prevent unintended slot invalidation */
-   appendPQExpBuffer(pg_ctl_cmd, " -o \"-c idle_replication_slot_timeout=0\"");
+   appendPQExpBufferStr(pg_ctl_cmd, " -o \"-c idle_replication_slot_timeout=0\"");
 
    if (restricted_access)
    {
@@ -1513,7 +1513,7 @@ start_standby_server(const struct CreateSubscriberOptions *opt, bool restricted_
 
    /* Suppress to start logical replication if requested */
    if (restrict_logical_worker)
-       appendPQExpBuffer(pg_ctl_cmd, " -o \"-c max_logical_replication_workers=0\"");
+       appendPQExpBufferStr(pg_ctl_cmd, " -o \"-c max_logical_replication_workers=0\"");
 
    pg_log_debug("pg_ctl command is: %s", pg_ctl_cmd->data);
    rc = system(pg_ctl_cmd->data);
index b158d96a831d6bc89b4876b09323a72221ee04a6..8ef9c6a021a8ef54f0e12017a3e0c08ae72b3435 100644 (file)
@@ -9751,7 +9751,7 @@ determineNotNullFlags(Archive *fout, PGresult *res, int r,
        {
            *invalidnotnulloids = createPQExpBuffer();
            appendPQExpBufferChar(*invalidnotnulloids, '{');
-           appendPQExpBuffer(*invalidnotnulloids, "%s", constroid);
+           appendPQExpBufferStr(*invalidnotnulloids, constroid);
        }
        else
            appendPQExpBuffer(*invalidnotnulloids, ",%s", constroid);
@@ -10978,7 +10978,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
         */
        if (rsinfo->nindAttNames == 0)
        {
-           appendPQExpBuffer(out, ",\n\t'attname', ");
+           appendPQExpBufferStr(out, ",\n\t'attname', ");
            appendStringLiteralAH(out, attname, fout);
        }
        else
index cd9c0323bb66fe749e7cb67cb1248812c251df96..ddd87dcf02d152b666cb6bb85cef0c145af165d6 100644 (file)
@@ -2859,7 +2859,7 @@ error_return:
        }
    }
 
-   appendPQExpBufferStr(&conn->errorMessage, "\n");
+   appendPQExpBufferChar(&conn->errorMessage, '\n');
 
    return PGRES_POLLING_FAILED;
 }
index f6b364489774f1729480678282ed5df0d16e29b4..0b4883cc7c88d15983cf0878a6a411cb63c2cf54 100644 (file)
@@ -96,8 +96,7 @@ escape_literal(PGconn *conn, PQExpBuffer target,
    escaped = PQescapeLiteral(conn, unescaped, unescaped_len);
    if (!escaped)
    {
-       appendPQExpBuffer(escape_err, "%s",
-                         PQerrorMessage(conn));
+       appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
        escape_err->data[escape_err->len - 1] = 0;
        escape_err->len--;
        return false;
@@ -120,8 +119,7 @@ escape_identifier(PGconn *conn, PQExpBuffer target,
    escaped = PQescapeIdentifier(conn, unescaped, unescaped_len);
    if (!escaped)
    {
-       appendPQExpBuffer(escape_err, "%s",
-                         PQerrorMessage(conn));
+       appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
        escape_err->data[escape_err->len - 1] = 0;
        escape_err->len--;
        return false;
@@ -153,8 +151,7 @@ escape_string_conn(PGconn *conn, PQExpBuffer target,
 
    if (error)
    {
-       appendPQExpBuffer(escape_err, "%s",
-                         PQerrorMessage(conn));
+       appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
        escape_err->data[escape_err->len - 1] = 0;
        escape_err->len--;
        return false;
@@ -514,7 +511,7 @@ test_psql_parse(pe_test_config *tc, PQExpBuffer testname,
                          "#\t\t %d: scan_result: %s prompt: %u, query_buf: ",
                          matches, scan_res_s(scan_result), prompt_status);
        escapify(details, query_buf->data, query_buf->len);
-       appendPQExpBuffer(details, "\n");
+       appendPQExpBufferChar(details, '\n');
 
        matches++;
    }
@@ -566,7 +563,7 @@ test_one_vector_escape(pe_test_config *tc, const pe_test_vector *tv, const pe_te
    }
 
    /* name to describe the test */
-   appendPQExpBuffer(testname, ">");
+   appendPQExpBufferChar(testname, '>');
    escapify(testname, tv->escape, tv->escape_len);
    appendPQExpBuffer(testname, "< - %s - %s",
                      tv->client_encoding, ef->name);
@@ -575,7 +572,7 @@ test_one_vector_escape(pe_test_config *tc, const pe_test_vector *tv, const pe_te
    appendPQExpBuffer(details, "#\t input: %zd bytes: ",
                      tv->escape_len);
    escapify(details, tv->escape, tv->escape_len);
-   appendPQExpBufferStr(details, "\n");
+   appendPQExpBufferChar(details, '\n');
    appendPQExpBuffer(details, "#\t encoding: %s\n",
                      tv->client_encoding);