Re: Aggregate with external sfunc

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tiberiu Stef <tstef(at)cs(dot)purdue(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Aggregate with external sfunc
Date: 2002-08-02 19:23:27
Message-ID: 14457.1028316207@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tiberiu Stef <tstef(at)cs(dot)purdue(dot)edu> writes:
> I created a C function:
> CREATE OR REPLACE FUNCTION fintransfunc(double precision,double precision)
> RETURNS double precision AS '$libdir/finops.so' LANGUAGE C;

You probably want to mark it strict (WITH (isStrict)), unless it's
prepared to deal with NULL inputs. I'm betting your table contains
some NULLs.

> However, if I replace in the aggregate creation the fintransfunc with
> float8smaller, and then test again, the query goes through and produces
> the desired result.

float8smaller is marked isStrict ...

> From my tests, I guess the aggregate interpreter fails to find a function
> that is not in the default postgres server library.

No, your routine is dumping core on a null pointer dereference, as you
should have been able to find out for yourself with a debugger. If you
don't know how to use gdb or some other debugger, writing C functions is
not going to be much fun for you.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-08-02 19:27:14 Re: How i can empty the buffers of a db
Previous Message Daniel Wickstrom 2002-08-02 19:11:17 Re: MySQL or Postgres ?