This commit is contained in:
Peter Eisentraut 2018-02-12 13:47:18 -05:00
parent b4e2ada347
commit a7b8f0661d
2 changed files with 115 additions and 115 deletions

View File

@ -69,124 +69,124 @@ SELECT proname, provolatile FROM pg_proc
-- --
-- SECURITY DEFINER | INVOKER -- SECURITY DEFINER | INVOKER
-- --
CREATE FUNCTION functext_C_1(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
AS 'SELECT $1 > 0'; AS 'SELECT $1 > 0';
CREATE FUNCTION functext_C_2(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
SECURITY DEFINER AS 'SELECT $1 = 0'; SECURITY DEFINER AS 'SELECT $1 = 0';
CREATE FUNCTION functext_C_3(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
SECURITY INVOKER AS 'SELECT $1 < 0'; SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functext_C_1'::regproc, WHERE oid in ('functest_C_1'::regproc,
'functext_C_2'::regproc, 'functest_C_2'::regproc,
'functext_C_3'::regproc) ORDER BY proname; 'functest_C_3'::regproc) ORDER BY proname;
proname | prosecdef proname | prosecdef
--------------+----------- --------------+-----------
functext_c_1 | f functest_c_1 | f
functext_c_2 | t functest_c_2 | t
functext_c_3 | f functest_c_3 | f
(3 rows) (3 rows)
ALTER FUNCTION functext_C_1(int) IMMUTABLE; -- unrelated change, no effect ALTER FUNCTION functest_C_1(int) IMMUTABLE; -- unrelated change, no effect
ALTER FUNCTION functext_C_2(int) SECURITY INVOKER; ALTER FUNCTION functest_C_2(int) SECURITY INVOKER;
ALTER FUNCTION functext_C_3(int) SECURITY DEFINER; ALTER FUNCTION functest_C_3(int) SECURITY DEFINER;
SELECT proname, prosecdef FROM pg_proc SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functext_C_1'::regproc, WHERE oid in ('functest_C_1'::regproc,
'functext_C_2'::regproc, 'functest_C_2'::regproc,
'functext_C_3'::regproc) ORDER BY proname; 'functest_C_3'::regproc) ORDER BY proname;
proname | prosecdef proname | prosecdef
--------------+----------- --------------+-----------
functext_c_1 | f functest_c_1 | f
functext_c_2 | f functest_c_2 | f
functext_c_3 | t functest_c_3 | t
(3 rows) (3 rows)
-- --
-- LEAKPROOF -- LEAKPROOF
-- --
CREATE FUNCTION functext_E_1(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
AS 'SELECT $1 > 100'; AS 'SELECT $1 > 100';
CREATE FUNCTION functext_E_2(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
LEAKPROOF AS 'SELECT $1 > 100'; LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functext_E_1'::regproc, WHERE oid in ('functest_E_1'::regproc,
'functext_E_2'::regproc) ORDER BY proname; 'functest_E_2'::regproc) ORDER BY proname;
proname | proleakproof proname | proleakproof
--------------+-------------- --------------+--------------
functext_e_1 | f functest_e_1 | f
functext_e_2 | t functest_e_2 | t
(2 rows) (2 rows)
ALTER FUNCTION functext_E_1(int) LEAKPROOF; ALTER FUNCTION functest_E_1(int) LEAKPROOF;
ALTER FUNCTION functext_E_2(int) STABLE; -- unrelated change, no effect ALTER FUNCTION functest_E_2(int) STABLE; -- unrelated change, no effect
SELECT proname, proleakproof FROM pg_proc SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functext_E_1'::regproc, WHERE oid in ('functest_E_1'::regproc,
'functext_E_2'::regproc) ORDER BY proname; 'functest_E_2'::regproc) ORDER BY proname;
proname | proleakproof proname | proleakproof
--------------+-------------- --------------+--------------
functext_e_1 | t functest_e_1 | t
functext_e_2 | t functest_e_2 | t
(2 rows) (2 rows)
ALTER FUNCTION functext_E_2(int) NOT LEAKPROOF; -- remove leakproog attribute ALTER FUNCTION functest_E_2(int) NOT LEAKPROOF; -- remove leakproog attribute
SELECT proname, proleakproof FROM pg_proc SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functext_E_1'::regproc, WHERE oid in ('functest_E_1'::regproc,
'functext_E_2'::regproc) ORDER BY proname; 'functest_E_2'::regproc) ORDER BY proname;
proname | proleakproof proname | proleakproof
--------------+-------------- --------------+--------------
functext_e_1 | t functest_e_1 | t
functext_e_2 | f functest_e_2 | f
(2 rows) (2 rows)
-- it takes superuser privilege to turn on leakproof, but not for turn off -- it takes superuser privilege to turn on leakproof, but not for turn off
ALTER FUNCTION functext_E_1(int) OWNER TO regress_unpriv_user; ALTER FUNCTION functest_E_1(int) OWNER TO regress_unpriv_user;
ALTER FUNCTION functext_E_2(int) OWNER TO regress_unpriv_user; ALTER FUNCTION functest_E_2(int) OWNER TO regress_unpriv_user;
SET SESSION AUTHORIZATION regress_unpriv_user; SET SESSION AUTHORIZATION regress_unpriv_user;
SET search_path TO temp_func_test, public; SET search_path TO temp_func_test, public;
ALTER FUNCTION functext_E_1(int) NOT LEAKPROOF; ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functext_E_2(int) LEAKPROOF; ALTER FUNCTION functest_E_2(int) LEAKPROOF;
ERROR: only superuser can define a leakproof function ERROR: only superuser can define a leakproof function
CREATE FUNCTION functext_E_3(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
LEAKPROOF AS 'SELECT $1 < 200'; -- failed LEAKPROOF AS 'SELECT $1 < 200'; -- failed
ERROR: only superuser can define a leakproof function ERROR: only superuser can define a leakproof function
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
-- --
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT -- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
-- --
CREATE FUNCTION functext_F_1(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
AS 'SELECT $1 > 50'; AS 'SELECT $1 > 50';
CREATE FUNCTION functext_F_2(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
CALLED ON NULL INPUT AS 'SELECT $1 = 50'; CALLED ON NULL INPUT AS 'SELECT $1 = 50';
CREATE FUNCTION functext_F_3(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50'; RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
CREATE FUNCTION functext_F_4(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
STRICT AS 'SELECT $1 = 50'; STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functext_F_1'::regproc, WHERE oid in ('functest_F_1'::regproc,
'functext_F_2'::regproc, 'functest_F_2'::regproc,
'functext_F_3'::regproc, 'functest_F_3'::regproc,
'functext_F_4'::regproc) ORDER BY proname; 'functest_F_4'::regproc) ORDER BY proname;
proname | proisstrict proname | proisstrict
--------------+------------- --------------+-------------
functext_f_1 | f functest_f_1 | f
functext_f_2 | f functest_f_2 | f
functext_f_3 | t functest_f_3 | t
functext_f_4 | t functest_f_4 | t
(4 rows) (4 rows)
ALTER FUNCTION functext_F_1(int) IMMUTABLE; -- unrelated change, no effect ALTER FUNCTION functest_F_1(int) IMMUTABLE; -- unrelated change, no effect
ALTER FUNCTION functext_F_2(int) STRICT; ALTER FUNCTION functest_F_2(int) STRICT;
ALTER FUNCTION functext_F_3(int) CALLED ON NULL INPUT; ALTER FUNCTION functest_F_3(int) CALLED ON NULL INPUT;
SELECT proname, proisstrict FROM pg_proc SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functext_F_1'::regproc, WHERE oid in ('functest_F_1'::regproc,
'functext_F_2'::regproc, 'functest_F_2'::regproc,
'functext_F_3'::regproc, 'functest_F_3'::regproc,
'functext_F_4'::regproc) ORDER BY proname; 'functest_F_4'::regproc) ORDER BY proname;
proname | proisstrict proname | proisstrict
--------------+------------- --------------+-------------
functext_f_1 | f functest_f_1 | f
functext_f_2 | t functest_f_2 | t
functext_f_3 | f functest_f_3 | f
functext_f_4 | t functest_f_4 | t
(4 rows) (4 rows)
-- information_schema tests -- information_schema tests
@ -236,15 +236,15 @@ drop cascades to function functest_a_3()
drop cascades to function functest_b_2(integer) drop cascades to function functest_b_2(integer)
drop cascades to function functest_b_3(integer) drop cascades to function functest_b_3(integer)
drop cascades to function functest_b_4(integer) drop cascades to function functest_b_4(integer)
drop cascades to function functext_c_1(integer) drop cascades to function functest_c_1(integer)
drop cascades to function functext_c_2(integer) drop cascades to function functest_c_2(integer)
drop cascades to function functext_c_3(integer) drop cascades to function functest_c_3(integer)
drop cascades to function functext_e_1(integer) drop cascades to function functest_e_1(integer)
drop cascades to function functext_e_2(integer) drop cascades to function functest_e_2(integer)
drop cascades to function functext_f_1(integer) drop cascades to function functest_f_1(integer)
drop cascades to function functext_f_2(integer) drop cascades to function functest_f_2(integer)
drop cascades to function functext_f_3(integer) drop cascades to function functest_f_3(integer)
drop cascades to function functext_f_4(integer) drop cascades to function functest_f_4(integer)
drop cascades to function functest_b_2(bigint) drop cascades to function functest_b_2(bigint)
DROP USER regress_unpriv_user; DROP USER regress_unpriv_user;
RESET search_path; RESET search_path;

View File

@ -52,57 +52,57 @@ SELECT proname, provolatile FROM pg_proc
-- --
-- SECURITY DEFINER | INVOKER -- SECURITY DEFINER | INVOKER
-- --
CREATE FUNCTION functext_C_1(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
AS 'SELECT $1 > 0'; AS 'SELECT $1 > 0';
CREATE FUNCTION functext_C_2(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
SECURITY DEFINER AS 'SELECT $1 = 0'; SECURITY DEFINER AS 'SELECT $1 = 0';
CREATE FUNCTION functext_C_3(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
SECURITY INVOKER AS 'SELECT $1 < 0'; SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functext_C_1'::regproc, WHERE oid in ('functest_C_1'::regproc,
'functext_C_2'::regproc, 'functest_C_2'::regproc,
'functext_C_3'::regproc) ORDER BY proname; 'functest_C_3'::regproc) ORDER BY proname;
ALTER FUNCTION functext_C_1(int) IMMUTABLE; -- unrelated change, no effect ALTER FUNCTION functest_C_1(int) IMMUTABLE; -- unrelated change, no effect
ALTER FUNCTION functext_C_2(int) SECURITY INVOKER; ALTER FUNCTION functest_C_2(int) SECURITY INVOKER;
ALTER FUNCTION functext_C_3(int) SECURITY DEFINER; ALTER FUNCTION functest_C_3(int) SECURITY DEFINER;
SELECT proname, prosecdef FROM pg_proc SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functext_C_1'::regproc, WHERE oid in ('functest_C_1'::regproc,
'functext_C_2'::regproc, 'functest_C_2'::regproc,
'functext_C_3'::regproc) ORDER BY proname; 'functest_C_3'::regproc) ORDER BY proname;
-- --
-- LEAKPROOF -- LEAKPROOF
-- --
CREATE FUNCTION functext_E_1(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
AS 'SELECT $1 > 100'; AS 'SELECT $1 > 100';
CREATE FUNCTION functext_E_2(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
LEAKPROOF AS 'SELECT $1 > 100'; LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functext_E_1'::regproc, WHERE oid in ('functest_E_1'::regproc,
'functext_E_2'::regproc) ORDER BY proname; 'functest_E_2'::regproc) ORDER BY proname;
ALTER FUNCTION functext_E_1(int) LEAKPROOF; ALTER FUNCTION functest_E_1(int) LEAKPROOF;
ALTER FUNCTION functext_E_2(int) STABLE; -- unrelated change, no effect ALTER FUNCTION functest_E_2(int) STABLE; -- unrelated change, no effect
SELECT proname, proleakproof FROM pg_proc SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functext_E_1'::regproc, WHERE oid in ('functest_E_1'::regproc,
'functext_E_2'::regproc) ORDER BY proname; 'functest_E_2'::regproc) ORDER BY proname;
ALTER FUNCTION functext_E_2(int) NOT LEAKPROOF; -- remove leakproog attribute ALTER FUNCTION functest_E_2(int) NOT LEAKPROOF; -- remove leakproog attribute
SELECT proname, proleakproof FROM pg_proc SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functext_E_1'::regproc, WHERE oid in ('functest_E_1'::regproc,
'functext_E_2'::regproc) ORDER BY proname; 'functest_E_2'::regproc) ORDER BY proname;
-- it takes superuser privilege to turn on leakproof, but not for turn off -- it takes superuser privilege to turn on leakproof, but not for turn off
ALTER FUNCTION functext_E_1(int) OWNER TO regress_unpriv_user; ALTER FUNCTION functest_E_1(int) OWNER TO regress_unpriv_user;
ALTER FUNCTION functext_E_2(int) OWNER TO regress_unpriv_user; ALTER FUNCTION functest_E_2(int) OWNER TO regress_unpriv_user;
SET SESSION AUTHORIZATION regress_unpriv_user; SET SESSION AUTHORIZATION regress_unpriv_user;
SET search_path TO temp_func_test, public; SET search_path TO temp_func_test, public;
ALTER FUNCTION functext_E_1(int) NOT LEAKPROOF; ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functext_E_2(int) LEAKPROOF; ALTER FUNCTION functest_E_2(int) LEAKPROOF;
CREATE FUNCTION functext_E_3(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
LEAKPROOF AS 'SELECT $1 < 200'; -- failed LEAKPROOF AS 'SELECT $1 < 200'; -- failed
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
@ -110,28 +110,28 @@ RESET SESSION AUTHORIZATION;
-- --
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT -- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
-- --
CREATE FUNCTION functext_F_1(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
AS 'SELECT $1 > 50'; AS 'SELECT $1 > 50';
CREATE FUNCTION functext_F_2(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
CALLED ON NULL INPUT AS 'SELECT $1 = 50'; CALLED ON NULL INPUT AS 'SELECT $1 = 50';
CREATE FUNCTION functext_F_3(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50'; RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
CREATE FUNCTION functext_F_4(int) RETURNS bool LANGUAGE 'sql' CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
STRICT AS 'SELECT $1 = 50'; STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functext_F_1'::regproc, WHERE oid in ('functest_F_1'::regproc,
'functext_F_2'::regproc, 'functest_F_2'::regproc,
'functext_F_3'::regproc, 'functest_F_3'::regproc,
'functext_F_4'::regproc) ORDER BY proname; 'functest_F_4'::regproc) ORDER BY proname;
ALTER FUNCTION functext_F_1(int) IMMUTABLE; -- unrelated change, no effect ALTER FUNCTION functest_F_1(int) IMMUTABLE; -- unrelated change, no effect
ALTER FUNCTION functext_F_2(int) STRICT; ALTER FUNCTION functest_F_2(int) STRICT;
ALTER FUNCTION functext_F_3(int) CALLED ON NULL INPUT; ALTER FUNCTION functest_F_3(int) CALLED ON NULL INPUT;
SELECT proname, proisstrict FROM pg_proc SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functext_F_1'::regproc, WHERE oid in ('functest_F_1'::regproc,
'functext_F_2'::regproc, 'functest_F_2'::regproc,
'functext_F_3'::regproc, 'functest_F_3'::regproc,
'functext_F_4'::regproc) ORDER BY proname; 'functest_F_4'::regproc) ORDER BY proname;
-- information_schema tests -- information_schema tests