summaryrefslogtreecommitdiffstats
path: root/src/pl/plpython/expected/plpython_global.out
blob: a4cfb1483f9c3fb643e2c15f3fa55afb73b3bb26 (plain)
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
--
-- check static and global data (SD and GD)
--
CREATE FUNCTION global_test_one() returns text
    AS
'if "global_test" not in SD:
	SD["global_test"] = "set by global_test_one"
if "global_test" not in GD:
	GD["global_test"] = "set by global_test_one"
return "SD: " + SD["global_test"] + ", GD: " + GD["global_test"]'
    LANGUAGE plpython3u;
CREATE FUNCTION global_test_two() returns text
    AS
'if "global_test" not in SD:
	SD["global_test"] = "set by global_test_two"
if "global_test" not in GD:
	GD["global_test"] = "set by global_test_two"
return "SD: " + SD["global_test"] + ", GD: " + GD["global_test"]'
    LANGUAGE plpython3u;
CREATE FUNCTION static_test() returns int4
    AS
'if "call" in SD:
	SD["call"] = SD["call"] + 1
else:
	SD["call"] = 1
return SD["call"]
'
    LANGUAGE plpython3u;
SELECT static_test();
 static_test 
-------------
           1
(1 row)

SELECT static_test();
 static_test 
-------------
           2
(1 row)

SELECT global_test_one();
                    global_test_one                     
--------------------------------------------------------
 SD: set by global_test_one, GD: set by global_test_one
(1 row)

SELECT global_test_two();
                    global_test_two                     
--------------------------------------------------------
 SD: set by global_test_two, GD: set by global_test_one
(1 row)