diff --git a/nix/tests/expected/plpgsql-check.out b/nix/tests/expected/plpgsql-check.out new file mode 100644 index 000000000..2b5bf8287 --- /dev/null +++ b/nix/tests/expected/plpgsql-check.out @@ -0,0 +1,35 @@ +create schema v; +create table v.t1( + a int, + b int +); +create or replace function v.f1() + returns void + language plpgsql +as $$ +declare r record; +begin + for r in select * from v.t1 + loop + raise notice '%', r.c; -- there is bug - table t1 missing "c" column + end loop; +end; +$$; +select * from v.f1(); + f1 +---- + +(1 row) + +-- use plpgsql_check_function to check the function for errors +select * from plpgsql_check_function('v.f1()'); + plpgsql_check_function +------------------------------------------------- + error:42703:6:RAISE:record "r" has no field "c" + Context: SQL expression "r.c" +(2 rows) + +drop schema v cascade; +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to table v.t1 +drop cascades to function v.f1() diff --git a/nix/tests/sql/plpgsql-check.sql b/nix/tests/sql/plpgsql-check.sql new file mode 100644 index 000000000..d54d2c45e --- /dev/null +++ b/nix/tests/sql/plpgsql-check.sql @@ -0,0 +1,26 @@ +create schema v; + +create table v.t1( + a int, + b int +); + +create or replace function v.f1() + returns void + language plpgsql +as $$ +declare r record; +begin + for r in select * from v.t1 + loop + raise notice '%', r.c; -- there is bug - table t1 missing "c" column + end loop; +end; +$$; + +select * from v.f1(); + +-- use plpgsql_check_function to check the function for errors +select * from plpgsql_check_function('v.f1()'); + +drop schema v cascade;