pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Noah Misch <noah@leadboat.com>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Andres Freund <andres@anarazel.de>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Jaime Casanova <jcasanov@systemguards.com.ec>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: SQL-standard function body
Date: Sat, 10 Apr 2021 10:52:15 -0400
Message-ID: <2298215.1618066335@sss.pgh.pa.us> (raw)
In-Reply-To: <20210410033014.GA993491@rfd.leadboat.com>
References: <01c65ea6-e5bf-22f4-cacc-6d0f6853a965@2ndquadrant.com>
	<1646498.1617826937@sss.pgh.pa.us>
	<YG54YggzyPrTFE+e@paquier.xyz>
	<1819824.1617858962@sss.pgh.pa.us>
	<20210408052759.7bmyawm4djnrux6y@alap3.anarazel.de>
	<1820954.1617860500@sss.pgh.pa.us>
	<20210408063514.houn2s3yxcorukdf@alap3.anarazel.de>
	<YG620HiF8Huz/YIn@paquier.xyz>
	<20210408111121.lsh6cvwjgk6ku7m5@nol>
	<2197698.1617984583@sss.pgh.pa.us>
	<20210410033014.GA993491@rfd.leadboat.com>

Noah Misch <noah@leadboat.com> writes:
> On Fri, Apr 09, 2021 at 12:09:43PM -0400, Tom Lane wrote:
>> The real value of 0003 of course would be to get an error cursor at
>> runtime

> A key benefit of $SUBJECT is the function body following DDL renames:

Agreed.  But ...

> After the rename, any stored prosrc is obsolete.  To show accurate error
> cursors, deparse prosqlbody and use that in place of prosrc.

... I'm not sure this conclusion follows.  There are two problems with it:

1. I don't see an acceptably low-overhead way to mechanize it.
Deparsing prosqlbody is unlikely to be safe in a post-error transaction,
but surely we'd not want to expend that cost in advance on every use
of a SQL function.  Even ignoring that, the act of deparsing would not
in itself tell you what offset to use.  Should we deparse and then
re-parse to get a new node tree with corrected token locations?

2. The reason we can get away with showing a fragment of a large query
(or function body) in an error message is that the user is supposed to
be able to correlate the display with what she wrote.  That assumption
falls to the ground if the display is based on a deconstruction that is
virtually certain to have line breaks in different places, not to mention
that the details of what is shown may be substantially different from the
original.

Still, I take your point that the original text may be less useful
for this purpose than I was supposing.

			regards, tom lane





view thread (90+ messages)  latest in thread

Message-ID: <2298215.1618066335@sss.pgh.pa.us>
Permalink:  ../2298215.1618066335@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2298215.1618066335@sss.pgh.pa.us

 · 

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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, noah@leadboat.com, rjuju123@gmail.com, michael@paquier.xyz, andres@anarazel.de, peter.eisentraut@2ndquadrant.com, jcasanov@systemguards.com.ec
  Subject: Re: SQL-standard function body
  In-Reply-To: <2298215.1618066335@sss.pgh.pa.us>
  References: <01c65ea6-e5bf-22f4-cacc-6d0f6853a965@2ndquadrant.com> <1646498.1617826937@sss.pgh.pa.us> <YG54YggzyPrTFE+e@paquier.xyz> <1819824.1617858962@sss.pgh.pa.us> <20210408052759.7bmyawm4djnrux6y@alap3.anarazel.de> <1820954.1617860500@sss.pgh.pa.us> <20210408063514.houn2s3yxcorukdf@alap3.anarazel.de> <YG620HiF8Huz/YIn@paquier.xyz> <20210408111121.lsh6cvwjgk6ku7m5@nol> <2197698.1617984583@sss.pgh.pa.us> <20210410033014.GA993491@rfd.leadboat.com> <2298215.1618066335@sss.pgh.pa.us>

* 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