Thread: C SRF question

C SRF question

From
Stephen Woodbridge
Date:
Hi all,

I am writing a C set returning function to standardize address strings like:

select * from standard_address(
    sql_for_lexicon,
    sql_for_gazeteer,
    sql_for_rules,
    sql_for_addresses);

On the first call, the first 3 sql statements are executed with SPI to
collect and build the standardizer internal structures and a pointer to
this is saved in functx->user_fctx.

Next I plan to create an SPI cursor to get the addresses that need to be
standardized and fetch one record on each call, standardize it and
return it. Is this the best strategy? In other functions I have written,
I have created a result structure and fetched all the results into that
then saved that structure and returned the record from that on
successive calls but those result sets were small.

Does this cursor need to be saved between successive calls to the
function? How? Do I need to SPI_connect on each all? or does it remember
that across calls?

Thanks for any insight you can offer.

-Steve