Re: multiple results from a function - Mailing list pgsql-general

From James Harper
Subject Re: multiple results from a function
Date
Msg-id 6035A0D088A63A46850C3988ED045A4B6F3C2632@BITCOM1.int.sbss.com.au
Whole thread Raw
In response to Re: multiple results from a function  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: multiple results from a function  (Merlin Moncure <mmoncure@gmail.com>)
Re: multiple results from a function  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
>
> On Thu, Feb 27, 2014 at 6:23 PM, James Harper
> <james.harper@bendigoit.com.au> wrote:
> > I see that I can use PQgetResult to get results from an async query, and this
> allows for multiple results, presumably when the query is like "SELECT 123,
> 456; SELECT 'ABC', 'DEF';". Is there a way for a C function, using SPI, to send
> result sets without waiting for completion and returning a potentially huge
> set of results right at the end of the function?
> >
> > Failing that, is there a way for a C function to send to STDOUT in the same
> way that a COPY (...) TO STDOUT would?
>
> Why does this have to be an SPI function?  Maybe a little more context
> here would help.
>

I'm working on an application to accept TDS (Microsoft SQL Server) connections and proxy them to postgres. MSSQL does
thingsa little differently, for instance in addition to a functions it has stored procedures that can contain multiple
selectstatement that return results to clients. 

I'm building against 9.3 at the moment, and my code is external to the postgres process and using libpq connections,
butI noticed that 9.4 allows dynamic backend worker processes which would allow my code to run server side and spawn a
processfor each TDS connection. 

I've worked around the multiple results issue by running the stored procedure outside of my custom language, which
allowsme to return the results as they happen. I had the idea that I could use COPY ... STDOUT to emulate the return of
results,but that would have had too many shortcomings anyway. 

Thanks

James


pgsql-general by date:

Previous
From: Brent Wood
Date:
Subject: Re: Multiple Schema in One DB
Next
From: Evan Martin
Date:
Subject: Efficiently delete rows not referenced by a foreign key