forked from nextgres/uplpgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplpgsql_misc.sql
More file actions
67 lines (58 loc) · 2.01 KB
/
Copy pathplpgsql_misc.sql
File metadata and controls
67 lines (58 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--
-- Miscellaneous topics
--
-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE
do LANGUAGE uplpgsql $$
declare procedure int; -- check we still recognize non-keywords as vars
begin
create function test1() returns int
begin atomic
select 2 + 2;
end;
create or replace procedure test2(x int)
begin atomic
select x + 2;
end;
end
$$;
\sf test1
\sf test2
-- Test %TYPE and %ROWTYPE error cases
create table misc_table(f1 int);
do LANGUAGE uplpgsql $$ declare x foo%type; begin end $$;
do LANGUAGE uplpgsql $$ declare x notice%type; begin end $$; -- covers unreserved-keyword case
do LANGUAGE uplpgsql $$ declare x foo.bar%type; begin end $$;
do LANGUAGE uplpgsql $$ declare x foo.bar.baz%type; begin end $$;
do LANGUAGE uplpgsql $$ declare x public.foo.bar%type; begin end $$;
do LANGUAGE uplpgsql $$ declare x public.misc_table.zed%type; begin end $$;
do LANGUAGE uplpgsql $$ declare x foo%rowtype; begin end $$;
do LANGUAGE uplpgsql $$ declare x notice%rowtype; begin end $$; -- covers unreserved-keyword case
do LANGUAGE uplpgsql $$ declare x foo.bar%rowtype; begin end $$;
do LANGUAGE uplpgsql $$ declare x foo.bar.baz%rowtype; begin end $$;
do LANGUAGE uplpgsql $$ declare x public.foo%rowtype; begin end $$;
do LANGUAGE uplpgsql $$ declare x public.misc_table%rowtype; begin end $$;
-- Test handling of an unreserved keyword as a variable name
-- and record field name.
do LANGUAGE uplpgsql $$
declare
execute int;
r record;
begin
execute := 10;
raise notice 'execute = %', execute;
select 1 as strict into r;
raise notice 'r.strict = %', r.strict;
end $$;
-- Test handling of a reserved keyword as a record field name.
do LANGUAGE uplpgsql $$ declare r record;
begin
select 1 as x, 2 as foreach into r;
raise notice 'r.x = %', r.x;
raise notice 'r.foreach = %', r.foreach; -- fails
end $$;
do LANGUAGE uplpgsql $$ declare r record;
begin
select 1 as x, 2 as foreach into r;
raise notice 'r.x = %', r.x;
raise notice 'r."foreach" = %', r."foreach"; -- ok
end $$;