diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
commit | 46651ce6fe013220ed397add242004d764fc0153 (patch) | |
tree | 6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/test/regress/sql/alter_operator.sql | |
parent | Initial commit. (diff) | |
download | postgresql-14-upstream.tar.xz postgresql-14-upstream.zip |
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/regress/sql/alter_operator.sql')
-rw-r--r-- | src/test/regress/sql/alter_operator.sql | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/test/regress/sql/alter_operator.sql b/src/test/regress/sql/alter_operator.sql new file mode 100644 index 0000000..fd40370 --- /dev/null +++ b/src/test/regress/sql/alter_operator.sql @@ -0,0 +1,100 @@ +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; + +-- +-- 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; + +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; + +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; + +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; + +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; + +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; + +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; + +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; + +-- +-- 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 = !==); + +-- invalid: non-lowercase quoted identifiers +ALTER OPERATOR & (bit, bit) SET ("Restrict" = _int_contsel, "Join" = _int_contjoinsel); + +-- +-- Test permission check. Must be owner to ALTER OPERATOR. +-- +CREATE USER regress_alter_op_user; +SET SESSION AUTHORIZATION regress_alter_op_user; + +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE); + +-- Clean up +RESET SESSION AUTHORIZATION; +DROP USER regress_alter_op_user; +DROP OPERATOR === (boolean, boolean); +DROP FUNCTION customcontsel(internal, oid, internal, integer); +DROP FUNCTION alter_op_test_fn(boolean, boolean); |