format_plpgsql() has the silent-drop defect that #58 fixed for SQL. The guard added in #59 never exercises it, since CREATE FUNCTION re-lays out a body rather than formatting it. Run over the 41 PL/pgSQL bodies in the PostgreSQL 19 documentation corpus, 5 lose content in every style:
| Dropped |
Example |
| Block labels |
<<outerblock>> DECLARE ... BEGIN ... END loses <<outerblock>>, so EXIT outerblock / outerblock.quantity name a block that no longer exists |
| Compiler directives |
#variable_conflict use_variable, #print_strict_params on |
| A bound cursor's query |
referrer_keys CURSOR IS SELECT * FROM cs_referrer_keys ORDER BY try_order; loses the whole query |
One further body is not a fixed point (a second pass changes it).
Separately, one body fails to parse: OPEN $1 FOR SELECT * FROM table_1; (a positional parameter as the cursor variable). That is valid PL/pgSQL rejected by the tree-sitter-postgres grammar, so it is an upstream grammar gap rather than a libpgfmt bug.
Fix
- Render the label, directive and cursor-query nodes in the PL/pgSQL formatter.
- Extend
tests/token_loss_test.rs to run format_plpgsql() over the corpus's PL/pgSQL bodies with the same three checks (no token loss, output re-parses, fixed point), so this class is covered.
format_plpgsql()has the silent-drop defect that #58 fixed for SQL. The guard added in #59 never exercises it, sinceCREATE FUNCTIONre-lays out a body rather than formatting it. Run over the 41 PL/pgSQL bodies in the PostgreSQL 19 documentation corpus, 5 lose content in every style:<<outerblock>> DECLARE ... BEGIN ... ENDloses<<outerblock>>, soEXIT outerblock/outerblock.quantityname a block that no longer exists#variable_conflict use_variable,#print_strict_params onreferrer_keys CURSOR IS SELECT * FROM cs_referrer_keys ORDER BY try_order;loses the whole queryOne further body is not a fixed point (a second pass changes it).
Separately, one body fails to parse:
OPEN $1 FOR SELECT * FROM table_1;(a positional parameter as the cursor variable). That is valid PL/pgSQL rejected by the tree-sitter-postgres grammar, so it is an upstream grammar gap rather than a libpgfmt bug.Fix
tests/token_loss_test.rsto runformat_plpgsql()over the corpus's PL/pgSQL bodies with the same three checks (no token loss, output re-parses, fixed point), so this class is covered.