]> granicus.if.org Git - postgresql/blob - src/pl/plpython/expected/plpython_test.out
92243738f6690dbf7f562475cfce066df4430dd4
[postgresql] / src / pl / plpython / expected / plpython_test.out
1 -- first some tests of basic functionality
2 --
3 -- better succeed
4 --
5 select stupid();
6  stupid 
7 --------
8  zarkon
9 (1 row)
10
11 -- check static and global data
12 --
13 SELECT static_test();
14  static_test 
15 -------------
16            1
17 (1 row)
18
19 SELECT static_test();
20  static_test 
21 -------------
22            2
23 (1 row)
24
25 SELECT global_test_one();
26                     global_test_one                     
27 --------------------------------------------------------
28  SD: set by global_test_one, GD: set by global_test_one
29 (1 row)
30
31 SELECT global_test_two();
32                     global_test_two                     
33 --------------------------------------------------------
34  SD: set by global_test_two, GD: set by global_test_one
35 (1 row)
36
37 -- import python modules
38 --
39 SELECT import_fail();
40 NOTICE:  ('import socket failed -- No module named foosocket',)
41     import_fail     
42 --------------------
43  failed as expected
44 (1 row)
45
46 SELECT import_succeed();
47      import_succeed     
48 ------------------------
49  succeeded, as expected
50 (1 row)
51
52 -- test import and simple argument handling
53 --
54 SELECT import_test_one('sha hash of this string');
55              import_test_one              
56 ------------------------------------------
57  a04e23cb9b1a09cd1051a04a7c571aae0f90346c
58 (1 row)
59
60 -- test import and tuple argument handling
61 --
62 select import_test_two(users) from users where fname = 'willem';
63                           import_test_two                          
64 -------------------------------------------------------------------
65  sha hash of willemdoe is 3cde6b574953b0ca937b4d76ebc40d534d910759
66 (1 row)
67
68 -- test multiple arguments
69 --
70 select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1;
71                            argument_test_one                           
72 -----------------------------------------------------------------------
73  jane doe => {fname: jane, lname: doe, userid: 1, username: j_doe}
74  john doe => {fname: john, lname: doe, userid: 2, username: johnd}
75  willem doe => {fname: willem, lname: doe, userid: 3, username: w_doe}
76 (3 rows)
77
78 -- spi and nested calls
79 --
80 select nested_call_one('pass this along');
81                          nested_call_one                         
82 -----------------------------------------------------------------
83  {'nested_call_two': "{'nested_call_three': 'pass this along'}"}
84 (1 row)
85
86 select spi_prepared_plan_test_one('doe');
87  spi_prepared_plan_test_one 
88 ----------------------------
89  there are 3 does
90 (1 row)
91
92 select spi_prepared_plan_test_one('smith');
93  spi_prepared_plan_test_one 
94 ----------------------------
95  there are 1 smiths
96 (1 row)
97
98 select spi_prepared_plan_test_nested('smith');
99  spi_prepared_plan_test_nested 
100 -------------------------------
101  there are 1 smiths
102 (1 row)
103
104 -- quick peek at the table
105 --
106 SELECT * FROM users;
107  fname  | lname | username | userid 
108 --------+-------+----------+--------
109  jane   | doe   | j_doe    |      1
110  john   | doe   | johnd    |      2
111  willem | doe   | w_doe    |      3
112  rick   | smith | slash    |      4
113 (4 rows)
114
115 -- should fail
116 --
117 UPDATE users SET fname = 'william' WHERE fname = 'willem';
118 -- should modify william to willem and create username
119 --
120 INSERT INTO users (fname, lname) VALUES ('william', 'smith');
121 INSERT INTO users (fname, lname, username) VALUES ('charles', 'darwin', 'beagle');
122 SELECT * FROM users;
123   fname  | lname  | username | userid 
124 ---------+--------+----------+--------
125  jane    | doe    | j_doe    |      1
126  john    | doe    | johnd    |      2
127  willem  | doe    | w_doe    |      3
128  rick    | smith  | slash    |      4
129  willem  | smith  | w_smith  |      5
130  charles | darwin | beagle   |      6
131 (6 rows)
132
133 SELECT join_sequences(sequences) FROM sequences;
134  join_sequences 
135 ----------------
136  ABCDEFGHIJKL
137  ABCDEF
138  ABCDEF
139  ABCDEF
140  ABCDEF
141  ABCDEF
142 (6 rows)
143
144 SELECT join_sequences(sequences) FROM sequences
145         WHERE join_sequences(sequences) ~* '^A';
146  join_sequences 
147 ----------------
148  ABCDEFGHIJKL
149  ABCDEF
150  ABCDEF
151  ABCDEF
152  ABCDEF
153  ABCDEF
154 (6 rows)
155
156 SELECT join_sequences(sequences) FROM sequences
157         WHERE join_sequences(sequences) ~* '^B';
158  join_sequences 
159 ----------------
160 (0 rows)
161
162 -- error in trigger
163 --
164 --
165 -- Check Universal Newline Support
166 --
167 SELECT newline_lf();
168  newline_lf 
169 ------------
170         123
171 (1 row)
172
173 SELECT newline_cr();
174  newline_cr 
175 ------------
176         123
177 (1 row)
178
179 SELECT newline_crlf();
180  newline_crlf 
181 --------------
182           123
183 (1 row)
184
185 -- Tests for functions returning void
186 SELECT test_void_func1(), test_void_func1() IS NULL AS "is null";
187  test_void_func1 | is null 
188 -----------------+---------
189                  | f
190 (1 row)
191
192 SELECT test_void_func2(); -- should fail
193 ERROR:  unexpected return value from plpython procedure
194 DETAIL:  void-returning functions must return "None"
195 SELECT test_return_none(), test_return_none() IS NULL AS "is null";
196  test_return_none | is null 
197 ------------------+---------
198                   | t
199 (1 row)
200