Skip to content

Commit 3fae25c

Browse files
committed
Fixup various new-to-v18 usages of appendPQExpBuffer
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
1 parent f3281f9 commit 3fae25c

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

src/bin/pg_basebackup/pg_createsubscriber.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ start_standby_server(const struct CreateSubscriberOptions *opt, bool restricted_
14871487
appendPQExpBuffer(pg_ctl_cmd, " -s -o \"-c sync_replication_slots=off\"");
14881488

14891489
/* Prevent unintended slot invalidation */
1490-
appendPQExpBuffer(pg_ctl_cmd, " -o \"-c idle_replication_slot_timeout=0\"");
1490+
appendPQExpBufferStr(pg_ctl_cmd, " -o \"-c idle_replication_slot_timeout=0\"");
14911491

14921492
if (restricted_access)
14931493
{
@@ -1513,7 +1513,7 @@ start_standby_server(const struct CreateSubscriberOptions *opt, bool restricted_
15131513

15141514
/* Suppress to start logical replication if requested */
15151515
if (restrict_logical_worker)
1516-
appendPQExpBuffer(pg_ctl_cmd, " -o \"-c max_logical_replication_workers=0\"");
1516+
appendPQExpBufferStr(pg_ctl_cmd, " -o \"-c max_logical_replication_workers=0\"");
15171517

15181518
pg_log_debug("pg_ctl command is: %s", pg_ctl_cmd->data);
15191519
rc = system(pg_ctl_cmd->data);

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9751,7 +9751,7 @@ determineNotNullFlags(Archive *fout, PGresult *res, int r,
97519751
{
97529752
*invalidnotnulloids = createPQExpBuffer();
97539753
appendPQExpBufferChar(*invalidnotnulloids, '{');
9754-
appendPQExpBuffer(*invalidnotnulloids, "%s", constroid);
9754+
appendPQExpBufferStr(*invalidnotnulloids, constroid);
97559755
}
97569756
else
97579757
appendPQExpBuffer(*invalidnotnulloids, ",%s", constroid);
@@ -10978,7 +10978,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
1097810978
*/
1097910979
if (rsinfo->nindAttNames == 0)
1098010980
{
10981-
appendPQExpBuffer(out, ",\n\t'attname', ");
10981+
appendPQExpBufferStr(out, ",\n\t'attname', ");
1098210982
appendStringLiteralAH(out, attname, fout);
1098310983
}
1098410984
else

src/interfaces/libpq/fe-auth-oauth-curl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2859,7 +2859,7 @@ pg_fe_run_oauth_flow_impl(PGconn *conn)
28592859
}
28602860
}
28612861

2862-
appendPQExpBufferStr(&conn->errorMessage, "\n");
2862+
appendPQExpBufferChar(&conn->errorMessage, '\n');
28632863

28642864
return PGRES_POLLING_FAILED;
28652865
}

src/test/modules/test_escape/test_escape.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ escape_literal(PGconn *conn, PQExpBuffer target,
9696
escaped = PQescapeLiteral(conn, unescaped, unescaped_len);
9797
if (!escaped)
9898
{
99-
appendPQExpBuffer(escape_err, "%s",
100-
PQerrorMessage(conn));
99+
appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
101100
escape_err->data[escape_err->len - 1] = 0;
102101
escape_err->len--;
103102
return false;
@@ -120,8 +119,7 @@ escape_identifier(PGconn *conn, PQExpBuffer target,
120119
escaped = PQescapeIdentifier(conn, unescaped, unescaped_len);
121120
if (!escaped)
122121
{
123-
appendPQExpBuffer(escape_err, "%s",
124-
PQerrorMessage(conn));
122+
appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
125123
escape_err->data[escape_err->len - 1] = 0;
126124
escape_err->len--;
127125
return false;
@@ -153,8 +151,7 @@ escape_string_conn(PGconn *conn, PQExpBuffer target,
153151

154152
if (error)
155153
{
156-
appendPQExpBuffer(escape_err, "%s",
157-
PQerrorMessage(conn));
154+
appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
158155
escape_err->data[escape_err->len - 1] = 0;
159156
escape_err->len--;
160157
return false;
@@ -514,7 +511,7 @@ test_psql_parse(pe_test_config *tc, PQExpBuffer testname,
514511
"#\t\t %d: scan_result: %s prompt: %u, query_buf: ",
515512
matches, scan_res_s(scan_result), prompt_status);
516513
escapify(details, query_buf->data, query_buf->len);
517-
appendPQExpBuffer(details, "\n");
514+
appendPQExpBufferChar(details, '\n');
518515

519516
matches++;
520517
}
@@ -566,7 +563,7 @@ test_one_vector_escape(pe_test_config *tc, const pe_test_vector *tv, const pe_te
566563
}
567564

568565
/* name to describe the test */
569-
appendPQExpBuffer(testname, ">");
566+
appendPQExpBufferChar(testname, '>');
570567
escapify(testname, tv->escape, tv->escape_len);
571568
appendPQExpBuffer(testname, "< - %s - %s",
572569
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
575572
appendPQExpBuffer(details, "#\t input: %zd bytes: ",
576573
tv->escape_len);
577574
escapify(details, tv->escape, tv->escape_len);
578-
appendPQExpBufferStr(details, "\n");
575+
appendPQExpBufferChar(details, '\n');
579576
appendPQExpBuffer(details, "#\t encoding: %s\n",
580577
tv->client_encoding);
581578

0 commit comments

Comments
 (0)