-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsrf.sql
More file actions
55 lines (48 loc) · 1.25 KB
/
srf.sql
File metadata and controls
55 lines (48 loc) · 1.25 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
-- Check that compensation is properly working.
CREATE OR REPLACE FUNCTION just_one() RETURNS int
LANGUAGE python AS
$python$
def main():
return 1
$python$;
SELECT * FROM just_one() AS g(i) LIMIT 0;
SELECT * FROM just_one() AS g(i);
CREATE OR REPLACE FUNCTION one_two_three() RETURNS SETOF int
LANGUAGE python AS
$python$
def main():
return (1,2,3)
$python$;
SELECT one_two_three();
SELECT one_two_three() LIMIT 2;
SELECT * FROM one_two_three();
SELECT * FROM one_two_three() LIMIT 2;
CREATE OR REPLACE FUNCTION one_two_three_records(OUT i int, OUT k text) RETURNS SETOF RECORD
LANGUAGE python AS
$python$
def main():
return (
(1,'one'),
(2,'two'),
(3,'three'),
)
$python$;
SELECT one_two_three_records();
SELECT one_two_three_records() LIMIT 2;
SELECT * FROM one_two_three_records();
SELECT * FROM one_two_three_records() LIMIT 2;
CREATE OR REPLACE FUNCTION one_two_three_records_d(OUT i int, OUT k text) RETURNS SETOF RECORD
LANGUAGE python AS
$python$
def main():
return (
dict(i = 1, k = 'one'),
dict(i = 2, k = 'two'),
dict(i = 3, k = 'three'),
dict(i = 4, k = None),
)
$python$;
SELECT one_two_three_records_d();
SELECT one_two_three_records_d() LIMIT 2;
SELECT * FROM one_two_three_records_d();
SELECT * FROM one_two_three_records_d() LIMIT 2;