File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ for i in range(count):
17
17
t += ( content, )
18
18
return t
19
19
$$ LANGUAGE plpython3u;
20
+ CREATE FUNCTION test_setof_as_set(count integer, content text) RETURNS SETOF text AS $$
21
+ s = set()
22
+ for i in range(count):
23
+ s.add(content * (i + 1) if content is not None else None)
24
+ return s
25
+ $$ LANGUAGE plpython3u;
20
26
CREATE FUNCTION test_setof_as_iterator(count integer, content text) RETURNS SETOF text AS $$
21
27
class producer:
22
28
def __init__ (self, icount, icontent):
@@ -90,6 +96,30 @@ SELECT test_setof_as_tuple(2, null);
90
96
91
97
(2 rows)
92
98
99
+ SELECT * FROM test_setof_as_set(0, 'set') ORDER BY 1;
100
+ test_setof_as_set
101
+ -------------------
102
+ (0 rows)
103
+
104
+ SELECT * FROM test_setof_as_set(1, 'set') ORDER BY 1;
105
+ test_setof_as_set
106
+ -------------------
107
+ set
108
+ (1 row)
109
+
110
+ SELECT * FROM test_setof_as_set(2, 'set') ORDER BY 1;
111
+ test_setof_as_set
112
+ -------------------
113
+ set
114
+ setset
115
+ (2 rows)
116
+
117
+ SELECT * FROM test_setof_as_set(2, null) ORDER BY 1;
118
+ test_setof_as_set
119
+ -------------------
120
+
121
+ (1 row)
122
+
93
123
SELECT test_setof_as_iterator(0, 'list');
94
124
test_setof_as_iterator
95
125
------------------------
Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ for i in range(count):
20
20
return t
21
21
$$ LANGUAGE plpython3u;
22
22
23
+ CREATE FUNCTION test_setof_as_set (count integer , content text ) RETURNS SETOF text AS $$
24
+ s = set ()
25
+ for i in range(count):
26
+ s .add (content * (i + 1 ) if content is not None else None)
27
+ return s
28
+ $$ LANGUAGE plpython3u;
29
+
23
30
CREATE FUNCTION test_setof_as_iterator (count integer , content text ) RETURNS SETOF text AS $$
24
31
class producer:
25
32
def __init__ (self, icount, icontent):
@@ -56,6 +63,11 @@ SELECT test_setof_as_tuple(1, 'tuple');
56
63
SELECT test_setof_as_tuple(2 , ' tuple' );
57
64
SELECT test_setof_as_tuple(2 , null );
58
65
66
+ SELECT * FROM test_setof_as_set(0 , ' set' ) ORDER BY 1 ;
67
+ SELECT * FROM test_setof_as_set(1 , ' set' ) ORDER BY 1 ;
68
+ SELECT * FROM test_setof_as_set(2 , ' set' ) ORDER BY 1 ;
69
+ SELECT * FROM test_setof_as_set(2 , null ) ORDER BY 1 ;
70
+
59
71
SELECT test_setof_as_iterator(0 , ' list' );
60
72
SELECT test_setof_as_iterator(1 , ' list' );
61
73
SELECT test_setof_as_iterator(2 , ' list' );
You can’t perform that action at this time.
0 commit comments