137 lines
5.1 KiB
Plaintext
137 lines
5.1 KiB
Plaintext
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
|
|
RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
|
|
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
|
|
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
|
|
CREATE OPERATOR === (
|
|
LEFTARG = boolean,
|
|
RIGHTARG = boolean,
|
|
PROCEDURE = alter_op_test_fn,
|
|
COMMUTATOR = ===,
|
|
NEGATOR = !==,
|
|
RESTRICT = customcontsel,
|
|
JOIN = contjoinsel,
|
|
HASHES, MERGES
|
|
);
|
|
SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
|
|
FROM pg_depend
|
|
WHERE classid = 'pg_operator'::regclass AND
|
|
objid = '===(bool,bool)'::regoperator
|
|
ORDER BY 1;
|
|
ref | deptype
|
|
-------------------------------------------------------+---------
|
|
function alter_op_test_fn(boolean,boolean) | n
|
|
function customcontsel(internal,oid,internal,integer) | n
|
|
schema public | n
|
|
(3 rows)
|
|
|
|
--
|
|
-- Reset and set params
|
|
--
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE);
|
|
ALTER OPERATOR === (boolean, boolean) SET (JOIN = NONE);
|
|
SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
|
|
AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
|
|
oprrest | oprjoin
|
|
---------+---------
|
|
- | -
|
|
(1 row)
|
|
|
|
SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
|
|
FROM pg_depend
|
|
WHERE classid = 'pg_operator'::regclass AND
|
|
objid = '===(bool,bool)'::regoperator
|
|
ORDER BY 1;
|
|
ref | deptype
|
|
--------------------------------------------+---------
|
|
function alter_op_test_fn(boolean,boolean) | n
|
|
schema public | n
|
|
(2 rows)
|
|
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = contsel);
|
|
ALTER OPERATOR === (boolean, boolean) SET (JOIN = contjoinsel);
|
|
SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
|
|
AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
|
|
oprrest | oprjoin
|
|
---------+-------------
|
|
contsel | contjoinsel
|
|
(1 row)
|
|
|
|
SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
|
|
FROM pg_depend
|
|
WHERE classid = 'pg_operator'::regclass AND
|
|
objid = '===(bool,bool)'::regoperator
|
|
ORDER BY 1;
|
|
ref | deptype
|
|
--------------------------------------------+---------
|
|
function alter_op_test_fn(boolean,boolean) | n
|
|
schema public | n
|
|
(2 rows)
|
|
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE, JOIN = NONE);
|
|
SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
|
|
AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
|
|
oprrest | oprjoin
|
|
---------+---------
|
|
- | -
|
|
(1 row)
|
|
|
|
SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
|
|
FROM pg_depend
|
|
WHERE classid = 'pg_operator'::regclass AND
|
|
objid = '===(bool,bool)'::regoperator
|
|
ORDER BY 1;
|
|
ref | deptype
|
|
--------------------------------------------+---------
|
|
function alter_op_test_fn(boolean,boolean) | n
|
|
schema public | n
|
|
(2 rows)
|
|
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = customcontsel, JOIN = contjoinsel);
|
|
SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
|
|
AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
|
|
oprrest | oprjoin
|
|
---------------+-------------
|
|
customcontsel | contjoinsel
|
|
(1 row)
|
|
|
|
SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
|
|
FROM pg_depend
|
|
WHERE classid = 'pg_operator'::regclass AND
|
|
objid = '===(bool,bool)'::regoperator
|
|
ORDER BY 1;
|
|
ref | deptype
|
|
-------------------------------------------------------+---------
|
|
function alter_op_test_fn(boolean,boolean) | n
|
|
function customcontsel(internal,oid,internal,integer) | n
|
|
schema public | n
|
|
(3 rows)
|
|
|
|
--
|
|
-- Test invalid options.
|
|
--
|
|
ALTER OPERATOR === (boolean, boolean) SET (COMMUTATOR = ====);
|
|
ERROR: operator attribute "commutator" can not be changed
|
|
ALTER OPERATOR === (boolean, boolean) SET (NEGATOR = ====);
|
|
ERROR: operator attribute "negator" can not be changed
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = non_existent_func);
|
|
ERROR: function non_existent_func(internal, oid, internal, integer) does not exist
|
|
ALTER OPERATOR === (boolean, boolean) SET (JOIN = non_existent_func);
|
|
ERROR: function non_existent_func(internal, oid, internal, smallint, internal) does not exist
|
|
ALTER OPERATOR === (boolean, boolean) SET (COMMUTATOR = !==);
|
|
ERROR: operator attribute "commutator" can not be changed
|
|
ALTER OPERATOR === (boolean, boolean) SET (NEGATOR = !==);
|
|
ERROR: operator attribute "negator" can not be changed
|
|
--
|
|
-- Test permission check. Must be owner to ALTER OPERATOR.
|
|
--
|
|
CREATE USER regtest_alter_user;
|
|
SET SESSION AUTHORIZATION regtest_alter_user;
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE);
|
|
ERROR: must be owner of operator ===
|
|
-- Clean up
|
|
RESET SESSION AUTHORIZATION;
|
|
DROP USER regtest_alter_user;
|
|
DROP OPERATOR === (boolean, boolean);
|
|
DROP FUNCTION customcontsel(internal, oid, internal, integer);
|
|
DROP FUNCTION alter_op_test_fn(boolean, boolean);
|