mirror of https://github.com/postgres/postgres
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.0 KiB
62 lines
2.0 KiB
CREATE OR REPLACE FUNCTION alter_op_test_fn(boolean, boolean)
|
|
RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
|
|
|
|
CREATE OPERATOR === (
|
|
LEFTARG = boolean,
|
|
RIGHTARG = boolean,
|
|
PROCEDURE = alter_op_test_fn,
|
|
COMMUTATOR = ===,
|
|
NEGATOR = !==,
|
|
RESTRICT = contsel,
|
|
JOIN = contjoinsel,
|
|
HASHES, MERGES
|
|
);
|
|
|
|
--
|
|
-- 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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = contsel, JOIN = contjoinsel);
|
|
|
|
SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '==='
|
|
AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
|
|
|
|
--
|
|
-- Test invalid options.
|
|
--
|
|
ALTER OPERATOR === (boolean, boolean) SET (COMMUTATOR = ====);
|
|
ALTER OPERATOR === (boolean, boolean) SET (NEGATOR = ====);
|
|
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = non_existent_func);
|
|
ALTER OPERATOR === (boolean, boolean) SET (JOIN = non_existent_func);
|
|
ALTER OPERATOR === (boolean, boolean) SET (COMMUTATOR = !==);
|
|
ALTER OPERATOR === (boolean, boolean) SET (NEGATOR = !==);
|
|
|
|
--
|
|
-- 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);
|
|
|
|
-- Clean up
|
|
RESET SESSION AUTHORIZATION;
|
|
DROP USER regtest_alter_user;
|
|
DROP OPERATOR === (boolean, boolean);
|
|
|