mirror of
https://github.com/postgres/postgres.git
synced 2026-06-05 23:33:01 -04:00
db23464715
Since 19252e8ec9 we reject Python 2 during build configuration. Now that the
dust on the buildfarm has settled, remove regression testing infrastructure
dealing with differing output between Python 2 / 3.
Reviewed-By: Peter Eisentraut <peter@eisentraut.org>
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20211031184548.g4sxfe47n2kyi55r@alap3.anarazel.de
76 lines
1.3 KiB
Plaintext
76 lines
1.3 KiB
Plaintext
--
|
|
-- Tests for procedures / CALL syntax
|
|
--
|
|
CREATE PROCEDURE test_proc1()
|
|
LANGUAGE plpython3u
|
|
AS $$
|
|
pass
|
|
$$;
|
|
CALL test_proc1();
|
|
-- error: can't return non-None
|
|
CREATE PROCEDURE test_proc2()
|
|
LANGUAGE plpython3u
|
|
AS $$
|
|
return 5
|
|
$$;
|
|
CALL test_proc2();
|
|
ERROR: PL/Python procedure did not return None
|
|
CONTEXT: PL/Python procedure "test_proc2"
|
|
CREATE TABLE test1 (a int);
|
|
CREATE PROCEDURE test_proc3(x int)
|
|
LANGUAGE plpython3u
|
|
AS $$
|
|
plpy.execute("INSERT INTO test1 VALUES (%s)" % x)
|
|
$$;
|
|
CALL test_proc3(55);
|
|
SELECT * FROM test1;
|
|
a
|
|
----
|
|
55
|
|
(1 row)
|
|
|
|
-- output arguments
|
|
CREATE PROCEDURE test_proc5(INOUT a text)
|
|
LANGUAGE plpython3u
|
|
AS $$
|
|
return [a + '+' + a]
|
|
$$;
|
|
CALL test_proc5('abc');
|
|
a
|
|
---------
|
|
abc+abc
|
|
(1 row)
|
|
|
|
CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int)
|
|
LANGUAGE plpython3u
|
|
AS $$
|
|
return (b * a, c * a)
|
|
$$;
|
|
CALL test_proc6(2, 3, 4);
|
|
b | c
|
|
---+---
|
|
6 | 8
|
|
(1 row)
|
|
|
|
-- OUT parameters
|
|
CREATE PROCEDURE test_proc9(IN a int, OUT b int)
|
|
LANGUAGE plpython3u
|
|
AS $$
|
|
plpy.notice("a: %s" % (a))
|
|
return (a * 2,)
|
|
$$;
|
|
DO $$
|
|
DECLARE _a int; _b int;
|
|
BEGIN
|
|
_a := 10; _b := 30;
|
|
CALL test_proc9(_a, _b);
|
|
RAISE NOTICE '_a: %, _b: %', _a, _b;
|
|
END
|
|
$$;
|
|
NOTICE: a: 10
|
|
NOTICE: _a: 10, _b: 20
|
|
DROP PROCEDURE test_proc1;
|
|
DROP PROCEDURE test_proc2;
|
|
DROP PROCEDURE test_proc3;
|
|
DROP TABLE test1;
|