Re: PostgreSQL documentation specifies 2-element array for float8_accum but 3-element array expected

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Disc Magnet <discmagnet(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL documentation specifies 2-element array for float8_accum but 3-element array expected
Date: 2011-03-23 14:05:10
Message-ID: AANLkTin9fxFyjP1j91g9PdTUyWyC29gQn4KyjOs-dZ-y@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 23, 2011 at 8:03 AM, Disc Magnet <discmagnet(at)gmail(dot)com> wrote:
> I was learning how to create my own aggregate functions from
> http://www.postgresql.org/docs/9.0/static/xaggr.html
>
> I copied the avg() example as
>
> CREATE TABLE numbers (
>    value integer
> );
>
> insert into numbers values (2);
> insert into numbers values (3);
> insert into numbers values (4);
>
> CREATE AGGREGATE myavg(float8) (
>    sfunc = float8_accum,
>    stype = float8[],
>    finalfunc = float8_avg,
>    initcond = '{0,0}'
> );
>
> On trying to run this, I get this error:
>
> cdb=# select myavg(value) from numbers;
> ERROR:  float8_accum: expected 3-element float8 array
>
> How can I fix this?

how embarrassing -- the initcont should be: '{0,0,0}' :^).

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2011-03-23 14:08:00 Re: Weird problems with C extension and bytea as input type
Previous Message dennis jenkins 2011-03-23 14:04:18 Re: Weird problems with C extension and bytea as input type