1 CREATE FUNCTION alter_op_test_fn(boolean, boolean)
2 RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
3 CREATE FUNCTION customcontsel(internal, oid, internal, integer)
4 RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
8 PROCEDURE = alter_op_test_fn,
11 RESTRICT = customcontsel,
15 SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
17 WHERE classid = 'pg_operator'::regclass AND
18 objid = '===(bool,bool)'::regoperator
21 -------------------------------------------------------+---------
22 function alter_op_test_fn(boolean,boolean) | n
23 function customcontsel(internal,oid,internal,integer) | n
28 -- Reset and set params
30 ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE);
31 ALTER OPERATOR === (boolean, boolean) SET (JOIN = NONE);
32 SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
33 AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
39 SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
41 WHERE classid = 'pg_operator'::regclass AND
42 objid = '===(bool,bool)'::regoperator
45 --------------------------------------------+---------
46 function alter_op_test_fn(boolean,boolean) | n
50 ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = contsel);
51 ALTER OPERATOR === (boolean, boolean) SET (JOIN = contjoinsel);
52 SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
53 AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
55 ---------+-------------
59 SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
61 WHERE classid = 'pg_operator'::regclass AND
62 objid = '===(bool,bool)'::regoperator
65 --------------------------------------------+---------
66 function alter_op_test_fn(boolean,boolean) | n
70 ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE, JOIN = NONE);
71 SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
72 AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
78 SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
80 WHERE classid = 'pg_operator'::regclass AND
81 objid = '===(bool,bool)'::regoperator
84 --------------------------------------------+---------
85 function alter_op_test_fn(boolean,boolean) | n
89 ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = customcontsel, JOIN = contjoinsel);
90 SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
91 AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
93 ---------------+-------------
94 customcontsel | contjoinsel
97 SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype
99 WHERE classid = 'pg_operator'::regclass AND
100 objid = '===(bool,bool)'::regoperator
103 -------------------------------------------------------+---------
104 function alter_op_test_fn(boolean,boolean) | n
105 function customcontsel(internal,oid,internal,integer) | n
110 -- Test invalid options.
112 ALTER OPERATOR === (boolean, boolean) SET (COMMUTATOR = ====);
113 ERROR: operator attribute "commutator" cannot be changed
114 ALTER OPERATOR === (boolean, boolean) SET (NEGATOR = ====);
115 ERROR: operator attribute "negator" cannot be changed
116 ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = non_existent_func);
117 ERROR: function non_existent_func(internal, oid, internal, integer) does not exist
118 ALTER OPERATOR === (boolean, boolean) SET (JOIN = non_existent_func);
119 ERROR: function non_existent_func(internal, oid, internal, smallint, internal) does not exist
120 ALTER OPERATOR === (boolean, boolean) SET (COMMUTATOR = !==);
121 ERROR: operator attribute "commutator" cannot be changed
122 ALTER OPERATOR === (boolean, boolean) SET (NEGATOR = !==);
123 ERROR: operator attribute "negator" cannot be changed
124 -- invalid: non-lowercase quoted identifiers
125 ALTER OPERATOR & (bit, bit) SET ("Restrict" = _int_contsel, "Join" = _int_contjoinsel);
126 ERROR: operator attribute "Restrict" not recognized
128 -- Test permission check. Must be owner to ALTER OPERATOR.
130 CREATE USER regress_alter_op_user;
131 SET SESSION AUTHORIZATION regress_alter_op_user;
132 ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE);
133 ERROR: must be owner of operator ===
135 RESET SESSION AUTHORIZATION;
136 DROP USER regress_alter_op_user;
137 DROP OPERATOR === (boolean, boolean);
138 DROP FUNCTION customcontsel(internal, oid, internal, integer);
139 DROP FUNCTION alter_op_test_fn(boolean, boolean);