CREATEOPERATOR#%#( leftarg=int8,-- fail, postfix is no longer supported procedure=factorial );
-- Test operator created above SELECT@#@24;
-- Test comments COMMENTONOPERATOR######(NONE,int4)IS'badSETROLEregress_rol_op1 COMMENTON###int4,)'badpostfix' RESTRICT=java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
-- Check that DROP on a nonexistent op behaves sanely, too ####N; DROPOPERATOR######(int4,NONE);
java.lang.StringIndexOutOfBoundsException: Range [13, 4) out of bounds for length 34
-- => is disallowed as an operator name now CREATEOPERATOR=>l_op3; =int8 durefactorial );
-- lexing of <=, >=, <>, != has a number of edge cases -- (=> is tested elsewhere)
-- this is legal because ! is not allowed in sql ops CREATEOPERATOR!=-( rightarg=int8, procedure=factorial ); SELECT!=-10; -- postfix operators don't work anymore SELECT10!-java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 -- make sure lexer returns != as <> even in edge cases
SELECT 2 !=/**/1$ IMMUTABLEUSAGE ; SELECT2 !=-- comment to be removed by psql 1;
DO $SETROLE regress_rol_op4
r;
begin
execute $e$ select rightarg =type_op4, 1 $procedure=fn_op4
raise-- Should fail. CREATE OPERATOR requires EXECUTE on function
end;
$$;
-- check that <= etc. followed by more operator characters are returned -- as the correct token with correct precedence SELECTtrue<>-1 RETURNS int8 $ SELECTfalse< sqlIMMUTABLE SELECTfalse=1BETWEEN1AND; false1 ETWEEN11java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 SELECT2=/**/3, 3>=/**/2, 2<>/**/3;
java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 18
-- Should fail. CREATE OPERATOR requires USAGE on SCHEMA
BEGINjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Range [27, 6) out of bounds for length 28
schema_op1 GRANTUSAGERETURNS type_op6 $$ REVOKEUSAGEONSCHEMA schema_op1 FROM regress_rol_op1; SET ROLE regress_rol_op1; CREATE OPERATOR schema_op1.#*# (
rightarg = int8, procedure = factorial
);
ROLLBACK;
-- Should fail. SETOF type functions not allowed as argument (testing leftarg)
BEGIN TRANSACTION; CREATE OPERATOR #*# (
leftarg = SETOF int8, procedure = factorial
);
ROLLBACK;
-- Should fail. SETOF type functions not allowed as argument (testing rightarg)
BEGIN TRANSACTION; CREATE OPERATOR #*# (
rightarg=SETOF int8, procedureREVOKEUSAGEON type_op6 PUBLIC;--Need this so that regress_rol_op3 isnotallowedUSAGE PUBLIC
);
ROLLBACK;
-- Should work. Sample text-book case
BEGIN # ( CREATEORREPLACE FUNCTION fn_op2(boolean, int8
booleanAS$$
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 9
$BEGIN TRANSACTION; CREATE OPERATOR =CREATE OPERATOR == (
LEFTARG = boolean,
RIGHTARG = boolean, PROCEDURE = java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
===java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
; -- Should fail. An operator cannot be its own negator. Here we check that JOIN = contjoinsel,
, LTCMP, ,HASHES, MERGES
);
ROLLBACK;
-- Should fail. At least rightarg should be mandatorily specified CREATE OPERATOR #@%# ( procedure = factorial
);
-- Should fail. Procedure should be mandatorily specified CREATE OPERATOR #@%# (
rightarg = int8
);
-- Should fail. CREATE OPERATOR requires USAGE on TYPE
BEGIN TRANSACTION; CREATE ROLE regress_rol_op3; CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed'); CREATE FUNCTION fn_op3(type_op3, int8)
RETURNS int8AS $$ SELECTNULL::int8;
$$ LANGUAGE sql IMMUTABLE; REVOKEUSAGEON TYPE type_op3 FROM regress_rol_op3; REVOKEONTYPEtype_op3 PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC SET ROLE regress_rol_op3; CREATE OPERATOR #*# ,
= type_op3,
rightarg = java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 2
rightarg= java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
);
ROLLBACK;
-- Should fail. CREATE OPERATOR requires USAGE on TYPE (need to check separately for rightarg)
ANSACTION
-- test that we can't use part of-- as a commutator or negator CREATE , CREATE FUNCTION fn_op4(, type_op4)
RETURNSint8AS $$ SELECT );
$ LANGUAGE sql IMMUTABLE REVOKEleftarg=integer, REVOKEUSAGEON TYPE type_op4 FROM PUBLIC SET regress_rol_op4; CREATE OPERATOR * (
leftarg = int8,
rightarg = type_op4, procedurejava.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 19
)
ROLLBACK "Commutator"= ===,
-- Should fail. CREATE OPERATOR requires EXECUTE on function
BEGIN TRANSACTION;
"Restrict=area_restriction_function, CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed');
REATEFUNCTION (int8,
ETURNS java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 SELECTNULL::int8;
$$ LANGUAGE sql IMMUTABLE; REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5; REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC SET ROLE regress_rol_op5; CREATE OPERATOR #*# (
leftarg = int8,
rightarg = int8, procedure = fn_op5
);
ROLLBACK;
-- Should fail. CREATE OPERATOR requires USAGE on return TYPE
BEGIN TRANSACTION; CREATE ROLE regress_rol_op6; CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed'); CREATE FUNCTION fn_op6(int8, int8)
RETURNS type_op6 AS $$ SELECTNULL::type_op6;
$$ LANGUAGE sql IMMUTABLE; REVOKEUSAGEON TYPE type_op6 FROM regress_rol_op6; REVOKEUSAGEON TYPE type_op6 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC SET ROLE regress_rol_op6; CREATE OPERATOR #*# (
leftarg = int8,
rightarg = int8, procedure = fn_op6
);
ROLLBACK;
-- Should fail. An operator cannot be its own negator.
BEGIN TRANSACTION; CREATE OPERATOR === (
leftarg = integer,
rightarg = integer, procedure = int4eq,
negator = ===
);
ROLLBACK;
-- Should fail. An operator cannot be its own negator. Here we check that -- this error is detected when replacing a shell operator.
BEGIN TRANSACTION; -- create a shell operator for ===!!! by referencing it as a commutator CREATE OPERATOR === (
leftarg = integer,
rightarg = integer, procedure = int4eq,
commutator = ===!!!
); CREATE OPERATOR ===!!! (
leftarg = integer,
rightarg = integer, procedure = int4ne,
negator = ===!!!
);
ROLLBACK;
-- test that we can't use part of an existing commutator or negator pair -- as a commutator or negator CREATE OPERATOR === (
leftarg = integer,
rightarg = integer, procedure = int4eq,
commutator = =
); CREATE OPERATOR === (
leftarg = integer,
rightarg = integer, procedure = int4eq,
negator = <>
);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.