Re: Aggregate with external sfunc - Mailing list pgsql-general

From Tom Lane
Subject Re: Aggregate with external sfunc
Date
Msg-id 14457.1028316207@sss.pgh.pa.us
Whole thread Raw
In response to Aggregate with external sfunc  (Tiberiu Stef <tstef@cs.purdue.edu>)
List pgsql-general
Tiberiu Stef <tstef@cs.purdue.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

pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: MySQL vs. PostgreSQL
Next
From: Tom Lane
Date:
Subject: Re: How i can empty the buffers of a db