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

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Jan Behrens <jbe-mlist(at)magnetkern(dot)de>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: (When) can a single SQL statement return multiple result sets?
Date: 2024-04-15 22:16:47
Message-ID: CAHyXU0z0PfBLQFp+QaxyW5UmkCgcxJ-+0_wo6FdexyzQmsJoAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Apr 15, 2024 at 10:24 AM Jan Behrens <jbe-mlist(at)magnetkern(dot)de>
wrote:

> On Wed, 10 Apr 2024 19:02:48 -0400
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > > Here, "DELETE FROM magic" returns multiple result sets, even though it
> > > is only a single SQL statement.
> >
> > Right, so it's kind of a case that you have to support. We're not
> > likely to rip out rules anytime soon, even if they're a bit
> > deprecated.
>
> As it seems to be a corner case that rarely occurs in practice, I was
> considering to simply not support this case in my client library. I
> don't know which SQL error code I could return in that case though.
> Maybe "0A000" (feature_not_supported) or
> "21000" (cardinality_violation). Not sure if either of those is a good
> choice. Any better idea?

If you are asking if "rules" can be ignored or error-walled in terms of
your library design, I'd say yes. 100% yes.

The main caveat would then be the proposed multi-resultset stored procedure
feature, which might break the 'one result per semicolon' assumption you
might be chasing as it has some basis in the standard, so I'd be balancing
risk/reward against that feature IMO if I were you.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nicolas Seinlet 2024-04-16 07:56:35 Re: Failing streaming replication on PostgreSQL 14
Previous Message Alvaro Herrera 2024-04-15 16:49:29 Re: Failing streaming replication on PostgreSQL 14