Commit 3d7ac0d0 authored by Tom Lane's avatar Tom Lane

Note that the example aggregate array_accum is comparable to the now

built-in array_agg.  Per suggestion from Robert Haas.
parent 170b66a0
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.35 2007/02/01 00:28:18 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.36 2008/11/20 21:10:44 tgl Exp $ -->
<sect1 id="xaggr"> <sect1 id="xaggr">
<title>User-Defined Aggregates</title> <title>User-Defined Aggregates</title>
...@@ -132,7 +132,10 @@ CREATE AGGREGATE array_accum (anyelement) ...@@ -132,7 +132,10 @@ CREATE AGGREGATE array_accum (anyelement)
</programlisting> </programlisting>
Here, the actual state type for any aggregate call is the array type Here, the actual state type for any aggregate call is the array type
having the actual input type as elements. having the actual input type as elements. The behavior of the aggregate
is to concatenate all the inputs into an array of that type.
(Note: the built-in aggregate <function>array_agg</> provides similar
functionality, with better performance than this definition would have.)
</para> </para>
<para> <para>
...@@ -149,14 +152,14 @@ SELECT attrelid::regclass, array_accum(attname) ...@@ -149,14 +152,14 @@ SELECT attrelid::regclass, array_accum(attname)
pg_tablespace | {spcname,spcowner,spclocation,spcacl} pg_tablespace | {spcname,spcowner,spclocation,spcacl}
(1 row) (1 row)
SELECT attrelid::regclass, array_accum(atttypid) SELECT attrelid::regclass, array_accum(atttypid::regtype)
FROM pg_attribute FROM pg_attribute
WHERE attnum &gt; 0 AND attrelid = 'pg_tablespace'::regclass WHERE attnum &gt; 0 AND attrelid = 'pg_tablespace'::regclass
GROUP BY attrelid; GROUP BY attrelid;
attrelid | array_accum attrelid | array_accum
---------------+----------------- ---------------+---------------------------
pg_tablespace | {19,26,25,1034} pg_tablespace | {name,oid,text,aclitem[]}
(1 row) (1 row)
</programlisting> </programlisting>
</para> </para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment