From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Better error messages for %TYPE and %ROWTYPE in plpgsql |
Date: | 2024-02-26 20:02:20 |
Message-ID: | 1964516.1708977740@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
v1-improve-percent-type-errors.patch | text/x-diff | 9.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2024-02-26 20:10:08 | Re: Better error messages for %TYPE and %ROWTYPE in plpgsql |
Previous Message | Jeff Davis | 2024-02-26 19:55:58 | Re: Comments on Custom RMGRs |