Re: Re: External search engine, advice - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Re: External search engine, advice
Date
Msg-id 10237.990332896@sss.pgh.pa.us
Whole thread Raw
In response to Re: External search engine, advice  (mlw <markw@mohawksoft.com>)
List pgsql-hackers
mlw <markw@mohawksoft.com> writes:
> The above is an example of how to write a function that returns multiple
> results.

One suggestion: you must check not only that fcinfo->resultinfo isn't
NULL, but that it points at the sort of node you're expecting.  Say
if (fcinfo->resultinfo == NULL ||    ! IsA(fcinfo->resultinfo, ReturnSetInfo))    <complain>;

If you fail to do this, you can fully expect your code to coredump
a version or two hence.  Right now the only possibility for resultinfo
is to point at a ReturnSetInfo, but that *will* change.

> create function ftss_search (varchar)
>     returns setof integer
>     as '/usr/local/lib/library.so', 'ftss_search'
>     language 'c' with (iscachable);

> The above in an example of how one would register this function in postgres.

Hmm ... given that ftss refers to external files, is it a good idea to
mark it cachable?  I'd sort of expect that the values it returns for
a particular argument could change over time.  Cachable amounts to a
promise that the results for a given argument will not change over time.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Fix for tablename in targetlist
Next
From: Tom Lane
Date:
Subject: Re: Fix for tablename in targetlist