pgsql: Improve error messages about misuse of SELECT INTO. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Improve error messages about misuse of SELECT INTO.
Date
Msg-id E1mHRtA-0005e5-GF@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Improve error messages about misuse of SELECT INTO.

Improve two places in plpgsql, and one in spi.c, where an error
message would confusingly tell you that you couldn't use a SELECT
query, when what you had written *was* a SELECT query.  The actual
problem is that you can't use SELECT ... INTO in these contexts,
but the messages failed to make that apparent.  Special-case
SELECT INTO to make these errors more helpful.

Also, fix the same spots in plpgsql, as well as several messages
in exec_eval_expr(), to not quote the entire complained-of query or
expression in the primary error message.  That behavior very easily
led to violating our message style guideline about keeping the primary
error message short and single-line.  Also, since the important part
of the message was after the inserted text, it could make the real
problem very hard to see.  We can report the query or expression as
the first line of errcontext instead.

Per complaint from Roger Mason.  Back-patch to v14, since (a) some
of these messages are new in v14 and (b) v14's translatable strings
are still somewhat in flux.  The problem's older than that of
course, but I'm hesitant to change the behavior further back.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/26ae66090398082c54ce046936fc41633dbfc41e

Modified Files
--------------
src/backend/executor/spi.c                    | 10 ++++-
src/pl/plpgsql/src/expected/plpgsql_array.out |  5 ++-
src/pl/plpgsql/src/pl_exec.c                  | 53 ++++++++++++++++++++-------
3 files changed, 51 insertions(+), 17 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql: psql: Add test for query canceling
Next
From: David Rowley
Date:
Subject: pgsql: Allow parallel DISTINCT