pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Provide an error cursor for "can't call an SRF here" errors.
Date: Tue, 18 Apr 2017 17:21:33 +0000
Message-ID: <E1d0Won-0003Hd-7A@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Provide an error cursor for "can't call an SRF here" errors.

Since it appears that v10 is going to move the goalposts by some amount
in terms of where you can and can't invoke set-returning functions,
arrange for the executor's "set-valued function called in context that
cannot accept a set" errors to include a syntax position if possible,
pointing to the specific SRF that can't be called where it's located.

The main bit of infrastructure needed for this is to make the query source
text accessible in the executor; but it turns out that commit 4c728f382
already did that.  We just need a new function executor_errposition()
modeled on parser_errposition(), and we're ready to rock.

While experimenting with this, I noted that the error position wasn't
properly reported if it occurred in a plpgsql FOR-over-query loop,
which turned out to be because SPI_cursor_open_internal wasn't providing
an error context callback during PortalStart.  Fix that.

There's a whole lot more that could be done with this infrastructure
now that it's there, but this is not the right time in the development
cycle for that sort of work.  Hence, resist the temptation to plaster
executor_errposition() calls everywhere ... for the moment.

Discussion: https://postgr.es/m/5263.1492471571@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e240a65c7dfc5ad80ab757ecb1aa9b9032c7f8ae

Modified Files
--------------
src/backend/executor/execExpr.c    |  4 +++-
src/backend/executor/execSRF.c     | 16 ++++++++++------
src/backend/executor/execUtils.c   | 33 +++++++++++++++++++++++++++++++++
src/backend/executor/spi.c         |  6 +++---
src/include/executor/executor.h    |  2 ++
src/test/regress/expected/tsrf.out |  6 ++++++
6 files changed, 57 insertions(+), 10 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (2+ messages)  latest in thread

Message-ID: <E1d0Won-0003Hd-7A@gemulon.postgresql.org>
Permalink:  ../E1d0Won-0003Hd-7A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1d0Won-0003Hd-7A@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Provide an error cursor for "can't call an SRF here" errors.
  In-Reply-To: <E1d0Won-0003Hd-7A@gemulon.postgresql.org>
  References: <E1d0Won-0003Hd-7A@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox