Re: (When) can a single SQL statement return multiple result sets?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <shammat(at)gmx(dot)net>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: (When) can a single SQL statement return multiple result sets?
Date: 2024-04-11 14:07:34
Message-ID: 169805.1712844454@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Kellerer <shammat(at)gmx(dot)net> writes:
> Tom Lane schrieb am 11.04.2024 um 01:02:
>> Jan Behrens <jbe-mlist(at)magnetkern(dot)de> writes:
>>> While writing a PostgreSQL client library for Lua supporting
>>> Pipelining (using PQsendQueryParams), I have been wondering if there
>>> are any single SQL commands that return multiple result sets.

>> Right now, I don't think so.

> Hmm, what about functions returning multiple refcursors?

Sure, but let's distinguish between "here's an ugly workaround"
and "it just works". Aside from being tedious, the refcursor
approach is restrictive: I don't think you can readily make
a refcursor on the result of INSERT/UPDATE/DELETE RETURNING,
nor on utility statements such as EXPLAIN. (There might be
a way around the former restriction with WITH, but I'm
certain that won't work for EXPLAIN.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2024-04-11 14:21:38 Re: subquery plan rows = 1, but it's merge joined instead of index lookup
Previous Message ilya Basin 2024-04-11 12:57:34 subquery plan rows = 1, but it's merge joined instead of index lookup