~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/test/regress/sql/create_aggregate.sql

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- CREATE_AGGREGATE
 
3
--
 
4
 
 
5
-- all functions CREATEd
 
6
CREATE AGGREGATE newavg (
 
7
   sfunc = int4_avg_accum, basetype = int4, stype = _int8, 
 
8
   finalfunc = int8_avg,
 
9
   initcond1 = '{0,0}'
 
10
);
 
11
 
 
12
-- test comments
 
13
COMMENT ON AGGREGATE newavg_wrong (int4) IS 'an agg comment';
 
14
COMMENT ON AGGREGATE newavg (int4) IS 'an agg comment';
 
15
COMMENT ON AGGREGATE newavg (int4) IS NULL;
 
16
 
 
17
-- without finalfunc; test obsolete spellings 'sfunc1' etc
 
18
CREATE AGGREGATE newsum (
 
19
   sfunc1 = int4pl, basetype = int4, stype1 = int4, 
 
20
   initcond1 = '0'
 
21
);
 
22
 
 
23
-- zero-argument aggregate
 
24
CREATE AGGREGATE newcnt (*) (
 
25
   sfunc = int8inc, stype = int8,
 
26
   initcond = '0'
 
27
);
 
28
 
 
29
-- old-style spelling of same
 
30
CREATE AGGREGATE oldcnt (
 
31
   sfunc = int8inc, basetype = 'ANY', stype = int8,
 
32
   initcond = '0'
 
33
);
 
34
 
 
35
-- aggregate that only cares about null/nonnull input
 
36
CREATE AGGREGATE newcnt ("any") (
 
37
   sfunc = int8inc_any, stype = int8,
 
38
   initcond = '0'
 
39
);
 
40
 
 
41
-- multi-argument aggregate
 
42
create function sum3(int8,int8,int8) returns int8 as
 
43
'select $1 + $2 + $3' language sql strict immutable;
 
44
 
 
45
create aggregate sum2(int8,int8) (
 
46
   sfunc = sum3, stype = int8,
 
47
   initcond = '0'
 
48
);
 
49
 
 
50
COMMENT ON AGGREGATE nosuchagg (*) IS 'should fail';
 
51
COMMENT ON AGGREGATE newcnt (*) IS 'an agg(*) comment';
 
52
COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';