aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-04-10 11:53:32 +1200
committerDavid Rowley <drowley@postgresql.org>2024-04-10 11:53:32 +1200
commit8461424fd717877ead0706984ef9b6440b2a97ad (patch)
treeac5ee13afb549d4f44830d8ac6d08d846e1c1b74 /src/backend/utils/adt/ruleutils.c
parentff9f72c68f678ded340b431c3e280fe56644a3e7 (diff)
downloadpostgresql-8461424fd717877ead0706984ef9b6440b2a97ad.tar.gz
postgresql-8461424fd717877ead0706984ef9b6440b2a97ad.zip
Fixup various StringInfo function usages
This adjusts various appendStringInfo* function calls to use a more appropriate and efficient function with the same behavior. For example, use appendStringInfoChar() when appending a single character rather than appendStringInfo() and appendStringInfoString() when no formatting is required rather than using appendStringInfo(). All adjustments made here are in code that's new to v17, so it makes sense to fix these now rather than wait a few years and make backpatching harder. Discussion: https://postgr.es/m/CAApHDvojY2UvMiO+9_55ArTj10P1LBNJyyoGB+C65BLDNT0GsQ@mail.gmail.com Reviewed-by: Nathan Bossart, Tom Lane
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 52bf87ac55b..24e3514b005 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -7176,16 +7176,16 @@ get_merge_query_def(Query *query, deparse_context *context,
switch (action->matchKind)
{
case MERGE_WHEN_MATCHED:
- appendStringInfo(buf, "MATCHED");
+ appendStringInfoString(buf, "MATCHED");
break;
case MERGE_WHEN_NOT_MATCHED_BY_SOURCE:
- appendStringInfo(buf, "NOT MATCHED BY SOURCE");
+ appendStringInfoString(buf, "NOT MATCHED BY SOURCE");
break;
case MERGE_WHEN_NOT_MATCHED_BY_TARGET:
if (haveNotMatchedBySource)
- appendStringInfo(buf, "NOT MATCHED BY TARGET");
+ appendStringInfoString(buf, "NOT MATCHED BY TARGET");
else
- appendStringInfo(buf, "NOT MATCHED");
+ appendStringInfoString(buf, "NOT MATCHED");
break;
default:
elog(ERROR, "unrecognized matchKind: %d",
@@ -8850,18 +8850,18 @@ get_json_expr_options(JsonExpr *jsexpr, deparse_context *context,
if (jsexpr->op == JSON_QUERY_OP)
{
if (jsexpr->wrapper == JSW_CONDITIONAL)
- appendStringInfo(context->buf, " WITH CONDITIONAL WRAPPER");
+ appendStringInfoString(context->buf, " WITH CONDITIONAL WRAPPER");
else if (jsexpr->wrapper == JSW_UNCONDITIONAL)
- appendStringInfo(context->buf, " WITH UNCONDITIONAL WRAPPER");
+ appendStringInfoString(context->buf, " WITH UNCONDITIONAL WRAPPER");
/* The default */
else if (jsexpr->wrapper == JSW_NONE || jsexpr->wrapper == JSW_UNSPEC)
- appendStringInfo(context->buf, " WITHOUT WRAPPER");
+ appendStringInfoString(context->buf, " WITHOUT WRAPPER");
if (jsexpr->omit_quotes)
- appendStringInfo(context->buf, " OMIT QUOTES");
+ appendStringInfoString(context->buf, " OMIT QUOTES");
/* The default */
else
- appendStringInfo(context->buf, " KEEP QUOTES");
+ appendStringInfoString(context->buf, " KEEP QUOTES");
}
if (jsexpr->on_empty && jsexpr->on_empty->btype != default_behavior)
@@ -10206,7 +10206,7 @@ get_rule_expr(Node *node, deparse_context *context,
JSON_BEHAVIOR_NULL :
JSON_BEHAVIOR_FALSE);
- appendStringInfoString(buf, ")");
+ appendStringInfoChar(buf, ')');
}
break;