CREATE AGGREGATE state function with one argument - Mailing list pgsql-general

From Thalis A. Kalfigopoulos
Subject CREATE AGGREGATE state function with one argument
Date
Msg-id Pine.LNX.4.21.0106181158250.19889-100000@aluminum.cs.pitt.edu
Whole thread Raw
Responses Re: CREATE AGGREGATE state function with one argument  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
In the manual fro creating aggregate functions (http://www.postgresql.org/idocs/index.php?sql-createaggregate.html) it
reads:

sfunc

     The name of the state transition function to be called for each input data value. This is normally a function of
twoarguments, the first being of type state_type and the second of type input_data_type. --->Alternatively, for an
aggregatethat does not examine its input values, the function takes just one argument of type state_type<---. In either
casethe function must return a value of type state_type. This function takes the current state value and the current
inputdata item, and returns the next state value. 

So I try this:

thalis=# CREATE FUNCTION state_func(int4) RETURNS int4 AS 'SELECT $1;' LANGUAGE 'sql';
CREATE
thalis=# CREATE AGGREGATE myaggr (basetype=int4,sfunc=state_func,stype=int4);
ERROR:  AggregateCreate: function 'state_func(int4, int4)' does not exist

I understand that I can have a state function that takes just one argument. Missing smthng?

TIA,
thalis

ps running 7.1.1


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Apache with PHP and PGSQL crashing ...
Next
From: Peter Eisentraut
Date:
Subject: Re: primary/secondary index, difference