mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-23 23:07:15 +08:00
1) pltcl: Add SPI_freetuptable() calls to avoid memory leaks (Me + Neil Conway) Change sprintf()s to snprintf()s (Neil Conway) Remove header files included elsewhere (Neil Conway) 2)plpython: Add SPI_freetuptable() calls to avoid memory leaks Cosemtic change to remove a compiler warning Notes: I have tested pltcl.c for a) the original leak problem reported for the repeated call of spi_exec in a TCL fragment and b) the subsequent report resulting from the use of spi_exec -array in a TCL fragment. The plpython.c patch is exactly the same as that applied to make revision 1.23, the plpython_schema.sql and feature.expected sections of the patch are also the same as last submited, applied and subsequently reversed out. It remains untested by me (other than via make check). However, this should be safe provided PyString_FromString() _copies_ the given string to make a PyObject. Nigel J. Andrews
140 lines
3.7 KiB
Plaintext
140 lines
3.7 KiB
Plaintext
select stupid();
|
|
stupid
|
|
--------
|
|
zarkon
|
|
(1 row)
|
|
|
|
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)
|
|
|
|
SELECT import_fail();
|
|
NOTICE: ('import socket failed -- untrusted dynamic module: _socket',)
|
|
import_fail
|
|
--------------------
|
|
failed as expected
|
|
(1 row)
|
|
|
|
SELECT import_succeed();
|
|
import_succeed
|
|
------------------------
|
|
succeeded, as expected
|
|
(1 row)
|
|
|
|
SELECT import_test_one('sha hash of this string');
|
|
import_test_one
|
|
------------------------------------------
|
|
a04e23cb9b1a09cd1051a04a7c571aae0f90346c
|
|
(1 row)
|
|
|
|
select import_test_two(users) from users where fname = 'willem';
|
|
import_test_two
|
|
-------------------------------------------------------------------
|
|
sha hash of willemdoe is 3cde6b574953b0ca937b4d76ebc40d534d910759
|
|
(1 row)
|
|
|
|
select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1;
|
|
argument_test_one
|
|
-------------------------------------------------------------------------------------
|
|
jane doe => {'fname': 'jane', 'userid': 1, 'lname': 'doe', 'username': 'j_doe'}
|
|
john doe => {'fname': 'john', 'userid': 2, 'lname': 'doe', 'username': 'johnd'}
|
|
willem doe => {'fname': 'willem', 'userid': 3, 'lname': 'doe', 'username': 'w_doe'}
|
|
(3 rows)
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
UPDATE users SET fname = 'william' WHERE fname = 'willem';
|
|
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)
|
|
|