Re: [GENERAL] c function return not recognized?

From: "Gene Selkov Jr(dot)" <selkovjr(at)selkovjr(dot)xnet(dot)com>
To: Frank Miles <fpm(at)u(dot)washington(dot)edu>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] c function return not recognized?
Date: 1999-12-12 07:37:18
Message-ID: 199912120635.AAA29334@mail.xnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Frank Miles wrote:

> I've got an external C function that I call from a SELECT, for example:
>
> select * from <table> where <cond1> and CFunction(columnName) > 1.0;
>
> The 'CFunction' has been installed into Postgreql using CREATE FUNCTION,
> with a single 'text' argument, and returning a float8 (i.e. double).

This is becoming a VFAQ, which is nice because it means that the
extensibility features gain popularity (which IMO make postgres stand
out very impressively), but it is disturbing that the message in the
docs and in examples is not getting through.

One can't get anything back from a C function by other means than
reference. One needs to first palloc() the space for the value and
then return the pointer to it. The reason Frank's function behaved as
he describes is likely because the caller treats the return values as
pointers which indeed points to random locations depending on the
input.

There could be other reasons, too, but then again, it is always helpful
to paste a bit of your code so we don't have to speculate about the
exact nature of your problem.

--Gene

Browse pgsql-general by date

  From Date Subject
Next Message R.J. 1999-12-12 13:57:33 Index of words form a field.
Previous Message Robert 1999-12-12 07:30:42 Re: [GENERAL] Czech Win1250 sorting q