Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions nix/tests/expected/plpgsql-check.out
Original file line number Diff line number Diff line change
@@ -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()
26 changes: 26 additions & 0 deletions nix/tests/sql/plpgsql-check.sql
Original file line number Diff line number Diff line change
@@ -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;
Loading