Re: Creating an aggregate function - Mailing list pgsql-sql

From Tom Lane
Subject Re: Creating an aggregate function
Date
Msg-id 29842.968533416@sss.pgh.pa.us
Whole thread Raw
In response to Creating an aggregate function  (Roberto Mello <rmello@cc.usu.edu>)
List pgsql-sql
Roberto Mello <rmello@cc.usu.edu> writes:
> and our output was: 
>       date_id | n_sessions_day |  members  | non_members
>      ---------+----------------+-----------+-------------
>             1 |            500 |        30 |   136394044
>             2 |           2000 | 136394612 |   136394612 

In current sources I get the expected results if I write the
CREATE AGGREGATE commands withinitcond1 = '0');
Although the parser will accept unquoted integers as initcond
inputs, it looks like something downstream is mishandling them,
resulting in an invalid initial value entered into the pg_aggregate
entry for the aggregate.

I'll look into fixing that for 7.1, but in the meantime try putting
quotes around the initial values.

BTW, your agg_if_member function is not very good, because if it gets
more than one input row with member_p = 1 then the result is order-
dependent.  You don't want that.
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Porting from mysql to psql (UNIX_TIMESTAMP()?)
Next
From: Max Pyziur
Date:
Subject: "ORDER BY" issue - is this a bug?