Skip to content

Commit 482b88a

Browse files
committed
add plpgsql-check test
1 parent aadd726 commit 482b88a

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
create schema v;
2+
create table v.t1(
3+
a int,
4+
b int
5+
);
6+
create or replace function v.f1()
7+
returns void
8+
language plpgsql
9+
as $$
10+
declare r record;
11+
begin
12+
for r in select * from v.t1
13+
loop
14+
raise notice '%', r.c; -- there is bug - table t1 missing "c" column
15+
end loop;
16+
end;
17+
$$;
18+
select * from v.f1();
19+
f1
20+
----
21+
22+
(1 row)
23+
24+
-- use plpgsql_check_function to check the function for errors
25+
select * from plpgsql_check_function('v.f1()');
26+
plpgsql_check_function
27+
-------------------------------------------------
28+
error:42703:6:RAISE:record "r" has no field "c"
29+
Context: SQL expression "r.c"
30+
(2 rows)
31+

nix/tests/sql/plpgsql-check.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
create schema v;
2+
3+
create table v.t1(
4+
a int,
5+
b int
6+
);
7+
8+
create or replace function v.f1()
9+
returns void
10+
language plpgsql
11+
as $$
12+
declare r record;
13+
begin
14+
for r in select * from v.t1
15+
loop
16+
raise notice '%', r.c; -- there is bug - table t1 missing "c" column
17+
end loop;
18+
end;
19+
$$;
20+
21+
select * from v.f1();
22+
23+
-- use plpgsql_check_function to check the function for errors
24+
select * from plpgsql_check_function('v.f1()');

0 commit comments

Comments
 (0)