Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8abc13a

Browse files
committed
Use appendStringInfoString and appendPQExpBufferStr where possible
This changes various places where appendPQExpBuffer was used in places where it was possible to use appendPQExpBufferStr, and likewise for appendStringInfo and appendStringInfoString. This is really just a stylistic improvement, but there are also small performance gains to be had from doing this. Discussion: http://postgr.es/m/CAKJS1f9P=M-3ULmPvr8iCno8yvfDViHibJjpriHU8+SXUgeZ=w@mail.gmail.com
1 parent 5683b34 commit 8abc13a

File tree

25 files changed

+195
-195
lines changed

25 files changed

+195
-195
lines changed

contrib/postgres_fdw/deparse.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
15311531
{
15321532
Assert(fpinfo->jointype == JOIN_INNER);
15331533
Assert(fpinfo->joinclauses == NIL);
1534-
appendStringInfo(buf, "%s", join_sql_o.data);
1534+
appendStringInfoString(buf, join_sql_o.data);
15351535
return;
15361536
}
15371537
}
@@ -1552,7 +1552,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
15521552
{
15531553
Assert(fpinfo->jointype == JOIN_INNER);
15541554
Assert(fpinfo->joinclauses == NIL);
1555-
appendStringInfo(buf, "%s", join_sql_i.data);
1555+
appendStringInfoString(buf, join_sql_i.data);
15561556
return;
15571557
}
15581558
}
@@ -1861,7 +1861,7 @@ deparseDirectUpdateSql(StringInfo buf, PlannerInfo *root,
18611861
{
18621862
List *ignore_conds = NIL;
18631863

1864-
appendStringInfo(buf, " FROM ");
1864+
appendStringInfoString(buf, " FROM ");
18651865
deparseFromExprForRel(buf, root, foreignrel, true, rtindex,
18661866
&ignore_conds, params_list);
18671867
remote_conds = list_concat(remote_conds, ignore_conds);
@@ -1944,7 +1944,7 @@ deparseDirectDeleteSql(StringInfo buf, PlannerInfo *root,
19441944
{
19451945
List *ignore_conds = NIL;
19461946

1947-
appendStringInfo(buf, " USING ");
1947+
appendStringInfoString(buf, " USING ");
19481948
deparseFromExprForRel(buf, root, foreignrel, true, rtindex,
19491949
&ignore_conds, params_list);
19501950
remote_conds = list_concat(remote_conds, ignore_conds);

contrib/sepgsql/database.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
6363
* check db_database:{getattr} permission
6464
*/
6565
initStringInfo(&audit_name);
66-
appendStringInfo(&audit_name, "%s", quote_identifier(dtemplate));
66+
appendStringInfoString(&audit_name, quote_identifier(dtemplate));
6767
sepgsql_avc_check_perms_label(tcontext,
6868
SEPG_CLASS_DB_DATABASE,
6969
SEPG_DB_DATABASE__GETATTR,
@@ -101,8 +101,8 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
101101
* check db_database:{create} permission
102102
*/
103103
resetStringInfo(&audit_name);
104-
appendStringInfo(&audit_name, "%s",
105-
quote_identifier(NameStr(datForm->datname)));
104+
appendStringInfoString(&audit_name,
105+
quote_identifier(NameStr(datForm->datname)));
106106
sepgsql_avc_check_perms_label(ncontext,
107107
SEPG_CLASS_DB_DATABASE,
108108
SEPG_DB_DATABASE__CREATE,

contrib/sepgsql/label.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ quote_object_name(const char *src1, const char *src2,
676676
if (src1)
677677
{
678678
temp = quote_identifier(src1);
679-
appendStringInfo(&result, "%s", temp);
679+
appendStringInfoString(&result, temp);
680680
if (src1 != temp)
681681
pfree((void *) temp);
682682
}

contrib/sepgsql/selinux.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ sepgsql_audit_log(bool denied,
702702
appendStringInfo(&buf, " %s", av_name);
703703
}
704704
}
705-
appendStringInfo(&buf, " }");
705+
appendStringInfoString(&buf, " }");
706706

707707
/*
708708
* Call external audit module, if loaded

contrib/test_decoding/test_decoding.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ pg_decode_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
518518
|| change->data.truncate.cascade)
519519
{
520520
if (change->data.truncate.restart_seqs)
521-
appendStringInfo(ctx->out, " restart_seqs");
521+
appendStringInfoString(ctx->out, " restart_seqs");
522522
if (change->data.truncate.cascade)
523-
appendStringInfo(ctx->out, " cascade");
523+
appendStringInfoString(ctx->out, " cascade");
524524
}
525525
else
526526
appendStringInfoString(ctx->out, " (no-flags)");

src/backend/access/rmgrdesc/heapdesc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
8686
int i;
8787

8888
if (xlrec->flags & XLH_TRUNCATE_CASCADE)
89-
appendStringInfo(buf, "cascade ");
89+
appendStringInfoString(buf, "cascade ");
9090
if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
91-
appendStringInfo(buf, "restart_seqs ");
91+
appendStringInfoString(buf, "restart_seqs ");
9292
appendStringInfo(buf, "nrelids %u relids", xlrec->nrelids);
9393
for (i = 0; i < xlrec->nrelids; i++)
9494
appendStringInfo(buf, " %u", xlrec->relids[i]);

src/backend/commands/explain.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ ExplainPrintJIT(ExplainState *es, int jit_flags,
822822
if (for_workers)
823823
appendStringInfo(es->str, "JIT for worker %u:\n", worker_num);
824824
else
825-
appendStringInfo(es->str, "JIT:\n");
825+
appendStringInfoString(es->str, "JIT:\n");
826826
es->indent += 1;
827827

828828
ExplainPropertyInteger("Functions", NULL, ji->created_functions, es);

src/backend/utils/adt/ruleutils.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
17231723
{
17241724
case PARTITION_STRATEGY_HASH:
17251725
if (!attrsOnly)
1726-
appendStringInfo(&buf, "HASH");
1726+
appendStringInfoString(&buf, "HASH");
17271727
break;
17281728
case PARTITION_STRATEGY_LIST:
17291729
if (!attrsOnly)

src/bin/pg_basebackup/streamutil.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -500,19 +500,19 @@ CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin,
500500
/* Build query */
501501
appendPQExpBuffer(query, "CREATE_REPLICATION_SLOT \"%s\"", slot_name);
502502
if (is_temporary)
503-
appendPQExpBuffer(query, " TEMPORARY");
503+
appendPQExpBufferStr(query, " TEMPORARY");
504504
if (is_physical)
505505
{
506-
appendPQExpBuffer(query, " PHYSICAL");
506+
appendPQExpBufferStr(query, " PHYSICAL");
507507
if (reserve_wal)
508-
appendPQExpBuffer(query, " RESERVE_WAL");
508+
appendPQExpBufferStr(query, " RESERVE_WAL");
509509
}
510510
else
511511
{
512512
appendPQExpBuffer(query, " LOGICAL \"%s\"", plugin);
513513
if (PQserverVersion(conn) >= 100000)
514514
/* pg_recvlogical doesn't use an exported snapshot, so suppress */
515-
appendPQExpBuffer(query, " NOEXPORT_SNAPSHOT");
515+
appendPQExpBufferStr(query, " NOEXPORT_SNAPSHOT");
516516
}
517517

518518
res = PQexec(conn, query->data);

src/bin/pg_ctl/pg_ctl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1481,14 +1481,14 @@ pgwin32_CommandLine(bool registration)
14811481
appendPQExpBuffer(cmdLine, " -e \"%s\"", event_source);
14821482

14831483
if (registration && do_wait)
1484-
appendPQExpBuffer(cmdLine, " -w");
1484+
appendPQExpBufferStr(cmdLine, " -w");
14851485

14861486
/* Don't propagate a value from an environment variable. */
14871487
if (registration && wait_seconds_arg && wait_seconds != DEFAULT_WAIT)
14881488
appendPQExpBuffer(cmdLine, " -t %d", wait_seconds);
14891489

14901490
if (registration && silent_mode)
1491-
appendPQExpBuffer(cmdLine, " -s");
1491+
appendPQExpBufferStr(cmdLine, " -s");
14921492

14931493
if (post_opts)
14941494
{

src/bin/pg_dump/dumputils.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ buildDefaultACLCommands(const char *type, const char *nspname,
425425

426426
if (strlen(initacls) != 0 || strlen(initracls) != 0)
427427
{
428-
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
428+
appendPQExpBufferStr(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
429429
if (!buildACLCommands("", NULL, NULL, type,
430430
initacls, initracls, owner,
431431
prefix->data, remoteVersion, sql))
432432
{
433433
destroyPQExpBuffer(prefix);
434434
return false;
435435
}
436-
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
436+
appendPQExpBufferStr(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
437437
}
438438

439439
if (!buildACLCommands("", NULL, NULL, type,

src/bin/pg_dump/pg_backup_archiver.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ RestoreArchive(Archive *AHX)
554554
*/
555555
if (strncmp(dropStmt, "ALTER TABLE", 11) == 0)
556556
{
557-
appendPQExpBuffer(ftStmt,
558-
"ALTER TABLE IF EXISTS");
557+
appendPQExpBufferStr(ftStmt,
558+
"ALTER TABLE IF EXISTS");
559559
dropStmt = dropStmt + 11;
560560
}
561561

@@ -4870,7 +4870,7 @@ CloneArchive(ArchiveHandle *AH)
48704870
* any data to/from the database.
48714871
*/
48724872
initPQExpBuffer(&connstr);
4873-
appendPQExpBuffer(&connstr, "dbname=");
4873+
appendPQExpBufferStr(&connstr, "dbname=");
48744874
appendConnStrVal(&connstr, PQdb(AH->connection));
48754875
pghost = PQhost(AH->connection);
48764876
pgport = PQport(AH->connection);

src/bin/pg_dump/pg_backup_db.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
149149
}
150150

151151
initPQExpBuffer(&connstr);
152-
appendPQExpBuffer(&connstr, "dbname=");
152+
appendPQExpBufferStr(&connstr, "dbname=");
153153
appendConnStrVal(&connstr, newdb);
154154

155155
do

0 commit comments

Comments
 (0)