plpython_test.out 4.25 KB
Newer Older
1 2 3 4
-- first some tests of basic functionality
--
-- better succeed
--
Bruce Momjian's avatar
Bruce Momjian committed
5 6 7 8 9 10
select stupid();
 stupid 
--------
 zarkon
(1 row)

11 12
-- check static and global data
--
Bruce Momjian's avatar
Bruce Momjian committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
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)

37 38
-- import python modules
--
Bruce Momjian's avatar
Bruce Momjian committed
39
SELECT import_fail();
40
NOTICE:  ('import socket failed -- No module named foosocket',)
Bruce Momjian's avatar
Bruce Momjian committed
41 42 43 44 45 46 47 48 49 50 51
    import_fail     
--------------------
 failed as expected
(1 row)

SELECT import_succeed();
     import_succeed     
------------------------
 succeeded, as expected
(1 row)

52 53
-- test import and simple argument handling
--
Bruce Momjian's avatar
Bruce Momjian committed
54 55 56 57 58 59
SELECT import_test_one('sha hash of this string');
             import_test_one              
------------------------------------------
 a04e23cb9b1a09cd1051a04a7c571aae0f90346c
(1 row)

60 61
-- test import and tuple argument handling
--
Bruce Momjian's avatar
Bruce Momjian committed
62 63 64 65 66 67
select import_test_two(users) from users where fname = 'willem';
                          import_test_two                          
-------------------------------------------------------------------
 sha hash of willemdoe is 3cde6b574953b0ca937b4d76ebc40d534d910759
(1 row)

68 69
-- test multiple arguments
--
70
select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1;
71 72 73 74 75
                           argument_test_one                           
-----------------------------------------------------------------------
 jane doe => {fname: jane, lname: doe, userid: 1, username: j_doe}
 john doe => {fname: john, lname: doe, userid: 2, username: johnd}
 willem doe => {fname: willem, lname: doe, userid: 3, username: w_doe}
Bruce Momjian's avatar
Bruce Momjian committed
76 77
(3 rows)

78 79
-- spi and nested calls
--
Bruce Momjian's avatar
Bruce Momjian committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
select nested_call_one('pass this along');
                         nested_call_one                         
-----------------------------------------------------------------
 {'nested_call_two': "{'nested_call_three': 'pass this along'}"}
(1 row)

select spi_prepared_plan_test_one('doe');
 spi_prepared_plan_test_one 
----------------------------
 there are 3 does
(1 row)

select spi_prepared_plan_test_one('smith');
 spi_prepared_plan_test_one 
----------------------------
 there are 1 smiths
(1 row)

select spi_prepared_plan_test_nested('smith');
 spi_prepared_plan_test_nested 
-------------------------------
 there are 1 smiths
(1 row)

104 105
-- quick peek at the table
--
Bruce Momjian's avatar
Bruce Momjian committed
106 107 108 109 110 111 112 113 114
SELECT * FROM users;
 fname  | lname | username | userid 
--------+-------+----------+--------
 jane   | doe   | j_doe    |      1
 john   | doe   | johnd    |      2
 willem | doe   | w_doe    |      3
 rick   | smith | slash    |      4
(4 rows)

115 116
-- should fail
--
Bruce Momjian's avatar
Bruce Momjian committed
117
UPDATE users SET fname = 'william' WHERE fname = 'willem';
118 119
-- should modify william to willem and create username
--
Bruce Momjian's avatar
Bruce Momjian committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
INSERT INTO users (fname, lname) VALUES ('william', 'smith');
INSERT INTO users (fname, lname, username) VALUES ('charles', 'darwin', 'beagle');
SELECT * FROM users;
  fname  | lname  | username | userid 
---------+--------+----------+--------
 jane    | doe    | j_doe    |      1
 john    | doe    | johnd    |      2
 willem  | doe    | w_doe    |      3
 rick    | smith  | slash    |      4
 willem  | smith  | w_smith  |      5
 charles | darwin | beagle   |      6
(6 rows)

SELECT join_sequences(sequences) FROM sequences;
 join_sequences 
----------------
 ABCDEFGHIJKL
 ABCDEF
 ABCDEF
 ABCDEF
 ABCDEF
 ABCDEF
(6 rows)

SELECT join_sequences(sequences) FROM sequences
	WHERE join_sequences(sequences) ~* '^A';
 join_sequences 
----------------
 ABCDEFGHIJKL
 ABCDEF
 ABCDEF
 ABCDEF
 ABCDEF
 ABCDEF
(6 rows)

SELECT join_sequences(sequences) FROM sequences
	WHERE join_sequences(sequences) ~* '^B';
 join_sequences 
----------------
(0 rows)

162 163 164 165 166
-- error in trigger
--
--
-- Check Universal Newline Support
--
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
SELECT newline_lf();
 newline_lf 
------------
        123
(1 row)

SELECT newline_cr();
 newline_cr 
------------
        123
(1 row)

SELECT newline_crlf();
 newline_crlf 
--------------
          123
(1 row)