C SRF question

From: Stephen Woodbridge <woodbri(at)swoodbridge(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: C SRF question
Date: 2012-11-04 13:57:50
Message-ID: 5096745E.5000003@swoodbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2012-11-04 16:37:40 Re: Server to run Postgresql
Previous Message Pavel Stehule 2012-11-04 11:49:08 proposal: fix corner use case of variadic fuctions usage