public inbox for [email protected]
help / color / mirror / Atom feedFrom: Pavel Stehule <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: Better error messages for %TYPE and %ROWTYPE in plpgsql
Date: Mon, 26 Feb 2024 21:10:08 +0100
Message-ID: <CAFj8pRCxOPgdaY=x0P8YxMGSn-md6NFQe9b4RFegoNAh1fNDfQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
po 26. 2. 2024 v 21:02 odesÃlatel Tom Lane <[email protected]> napsal:
> Per recent discussion[1], plpgsql returns fairly unhelpful "syntax
> error" messages when a %TYPE or %ROWTYPE construct references a
> nonexistent object. Here's a quick little finger exercise to try
> to improve that.
>
> The basic point is that plpgsql_parse_wordtype and friends are
> designed to return NULL rather than failing (at least when it's
> easy to do so), but that leaves the caller without enough info
> to deliver a good error message. There is only one caller,
> and it has no use at all for this behavior, so let's just
> change those functions to throw appropriate errors. Amusingly,
> plpgsql_parse_wordrowtype was already behaving that way, and
> plpgsql_parse_cwordrowtype did so in more cases than not,
> so we didn't even have a consistent "return NULL" story.
>
> Along the way I got rid of plpgsql_parse_cwordtype's restriction
> on what relkinds can be referenced. I don't really see the
> point of that --- as long as the relation has the desired
> column, the column's type is surely well-defined.
>
+1
Pavel
> regards, tom lane
>
> [1]
> https://www.postgresql.org/message-id/flat/88b574f4-cc08-46c5-826b-020849e5a356%40gelassene-pferde.b...
>
>
view thread (4+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Better error messages for %TYPE and %ROWTYPE in plpgsql
In-Reply-To: <CAFj8pRCxOPgdaY=x0P8YxMGSn-md6NFQe9b4RFegoNAh1fNDfQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox