aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/varlena.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2012-04-13 21:36:59 +0300
committerPeter Eisentraut <peter_e@gmx.net>2012-04-13 21:36:59 +0300
commitc0cc526e8b1e821dfced692a68e4c8978c2bdbc1 (patch)
treeefc28ea316bc5aedcffe57963c049a8bbd540d13 /src/backend/utils/adt/varlena.c
parent64e1309c76aca35e32e62e69fc11e96aadfb2615 (diff)
downloadpostgresql-c0cc526e8b1e821dfced692a68e4c8978c2bdbc1.tar.gz
postgresql-c0cc526e8b1e821dfced692a68e4c8978c2bdbc1.zip
Rename bytea_agg to string_agg and add delimiter argument
Per mailing list discussion, we would like to keep the bytea functions parallel to the text functions, so rename bytea_agg to string_agg, which already exists for text. Also, to satisfy the rule that we don't want aggregate functions of the same name with a different number of arguments, add a delimiter argument, just like string_agg for text already has.
Diffstat (limited to 'src/backend/utils/adt/varlena.c')
-rw-r--r--src/backend/utils/adt/varlena.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 65e9af8db89..a5592d56e11 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -397,7 +397,7 @@ byteasend(PG_FUNCTION_ARGS)
}
Datum
-bytea_agg_transfn(PG_FUNCTION_ARGS)
+bytea_string_agg_transfn(PG_FUNCTION_ARGS)
{
StringInfo state;
@@ -408,21 +408,28 @@ bytea_agg_transfn(PG_FUNCTION_ARGS)
{
bytea *value = PG_GETARG_BYTEA_PP(1);
+ /* On the first time through, we ignore the delimiter. */
if (state == NULL)
state = makeStringAggState(fcinfo);
+ else if (!PG_ARGISNULL(2))
+ {
+ bytea *delim = PG_GETARG_BYTEA_PP(2);
+
+ appendBinaryStringInfo(state, VARDATA_ANY(delim), VARSIZE_ANY_EXHDR(delim));
+ }
appendBinaryStringInfo(state, VARDATA_ANY(value), VARSIZE_ANY_EXHDR(value));
}
/*
- * The transition type for bytea_agg() is declared to be "internal",
+ * The transition type for string_agg() is declared to be "internal",
* which is a pass-by-value type the same size as a pointer.
*/
PG_RETURN_POINTER(state);
}
Datum
-bytea_agg_finalfn(PG_FUNCTION_ARGS)
+bytea_string_agg_finalfn(PG_FUNCTION_ARGS)
{
StringInfo state;