Skip to content

Commit 77d0570

Browse files
committed
Fix up some misusage of appendStringInfo() and friends
Change to appendStringInfoChar() or appendStringInfoString() where those can be used. Author: David Rowley <david.rowley@2ndquadrant.com> Reviewed-by: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
1 parent 4d4c891 commit 77d0570

File tree

13 files changed

+55
-56
lines changed

13 files changed

+55
-56
lines changed

contrib/postgres_fdw/deparse.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel,
973973
/* Append HAVING clause */
974974
if (remote_conds)
975975
{
976-
appendStringInfo(buf, " HAVING ");
976+
appendStringInfoString(buf, " HAVING ");
977977
appendConditions(remote_conds, &context);
978978
}
979979
}
@@ -1076,7 +1076,7 @@ deparseFromExpr(List *quals, deparse_expr_cxt *context)
10761076
/* Construct WHERE clause */
10771077
if (quals != NIL)
10781078
{
1079-
appendStringInfo(buf, " WHERE ");
1079+
appendStringInfoString(buf, " WHERE ");
10801080
appendConditions(quals, context);
10811081
}
10821082
}
@@ -1447,15 +1447,15 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
14471447
context.root = root;
14481448
context.params_list = params_list;
14491449

1450-
appendStringInfo(buf, "(");
1450+
appendStringInfoChar(buf, '(');
14511451
appendConditions(fpinfo->joinclauses, &context);
1452-
appendStringInfo(buf, ")");
1452+
appendStringInfoChar(buf, ')');
14531453
}
14541454
else
14551455
appendStringInfoString(buf, "(TRUE)");
14561456

