On fre, 2011-12-23 at 19:51 +0200, Peter Eisentraut wrote:
> On ons, 2011-12-21 at 11:04 +0100, Pavel Stehule wrote:
> > this patch adds a bytea_agg aggregation.
> > 
> > It allow fast bytea concatetation.
> 
> Why not call it string_agg?  All the function names are the same between
> text and bytea (e.g., ||, substr, position, length).  It would be nice
> not to introduce arbitrary differences.

Here is a patch to do the renaming.  As it stands, it fails the
opr_sanity regression test, because that complains that there are now
two aggregate functions string_agg with different number of arguments.
It seems to me that that test should really only complain if the common
argument types of the two aggregates are the same, correct?

diff --git i/doc/src/sgml/func.sgml w/doc/src/sgml/func.sgml
index 34fea16..393cfcd 100644
--- i/doc/src/sgml/func.sgml
+++ w/doc/src/sgml/func.sgml
@@ -10963,10 +10963,10 @@ SELECT NULLIF(value, '(none)') ...
      <row>
       <entry>
        <indexterm>
-        <primary>bytea_agg</primary>
+        <primary>string_agg</primary>
        </indexterm>
        <function>
-         bytea_agg(<replaceable class="parameter">expression</replaceable>)
+         string_agg(<replaceable class="parameter">expression</replaceable>)
        </function>
       </entry>
       <entry>
diff --git i/src/backend/utils/adt/varlena.c w/src/backend/utils/adt/varlena.c
index 65e9af8..c6b351e 100644
--- i/src/backend/utils/adt/varlena.c
+++ w/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;
 
@@ -415,14 +415,14 @@ bytea_agg_transfn(PG_FUNCTION_ARGS)
 	}
 
 	/*
-	 * 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;
 
diff --git i/src/include/catalog/pg_aggregate.h w/src/include/catalog/pg_aggregate.h
index adda07c..461772c 100644
--- i/src/include/catalog/pg_aggregate.h
+++ w/src/include/catalog/pg_aggregate.h
@@ -229,7 +229,7 @@ DATA(insert ( 2335	array_agg_transfn	array_agg_finalfn		0	2281	_null_ ));
 DATA(insert ( 3538	string_agg_transfn	string_agg_finalfn		0	2281	_null_ ));
 
 /* bytea */
-DATA(insert ( 3545	bytea_agg_transfn	bytea_agg_finalfn		0	2281	_null_ ));
+DATA(insert ( 3545	bytea_string_agg_transfn	bytea_string_agg_finalfn		0	2281	_null_ ));
 
 /*
  * prototypes for functions in pg_aggregate.c
diff --git i/src/include/catalog/pg_proc.h w/src/include/catalog/pg_proc.h
index 49b0754..e1962fe 100644
--- i/src/include/catalog/pg_proc.h
+++ w/src/include/catalog/pg_proc.h
@@ -2433,11 +2433,11 @@ DATA(insert OID = 3536 (  string_agg_finalfn		PGNSP PGUID 12 1 0 0 0 f f f f f f
 DESCR("aggregate final function");
 DATA(insert OID = 3538 (  string_agg				PGNSP PGUID 12 1 0 0 0 t f f f f f i 2 0 25 "25 25" _null_ _null_ _null_ _null_ aggregate_dummy _null_ _null_ _null_ ));
 DESCR("concatenate aggregate input into a string");
-DATA(insert OID = 3543 (  bytea_agg_transfn		PGNSP PGUID 12 1 0 0 0 f f f f f f i 2 0 2281 "2281 17" _null_ _null_ _null_ _null_ bytea_agg_transfn _null_ _null_ _null_ ));
+DATA(insert OID = 3543 (  bytea_string_agg_transfn	PGNSP PGUID 12 1 0 0 0 f f f f f f i 2 0 2281 "2281 17" _null_ _null_ _null_ _null_ bytea_string_agg_transfn _null_ _null_ _null_ ));
 DESCR("aggregate transition function");
-DATA(insert OID = 3544 (  bytea_agg_finalfn		PGNSP PGUID 12 1 0 0 0 f f f f f f i 1 0 17 "2281" _null_ _null_ _null_ _null_ bytea_agg_finalfn _null_ _null_ _null_ ));
+DATA(insert OID = 3544 (  bytea_string_agg_finalfn	PGNSP PGUID 12 1 0 0 0 f f f f f f i 1 0 17 "2281" _null_ _null_ _null_ _null_ bytea_string_agg_finalfn _null_ _null_ _null_ ));
 DESCR("aggregate final function");
-DATA(insert OID = 3545 (  bytea_agg				PGNSP PGUID 12 1 0 0 0 t f f f f f i 1 0 17 "17" _null_ _null_ _null_ _null_ aggregate_dummy _null_ _null_ _null_ ));
+DATA(insert OID = 3545 (  string_agg				PGNSP PGUID 12 1 0 0 0 t f f f f f i 1 0 17 "17" _null_ _null_ _null_ _null_ aggregate_dummy _null_ _null_ _null_ ));
 DESCR("concatenate aggregate input into a bytea");
 
 /* To ASCII conversion */
