From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Thiemo Kellner <thiemo@gelassene-pferde.biz>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: pPL/pgSQL restriction on characters for copying types?
Date: Mon, 26 Feb 2024 13:09:28 -0500
Message-ID: <1822749.1708970968@sss.pgh.pa.us> (raw)
In-Reply-To: <5e173ae9-9494-446a-850f-8d21663cfadf@aklaver.com>
References: <88b574f4-cc08-46c5-826b-020849e5a356@gelassene-pferde.biz>
<1812333.1708965337@sss.pgh.pa.us>
<e928b61b-7bc6-4f9b-bfad-c3bf2d1a7958@gelassene-pferde.biz>
<f2ea15ec-8a01-4032-b82e-3784ee2d24ee@gelassene-pferde.biz>
<5e173ae9-9494-446a-850f-8d21663cfadf@aklaver.com>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 2/26/24 09:30, Thiemo Kellner wrote:
>> Shame on me. My bad. It was the order of installation that did not work.
>> Sorry for that. I was mislead by the error message. If an object is
>> missing I would not expect an invalid type name message.
> For all the code knows it could be just a misspelling.
I think Thiemo's got a point: "invalid type name" isn't the sort
of phrasing we'd normally use. Compare
regression=# select 0::foo;
ERROR: type "foo" does not exist
regression=# create function f() returns foo.bar%type as 'select 1' language sql;
ERROR: relation "foo" does not exist
regression=# create function f() returns void language plpgsql as
$$declare x foo.bar%type; begin end$$;
ERROR: syntax error at or near "%"
LINE 2: $$declare x foo.bar%type; begin end$$;
^
CONTEXT: invalid type name "foo.bar%type"
Digging in the plpgsql code, I notice that there's already a comment
complaining about how this is unhelpful:
* If we have a simple or composite identifier, check for %TYPE and
* %ROWTYPE constructs. (Note that if plpgsql_parse_wordtype et al fail
* to recognize the identifier, we'll fall through and pass the whole
* string to parse_datatype, which will assuredly give an unhelpful
* "syntax error". Should we try to give a more specific error?)
which I believe I wrote not very long ago as part of an unrelated
change (digs ... yeah, see 5e8674dc8). I'd not gone further than that
because the previous behavior was no better, but maybe it's time to
work harder. The main problem is that this code doesn't know whether
the appropriate complaint is about a table not existing or a table
column not existing. Maybe it's okay to let plpgsql_parse_wordtype
etc throw the error for themselves, though.
regards, tom lane
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, thiemo@gelassene-pferde.biz
Subject: Re: pPL/pgSQL restriction on characters for copying types?
In-Reply-To: <1822749.1708970968@sss.pgh.pa.us>
References: <88b574f4-cc08-46c5-826b-020849e5a356@gelassene-pferde.biz> <1812333.1708965337@sss.pgh.pa.us> <e928b61b-7bc6-4f9b-bfad-c3bf2d1a7958@gelassene-pferde.biz> <f2ea15ec-8a01-4032-b82e-3784ee2d24ee@gelassene-pferde.biz> <5e173ae9-9494-446a-850f-8d21663cfadf@aklaver.com> <1822749.1708970968@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