14571457
/* End the FROM clause entry. */
1458-
appendStringInfo(buf, ")");
1458+
appendStringInfoChar(buf, ')');
14591459
}
14601460
else
14611461
{
@@ -1702,7 +1702,7 @@ deparseDirectUpdateSql(StringInfo buf, PlannerInfo *root,
17021702

17031703
if (remote_conds)
17041704
{
1705-
appendStringInfo(buf, " WHERE ");
1705+
appendStringInfoString(buf, " WHERE ");
17061706
appendConditions(remote_conds, &context);
17071707
}
17081708

@@ -1762,7 +1762,7 @@ deparseDirectDeleteSql(StringInfo buf, PlannerInfo *root,
17621762

17631763
if (remote_conds)
17641764
{
1765-
appendStringInfo(buf, " WHERE ");
1765+
appendStringInfoString(buf, " WHERE ");
17661766
appendConditions(remote_conds, &context);
17671767
}
17681768

@@ -1978,17 +1978,17 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, PlannerInfo *root,
19781978
{
19791979
appendStringInfoString(buf, "CASE WHEN (");
19801980
ADD_REL_QUALIFIER(buf, varno);
1981-
appendStringInfo(buf, "*)::text IS NOT NULL THEN ");
1981+
appendStringInfoString(buf, "*)::text IS NOT NULL THEN ");
19821982
}
19831983

19841984
appendStringInfoString(buf, "ROW(");
19851985
deparseTargetList(buf, root, varno, rel, false, attrs_used, qualify_col,
19861986
&retrieved_attrs);
1987-
appendStringInfoString(buf, ")");
1987+
appendStringInfoChar(buf, ')');
19881988

19891989
/* Complete the CASE WHEN statement started above. */
19901990
if (qualify_col)
1991-
appendStringInfo(buf, " END");
1991+
appendStringInfoString(buf, " END");
19921992

19931993
heap_close(rel, NoLock);
19941994
bms_free(attrs_used);
@@ -2759,7 +2759,7 @@ deparseAggref(Aggref *node, deparse_expr_cxt *context)
27592759
appendStringInfoChar(buf, '(');
27602760

27612761
/* Add DISTINCT */
2762-
appendStringInfo(buf, "%s", (node->aggdistinct != NIL) ? "DISTINCT " : "");
2762+
appendStringInfoString(buf, (node->aggdistinct != NIL) ? "DISTINCT " : "");
27632763

27642764
if (AGGKIND_IS_ORDERED_SET(node->aggkind))
27652765
{
@@ -2944,7 +2944,7 @@ appendGroupByClause(List *tlist, deparse_expr_cxt *context)
29442944
if (!query->groupClause)
29452945
return;
29462946

2947-
appendStringInfo(buf, " GROUP BY ");
2947+
appendStringInfoString(buf, " GROUP BY ");
29482948

29492949
/*
29502950
* Queries with grouping sets are not pushed down, so we don't expect
@@ -2981,7 +2981,7 @@ appendOrderByClause(List *pathkeys, deparse_expr_cxt *context)
29812981
/* Make sure any constants in the exprs are printed portably */
29822982
nestlevel = set_transmission_modes();
29832983

2984-
appendStringInfo(buf, " ORDER BY");
2984+
appendStringInfoString(buf, " ORDER BY");
29852985
foreach(lcell, pathkeys)
29862986
{
29872987
PathKey *pathkey = lfirst(lcell);
@@ -3035,7 +3035,7 @@ appendFunctionName(Oid funcid, deparse_expr_cxt *context)
30353035

30363036
/* Always print the function name */
30373037
proname = NameStr(procform->proname);
3038-
appendStringInfo(buf, "%s", quote_identifier(proname));
3038+
appendStringInfoString(buf, quote_identifier(proname));
30393039

30403040
ReleaseSysCache(proctup);
30413041
}
@@ -3070,9 +3070,9 @@ deparseSortGroupClause(Index ref, List *tlist, deparse_expr_cxt *context)
30703070
else
30713071
{
30723072
/* Always parenthesize the expression. */
3073-
appendStringInfoString(buf, "(");
3073+
appendStringInfoChar(buf, '(');
30743074
deparseExpr(expr, context);
3075-
appendStringInfoString(buf, ")");
3075+
appendStringInfoChar(buf, ')');
30763076
}
30773077

30783078
return (Node *) expr;

src/backend/commands/subscriptioncmds.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,9 @@ fetch_table_list(WalReceiverConn *wrconn, List *publications)
11171117
Assert(list_length(publications) > 0);
11181118

11191119
initStringInfo(&cmd);
1120-
appendStringInfo(&cmd, "SELECT DISTINCT t.schemaname, t.tablename\n"
1121-
" FROM pg_catalog.pg_publication_tables t\n"
1122-
" WHERE t.pubname IN (");
1120+
appendStringInfoString(&cmd, "SELECT DISTINCT t.schemaname, t.tablename\n"
1121+
" FROM pg_catalog.pg_publication_tables t\n"
1122+
" WHERE t.pubname IN (");
11231123
first = true;
11241124
foreach(lc, publications)
11251125
{
@@ -1130,9 +1130,9 @@ fetch_table_list(WalReceiverConn *wrconn, List *publications)
11301130
else
11311131
appendStringInfoString(&cmd, ", ");
11321132

1133-
appendStringInfo(&cmd, "%s", quote_literal_cstr(pubname));
1133+
appendStringInfoString(&cmd, quote_literal_cstr(pubname));
11341134
}
1135-
appendStringInfoString(&cmd, ")");
1135+
appendStringInfoChar(&cmd, ')');
11361136

11371137
res = walrcv_exec(wrconn, cmd.data, 2, tableRow);
11381138
pfree(cmd.data);

src/backend/nodes/outfuncs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void outChar(StringInfo str, char c);
8383

8484
/* Write a character-string (possibly NULL) field */
8585
#define WRITE_STRING_FIELD(fldname) \
86-
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
86+
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
8787
outToken(str, node->fldname))
8888

8989
/* Write a parse location field (actually same as INT case) */
@@ -92,12 +92,12 @@ static void outChar(StringInfo str, char c);
9292

9393
/* Write a Node field */
9494
#define WRITE_NODE_FIELD(fldname) \
95-
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
95+
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
9696
outNode(str, node->fldname))
9797

9898
/* Write a bitmapset field */
9999
#define WRITE_BITMAPSET_FIELD(fldname) \
100-
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
100+
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
101101
outBitmapset(str, node->fldname))
102102

103103

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ libpqrcv_startstreaming(WalReceiverConn *conn,
355355
options->slotname);
356356

357357
if (options->logical)
358-
appendStringInfo(&cmd, " LOGICAL");
358+
appendStringInfoString(&cmd, " LOGICAL");
359359

360360
appendStringInfo(&cmd, " %X/%X",
361361
(uint32) (options->startpoint >> 32),
@@ -774,21 +774,21 @@ libpqrcv_create_slot(WalReceiverConn *conn, const char *slotname,
774774
appendStringInfo(&cmd, "CREATE_REPLICATION_SLOT \"%s\"", slotname);
775775

776776
if (temporary)
777-
appendStringInfo(&cmd, " TEMPORARY");
777+
appendStringInfoString(&cmd, " TEMPORARY");
778778

779779
if (conn->logical)
780780
{
781-
appendStringInfo(&cmd, " LOGICAL pgoutput");
781+
appendStringInfoString(&cmd, " LOGICAL pgoutput");
782782
switch (snapshot_action)
783783
{
784784
case CRS_EXPORT_SNAPSHOT:
785-
appendStringInfo(&cmd, " EXPORT_SNAPSHOT");
785+
appendStringInfoString(&cmd, " EXPORT_SNAPSHOT");
786786
break;
787787
case CRS_NOEXPORT_SNAPSHOT:
788-
appendStringInfo(&cmd, " NOEXPORT_SNAPSHOT");
788+
appendStringInfoString(&cmd, " NOEXPORT_SNAPSHOT");
789789
break;
790790
case CRS_USE_SNAPSHOT:
791-
appendStringInfo(&cmd, " USE_SNAPSHOT");
791+
appendStringInfoString(&cmd, " USE_SNAPSHOT");
792792
break;
793793
}
794794
}

src/backend/utils/adt/ruleutils.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,19 +1656,19 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
16561656
{
16571657
case PARTITION_STRATEGY_LIST:
16581658
if (!attrsOnly)
1659-
appendStringInfo(&buf, "LIST");
1659+
appendStringInfoString(&buf, "LIST");
16601660
break;
16611661
case PARTITION_STRATEGY_RANGE:
16621662
if (!attrsOnly)
1663-
appendStringInfo(&buf, "RANGE");
1663+
appendStringInfoString(&buf, "RANGE");
16641664
break;
16651665
default:
16661666
elog(ERROR, "unexpected partition strategy: %d",
16671667
(int) form->partstrat);
16681668
}
16691669

16701670
if (!attrsOnly)
1671-
appendStringInfo(&buf, " (");
1671+
appendStringInfoString(&buf, " (");
16721672
sep = "";
16731673
for (keyno = 0; keyno < form->partnatts; keyno++)
16741674
{
@@ -5635,10 +5635,10 @@ get_rule_sortgroupclause(Index ref, List *tlist, bool force_colno,
56355635
||IsA(expr, WindowFunc));
56365636

56375637
if (need_paren)
5638-
appendStringInfoString(context->buf, "(");
5638+
appendStringInfoChar(context->buf, '(');
56395639
get_rule_expr(expr, context, true);
56405640
if (need_paren)
5641-
appendStringInfoString(context->buf, ")");
5641+
appendStringInfoChar(context->buf, ')');
56425642
}
56435643

56445644
return expr;
@@ -5665,7 +5665,7 @@ get_rule_groupingset(GroupingSet *gset, List *targetlist,
56655665
case GROUPING_SET_SIMPLE:
56665666
{
56675667
if (!omit_parens || list_length(gset->content) != 1)
5668-
appendStringInfoString(buf, "(");
5668+
appendStringInfoChar(buf, '(');
56695669

56705670
foreach(l, gset->content)
56715671
{
@@ -5678,7 +5678,7 @@ get_rule_groupingset(GroupingSet *gset, List *targetlist,
56785678
}
56795679

56805680
if (!omit_parens || list_length(gset->content) != 1)
5681-
appendStringInfoString(buf, ")");
5681+
appendStringInfoChar(buf, ')');
56825682
}
56835683
return;
56845684

@@ -5701,7 +5701,7 @@ get_rule_groupingset(GroupingSet *gset, List *targetlist,
57015701
sep = ", ";
57025702
}
57035703

5704-
appendStringInfoString(buf, ")");
5704+
appendStringInfoChar(buf, ')');
57055705
}
57065706

57075707
/*
@@ -8713,7 +8713,7 @@ get_rule_expr(Node *node, deparse_context *context,
87138713
sep = ", ";
87148714
}
87158715

8716-
appendStringInfoString(buf, ")");
8716+
appendStringInfoChar(buf, ')');
87178717
break;
87188718

87198719
case PARTITION_STRATEGY_RANGE:
@@ -10941,7 +10941,7 @@ get_range_partbound_string(List *bound_datums)
1094110941
}
1094210942
sep = ", ";
1094310943
}
10944-
appendStringInfoString(buf, ")");
10944+
appendStringInfoChar(buf, ')');
1094510945

1094610946
return buf->data;
1094710947
}

src/backend/utils/adt/xml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,8 +3458,8 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod)
34583458
case BPCHAROID:
34593459
case VARCHAROID:
34603460
case TEXTOID:
3461-
appendStringInfo(&result,
3462-
" <xsd:restriction base=\"xsd:string\">\n");
3461+
appendStringInfoString(&result,
3462+
" <xsd:restriction base=\"xsd:string\">\n");
34633463
if (typmod != -1)
34643464
appendStringInfo(&result,
34653465
" <xsd:maxLength value=\"%d\"/>\n",

src/backend/utils/mmgr/freepage.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ FreePageManagerDump(FreePageManager *fpm)
455455
recycle = relptr_access(base, fpm->btree_recycle);
456456
if (recycle != NULL)
457457
{
458-
appendStringInfo(&buf, "btree recycle:");
458+
appendStringInfoString(&buf, "btree recycle:");
459459
FreePageManagerDumpSpans(fpm, recycle, 1, &buf);
460460
}
461461

@@ -468,7 +468,7 @@ FreePageManagerDump(FreePageManager *fpm)
468468
continue;
469469
if (!dumped_any_freelist)
470470
{
471-
appendStringInfo(&buf, "freelists:\n");
471+
appendStringInfoString(&buf, "freelists:\n");
472472
dumped_any_freelist = true;
473473
}
474474
appendStringInfo(&buf, " %zu:", f + 1);
@@ -1275,7 +1275,7 @@ FreePageManagerDumpBtree(FreePageManager *fpm, FreePageBtree *btp,
12751275
btp->u.leaf_key[index].first_page,
12761276
btp->u.leaf_key[index].npages);
12771277
}
1278-
appendStringInfo(buf, "\n");
1278+
appendStringInfoChar(buf, '\n');
12791279

12801280
if (btp->hdr.magic == FREE_PAGE_INTERNAL_MAGIC)
12811281
{
@@ -1308,7 +1308,7 @@ FreePageManagerDumpSpans(FreePageManager *fpm, FreePageSpanLeader *span,
13081308
span = relptr_access(base, span->next);
13091309
}
13101310

1311-
appendStringInfo(buf, "\n");
1311+
appendStringInfoChar(buf, '\n');
13121312
}
13131313

13141314
/*

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15424,7 +15424,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1542415424

1542515425
if (tbinfo->ispartition && !dopt->binary_upgrade)
1542615426
{
15427-
appendPQExpBufferStr(q, "\n");
15427+
appendPQExpBufferChar(q, '\n');
1542815428
appendPQExpBufferStr(q, tbinfo->partbound);
1542915429
}
1543015430

@@ -17127,8 +17127,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
1712717127

1712817128
appendPQExpBuffer(delcmd, "CREATE OR REPLACE VIEW %s.",
1712917129
fmtId(tbinfo->dobj.namespace->dobj.name));
17130-
appendPQExpBuffer(delcmd, "%s",
17131-
fmtId(tbinfo->dobj.name));
17130+
appendPQExpBufferStr(delcmd, fmtId(tbinfo->dobj.name));
1713217131
result = createDummyViewAsClause(fout, tbinfo);
1713317132
appendPQExpBuffer(delcmd, " AS\n%s;\n", result->data);
1713417133
destroyPQExpBuffer(result);

src/bin/pg_dump/pg_dumpall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ dumpDatabaseConfig(PGconn *conn, const char *dbname)
15751575
appendStringLiteralConn(buf, dbname, conn);
15761576

15771577
if (server_version >= 90000)
1578-
appendPQExpBuffer(buf, ")");
1578+
appendPQExpBufferChar(buf, ')');
15791579

15801580
res = executeQuery(conn, buf->data);
15811581
if (PQntuples(res) == 1 &&

src/bin/psql/command.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4676,7 +4676,7 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
46764676
psql_error("could not parse reloptions array\n");
46774677
result = false;
46784678
}
4679-
appendPQExpBufferStr(buf, ")");
4679+
appendPQExpBufferChar(buf, ')');
46804680
}
46814681

46824682
/* View definition from pg_get_viewdef (a SELECT query) */
@@ -4862,7 +4862,7 @@ minimal_error_message(PGresult *res)
48624862
appendPQExpBufferStr(msg, fld);
48634863
else
48644864
appendPQExpBufferStr(msg, "(not available)");
4865-
appendPQExpBufferStr(msg, "\n");
4865+
appendPQExpBufferChar(msg, '\n');
48664866

48674867
psql_error("%s", msg->data);
48684868

src/bin/psql/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3177,7 +3177,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
31773177
if (strcmp(PQgetvalue(res, i, 7), "") != 0)
31783178
{
31793179
if (buf.len > 0)
3180-
appendPQExpBufferStr(&buf, "\n");
3180+
appendPQExpBufferChar(&buf, '\n');
31813181
appendPQExpBufferStr(&buf, _("Password valid until "));
31823182
appendPQExpBufferStr(&buf, PQgetvalue(res, i, 7));
31833183
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy