• Tom Lane's avatar
    Improve regression tests' code coverage for plpgsql control structures. · dd2243f2
    Tom Lane authored
    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
    dd2243f2
plpgsql.sql 116 KB