pgsql: Improve regression tests' code coverage for plpgsql controlstru - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Improve regression tests' code coverage for plpgsql controlstru
Date
Msg-id E1eVlyI-0000DZ-H3@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Improve regression tests' code coverage for plpgsql control structures.

I noticed that our code coverage report showed considerable deficiency
in test coverage for PL/pgSQL control statements.  Notably, both
exec_stmt_block and most of the loop control statements had very poor
coverage of handling of return/exit/continue result codes from their
child statements; and exec_stmt_fori was seriously lacking in feature
coverage, having no test that exercised its BY or REVERSE features,
nor verification that its overflow defenses work.

Now that we have some infrastructure for plpgsql-specific test scripts,
the natural thing to do is make a new script rather than further extend
plpgsql.sql.  So I created a new script plpgsql_control.sql with the
charter to test plpgsql control structures, and moved a few existing
tests there because they fell entirely under that charter.  I then
added new test cases that exercise the bits of code complained of above.

Of the five kinds of loop statements, only exec_stmt_while's result code
handling is fully exercised by these tests.  That would be a deficiency
as things stand, but a follow-on commit will merge the loop statements'
result code handling into one implementation.  So testing each usage of
that implementation separately seems redundant.

In passing, also add a couple test cases to plpgsql.sql to more fully
exercise plpgsql's code related to expanded arrays --- I had thought
that area was sufficiently covered already, but the coverage report
showed a couple of un-executed code paths.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dd2243f2ade43bcad8e615e6cf4286be250e374a

Modified Files
--------------
src/pl/plpgsql/src/Makefile                     |   2 +-
src/pl/plpgsql/src/expected/plpgsql_control.out | 672 ++++++++++++++++++++++++
src/pl/plpgsql/src/sql/plpgsql_control.sql      | 476 +++++++++++++++++
src/test/regress/expected/plpgsql.out           | 476 +----------------
src/test/regress/sql/plpgsql.sql                | 310 +----------
5 files changed, 1171 insertions(+), 765 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql: Add parallel-aware hash joins.
Next
From: Noah Misch
Date:
Subject: pgsql: In tests, await an LSN no later than the recovery target.