2 * Copyright (C) 2004-2008 Georgia Public Library Service
3 * Copyright (C) 2008 Equinox Software, Inc.
4 * Mike Rylander <miker@esilibrary.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
20 DROP AGGREGATE IF EXISTS array_accum(anyelement) CASCADE;
22 CREATE AGGREGATE array_accum (
24 basetype = anyelement,
29 CREATE OR REPLACE FUNCTION public.first_agg ( anyelement, anyelement ) RETURNS anyelement AS $$
30 SELECT CASE WHEN $1 IS NULL THEN $2 ELSE $1 END;
31 $$ LANGUAGE SQL STABLE;
33 DROP AGGREGATE IF EXISTS public.first(anyelement) CASCADE;
35 CREATE AGGREGATE public.first (
36 sfunc = public.first_agg,
37 basetype = anyelement,
41 CREATE OR REPLACE FUNCTION public.last_agg ( anyelement, anyelement ) RETURNS anyelement AS $$
43 $$ LANGUAGE SQL STABLE;
45 DROP AGGREGATE IF EXISTS public.last(anyelement) CASCADE;
47 CREATE AGGREGATE public.last (
48 sfunc = public.last_agg,
49 basetype = anyelement,
53 CREATE OR REPLACE FUNCTION public.text_concat ( TEXT, TEXT ) RETURNS TEXT AS $$
61 $$ LANGUAGE SQL STABLE;
63 DROP AGGREGATE IF EXISTS public.agg_text(text) CASCADE;
65 CREATE AGGREGATE public.agg_text (
66 sfunc = public.text_concat,
71 CREATE OR REPLACE FUNCTION public.tsvector_concat ( tsvector, tsvector ) RETURNS tsvector AS $$
79 $$ LANGUAGE SQL STABLE;
81 DROP AGGREGATE IF EXISTS public.agg_tsvector(tsvector) CASCADE;
83 CREATE AGGREGATE public.agg_tsvector (
84 sfunc = public.tsvector_concat,