diff --git i/src/include/utils/builtins.h w/src/include/utils/builtins.h
index 9fda7ad..201b23e 100644
--- i/src/include/utils/builtins.h
+++ w/src/include/utils/builtins.h
@@ -771,8 +771,8 @@ extern Datum unknownsend(PG_FUNCTION_ARGS);
 
 extern Datum pg_column_size(PG_FUNCTION_ARGS);
 
-extern Datum bytea_agg_transfn(PG_FUNCTION_ARGS);
-extern Datum bytea_agg_finalfn(PG_FUNCTION_ARGS);
+extern Datum bytea_string_agg_transfn(PG_FUNCTION_ARGS);
+extern Datum bytea_string_agg_finalfn(PG_FUNCTION_ARGS);
 extern Datum string_agg_transfn(PG_FUNCTION_ARGS);
 extern Datum string_agg_finalfn(PG_FUNCTION_ARGS);
 
diff --git i/src/test/regress/expected/aggregates.out w/src/test/regress/expected/aggregates.out
index 2ec4eec..99ea5ef 100644
--- i/src/test/regress/expected/aggregates.out
+++ w/src/test/regress/expected/aggregates.out
@@ -1061,25 +1061,25 @@ select string_agg(distinct f1::text, ',' order by f1::text) from varchar_tbl;  -
  a,ab,abcd
 (1 row)
 
--- bytea_agg tests
+-- string_agg bytea tests
 create table bytea_test_table(v bytea);
-select bytea_agg(v) from bytea_test_table;
- bytea_agg 
------------
+select string_agg(v) from bytea_test_table;
+ string_agg 
+------------
  
 (1 row)
 
 insert into bytea_test_table values(decode('ff','hex'));
-select bytea_agg(v) from bytea_test_table;
- bytea_agg 
------------
+select string_agg(v) from bytea_test_table;
+ string_agg 
+------------
  \xff
 (1 row)
 
 insert into bytea_test_table values(decode('aa','hex'));
-select bytea_agg(v) from bytea_test_table;
- bytea_agg 
------------
+select string_agg(v) from bytea_test_table;
+ string_agg 
+------------
  \xffaa
 (1 row)
 
diff --git i/src/test/regress/sql/aggregates.sql w/src/test/regress/sql/aggregates.sql
index 01c2e2d..b77daf5 100644
--- i/src/test/regress/sql/aggregates.sql
+++ w/src/test/regress/sql/aggregates.sql
@@ -417,17 +417,17 @@ select string_agg(distinct f1::text, ',' order by f1) from varchar_tbl;  -- not
 select string_agg(distinct f1, ',' order by f1::text) from varchar_tbl;  -- not ok
 select string_agg(distinct f1::text, ',' order by f1::text) from varchar_tbl;  -- ok
 
--- bytea_agg tests
+-- string_agg bytea tests
 create table bytea_test_table(v bytea);
 
-select bytea_agg(v) from bytea_test_table;
+select string_agg(v) from bytea_test_table;
 
 insert into bytea_test_table values(decode('ff','hex'));
 
-select bytea_agg(v) from bytea_test_table;
+select string_agg(v) from bytea_test_table;
 
 insert into bytea_test_table values(decode('aa','hex'));
 
-select bytea_agg(v) from bytea_test_table;
+select string_agg(v) from bytea_test_table;
 
 drop table bytea_test_table;
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to