pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Add strict_multi_assignment and too_many_rows plpgsql checks
3+ messages / 3 participants
[nested] [flat]
* pgsql: Add strict_multi_assignment and too_many_rows plpgsql checks
@ 2018-07-24 23:47 Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: Tomas Vondra @ 2018-07-24 23:47 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Add strict_multi_assignment and too_many_rows plpgsql checks
Until now shadowed_variables was the only plpgsql check supported by
plpgsql.extra_warnings and plpgsql.extra_errors. This patch introduces
two new checks - strict_multi_assignment and too_many_rows. Unlike
shadowed_variables, these new checks are enforced at run-time.
strict_multi_assignment checks that commands allowing multi-assignment
(for example SELECT INTO) have the same number of sources and targets.
too_many_rows checks that queries with an INTO clause return one row
exactly.
These checks are aimed at cases that are technically valid and allowed,
but are often a sign of a bug. Therefore those checks are expected to
be enabled primarily in development and testing environments.
Author: Pavel Stehule
Reviewed-by: Stephen Frost, Tomas Vondra
Discussion: https://www.postgresql.org/message-id/flat/CAFj8pRA2kKRDKpUNwLY0GeG1OqOp+tLS2yQA1V41gzuSz-hCng@mail....
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/167075be3ab1547e186096bb8e6e448cd8eea5af
Modified Files
--------------
doc/src/sgml/plpgsql.sgml | 115 +++++++++++++++++++++++++++-------
src/pl/plpgsql/src/pl_exec.c | 108 ++++++++++++++++++++++++++++---
src/pl/plpgsql/src/pl_handler.c | 4 ++
src/pl/plpgsql/src/plpgsql.h | 10 +--
src/test/regress/expected/plpgsql.out | 107 +++++++++++++++++++++++++++++++
src/test/regress/sql/plpgsql.sql | 89 ++++++++++++++++++++++++++
6 files changed, 400 insertions(+), 33 deletions(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Add strict_multi_assignment and too_many_rows plpgsql checks
@ 2019-05-09 06:52 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: Tomas Vondra <tomas.vondra@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: Peter Eisentraut @ 2019-05-09 06:52 UTC (permalink / raw)
To: pgsql-hackers <pgsql-hackers@postgresql.org>; Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Tomas Vondra <tomas.vondra@postgresql.org>
On 2018-07-25 01:47, Tomas Vondra wrote:
> Add strict_multi_assignment and too_many_rows plpgsql checks
Could you clarify this error message:
/* translator: %s represents a name of an extra check */
errdetail("%s check of %s is active.",
"strict_multi_assignment",
strict_multiassignment_level == ERROR ? "extra_errors" :
"extra_warnings"),
What does, for example,
strict_multi_assignment check of extra_errors is active.
mean?
Also note that the translator comment is only mentioning one of the %s.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Add strict_multi_assignment and too_many_rows plpgsql checks
@ 2019-05-09 09:12 Pavel Stehule <pavel.stehule@gmail.com>
parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Stehule @ 2019-05-09 09:12 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: pgsql-hackers <pgsql-hackers@postgresql.org>; Tomas Vondra <tomas.vondra@postgresql.org>
Hi
čt 9. 5. 2019 v 8:52 odesílatel Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> napsal:
> On 2018-07-25 01:47, Tomas Vondra wrote:
> > Add strict_multi_assignment and too_many_rows plpgsql checks
>
> Could you clarify this error message:
>
> /* translator: %s represents a name of an extra check */
> errdetail("%s check of %s is active.",
> "strict_multi_assignment",
> strict_multiassignment_level == ERROR ? "extra_errors" :
> "extra_warnings"),
>
> What does, for example,
>
> strict_multi_assignment check of extra_errors is active.
>
> mean?
>
>
strict_multi_assignment is a name of plpgsql extra check. This check checks
number of expressions against number of target variables.
extra checks can produces errors or warnings - so second placeholder
specifies used level.
The sense of this detail's message is a introduce of reason of this error
message.
Regards
Pavel
> Also note that the translator comment is only mentioning one of the %s.
>
> --
> Peter Eisentraut http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-05-09 09:12 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24 23:47 pgsql: Add strict_multi_assignment and too_many_rows plpgsql checks Tomas Vondra <tomas.vondra@postgresql.org>
2019-05-09 06:52 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2019-05-09 09:12 ` Pavel Stehule <pavel.stehule@gmail.com>
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