2000-01-05 18:31:08 +01:00
|
|
|
--
|
|
|
|
-- CREATE_AGGREGATE
|
|
|
|
--
|
|
|
|
-- all functions CREATEd
|
|
|
|
CREATE AGGREGATE newavg (
|
2000-07-17 05:05:41 +02:00
|
|
|
sfunc = int4_accum, basetype = int4, stype = _numeric,
|
|
|
|
finalfunc = numeric_avg,
|
|
|
|
initcond1 = '{0,0,0}'
|
1997-04-06 08:07:13 +02:00
|
|
|
);
|
2003-11-21 23:32:49 +01:00
|
|
|
-- test comments
|
|
|
|
COMMENT ON AGGREGATE newavg_wrong (int4) IS 'an agg comment';
|
|
|
|
ERROR: aggregate newavg_wrong(integer) does not exist
|
|
|
|
COMMENT ON AGGREGATE newavg (int4) IS 'an agg comment';
|
|
|
|
COMMENT ON AGGREGATE newavg (int4) IS NULL;
|
2000-07-17 05:05:41 +02:00
|
|
|
-- without finalfunc; test obsolete spellings 'sfunc1' etc
|
2000-01-05 18:31:08 +01:00
|
|
|
CREATE AGGREGATE newsum (
|
|
|
|
sfunc1 = int4pl, basetype = int4, stype1 = int4,
|
1997-04-06 08:07:13 +02:00
|
|
|
initcond1 = '0'
|
|
|
|
);
|
2006-07-27 21:52:07 +02:00
|
|
|
-- zero-argument aggregate
|
|
|
|
CREATE AGGREGATE newcnt (*) (
|
|
|
|
sfunc = int8inc, stype = int8,
|
|
|
|
initcond = '0'
|
|
|
|
);
|
|
|
|
-- old-style spelling of same
|
|
|
|
CREATE AGGREGATE oldcnt (
|
|
|
|
sfunc = int8inc, basetype = 'ANY', stype = int8,
|
|
|
|
initcond = '0'
|
|
|
|
);
|
|
|
|
-- aggregate that only cares about null/nonnull input
|
|
|
|
CREATE AGGREGATE newcnt ("any") (
|
|
|
|
sfunc = int8inc_any, stype = int8,
|
|
|
|
initcond = '0'
|
|
|
|
);
|
|
|
|
-- multi-argument aggregate
|
|
|
|
create function sum3(int8,int8,int8) returns int8 as
|
|
|
|
'select $1 + $2 + $3' language sql strict immutable;
|
|
|
|
create aggregate sum2(int8,int8) (
|
|
|
|
sfunc = sum3, stype = int8,
|
2000-07-17 05:05:41 +02:00
|
|
|
initcond = '0'
|
1997-04-06 08:07:13 +02:00
|
|
|
);
|
2003-11-21 23:32:49 +01:00
|
|
|
COMMENT ON AGGREGATE nosuchagg (*) IS 'should fail';
|
|
|
|
ERROR: aggregate nosuchagg(*) does not exist
|
2006-07-27 21:52:07 +02:00
|
|
|
COMMENT ON AGGREGATE newcnt (*) IS 'an agg(*) comment';
|
|
|
|
COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';
|