1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-20 00:42:27 +03:00

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
This commit is contained in:
David Rowley 2025-04-17 11:37:55 +12:00
parent f3281f9f93
commit 3fae25cbb3
4 changed files with 11 additions and 14 deletions

View 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\""); appendPQExpBuffer(pg_ctl_cmd, " -s -o \"-c sync_replication_slots=off\"");
/* Prevent unintended slot invalidation */ /* 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) if (restricted_access)
{ {
@ -1513,7 +1513,7 @@ start_standby_server(const struct CreateSubscriberOptions *opt, bool restricted_
/* Suppress to start logical replication if requested */ /* Suppress to start logical replication if requested */
if (restrict_logical_worker) 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); pg_log_debug("pg_ctl command is: %s", pg_ctl_cmd->data);
rc = system(pg_ctl_cmd->data); rc = system(pg_ctl_cmd->data);

View File

@ -9751,7 +9751,7 @@ determineNotNullFlags(Archive *fout, PGresult *res, int r,
{ {
*invalidnotnulloids = createPQExpBuffer(); *invalidnotnulloids = createPQExpBuffer();
appendPQExpBufferChar(*invalidnotnulloids, '{'); appendPQExpBufferChar(*invalidnotnulloids, '{');
appendPQExpBuffer(*invalidnotnulloids, "%s", constroid); appendPQExpBufferStr(*invalidnotnulloids, constroid);
} }
else else
appendPQExpBuffer(*invalidnotnulloids, ",%s", constroid); appendPQExpBuffer(*invalidnotnulloids, ",%s", constroid);
@ -10978,7 +10978,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
*/ */
if (rsinfo->nindAttNames == 0) if (rsinfo->nindAttNames == 0)
{ {
appendPQExpBuffer(out, ",\n\t'attname', "); appendPQExpBufferStr(out, ",\n\t'attname', ");
appendStringLiteralAH(out, attname, fout); appendStringLiteralAH(out, attname, fout);
} }
else else

View File

@ -2859,7 +2859,7 @@ error_return:
} }
} }
appendPQExpBufferStr(&conn->errorMessage, "\n"); appendPQExpBufferChar(&conn->errorMessage, '\n');
return PGRES_POLLING_FAILED; return PGRES_POLLING_FAILED;
} }

View File

@ -96,8 +96,7 @@ escape_literal(PGconn *conn, PQExpBuffer target,
escaped = PQescapeLiteral(conn, unescaped, unescaped_len); escaped = PQescapeLiteral(conn, unescaped, unescaped_len);
if (!escaped) if (!escaped)
{ {
appendPQExpBuffer(escape_err, "%s", appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
PQerrorMessage(conn));
escape_err->data[escape_err->len - 1] = 0; escape_err->data[escape_err->len - 1] = 0;
escape_err->len--; escape_err->len--;
return false; return false;
@ -120,8 +119,7 @@ escape_identifier(PGconn *conn, PQExpBuffer target,
escaped = PQescapeIdentifier(conn, unescaped, unescaped_len); escaped = PQescapeIdentifier(conn, unescaped, unescaped_len);
if (!escaped) if (!escaped)
{ {
appendPQExpBuffer(escape_err, "%s", appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
PQerrorMessage(conn));
escape_err->data[escape_err->len - 1] = 0; escape_err->data[escape_err->len - 1] = 0;
escape_err->len--; escape_err->len--;
return false; return false;
@ -153,8 +151,7 @@ escape_string_conn(PGconn *conn, PQExpBuffer target,
if (error) if (error)
{ {
appendPQExpBuffer(escape_err, "%s", appendPQExpBufferStr(escape_err, PQerrorMessage(conn));
PQerrorMessage(conn));
escape_err->data[escape_err->len - 1] = 0; escape_err->data[escape_err->len - 1] = 0;
escape_err->len--; escape_err->len--;
return false; 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: ", "#\t\t %d: scan_result: %s prompt: %u, query_buf: ",
matches, scan_res_s(scan_result), prompt_status); matches, scan_res_s(scan_result), prompt_status);
escapify(details, query_buf->data, query_buf->len); escapify(details, query_buf->data, query_buf->len);
appendPQExpBuffer(details, "\n"); appendPQExpBufferChar(details, '\n');
matches++; 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 */ /* name to describe the test */
appendPQExpBuffer(testname, ">"); appendPQExpBufferChar(testname, '>');
escapify(testname, tv->escape, tv->escape_len); escapify(testname, tv->escape, tv->escape_len);
appendPQExpBuffer(testname, "< - %s - %s", appendPQExpBuffer(testname, "< - %s - %s",
tv->client_encoding, ef->name); 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: ", appendPQExpBuffer(details, "#\t input: %zd bytes: ",
tv->escape_len); tv->escape_len);
escapify(details, tv->escape, tv->escape_len); escapify(details, tv->escape, tv->escape_len);
appendPQExpBufferStr(details, "\n"); appendPQExpBufferChar(details, '\n');
appendPQExpBuffer(details, "#\t encoding: %s\n", appendPQExpBuffer(details, "#\t encoding: %s\n",
tv->client_encoding); tv->client_encoding);