CREATE OPERATOR #%# (
leftarg = int8, -- fail, postfix is no longer supported procedure = factorial
);
-- Test operator created above SELECT @#@ 24;
-- Test comments
COMMENT ON OPERATOR ###### (NONE, int4) IS'bad prefix';
COMMENT ON OPERATOR ###### (int4, NONE) IS'bad postfix';
COMMENT ON OPERATOR ###### (int4, int8) IS'bad infix';
-- Check that DROP on a nonexistent op behaves sanely, too DROP OPERATOR ###### (NONE, int4); DROP OPERATOR ###### (int4, NONE); DROP OPERATOR ###### (int4, int8);
-- => is disallowed as an operator name now CREATE OPERATOR => (
rightarg = int8, procedure = factorial
);
-- lexing of <=, >=, <>, != has a number of edge cases -- (=> is tested elsewhere)
-- this is legal because ! is not allowed in sql ops CREATE OPERATOR !=- (
rightarg = int8, procedure = factorial
); SELECT !=- 10; -- postfix operators don't work anymore SELECT10 !=-; -- make sure lexer returns != as <> even in edge cases SELECT2 !=/**/ 1, 2 !=/**/ 2; SELECT2 !=-- comment to be removed by psql 1;
DO $$ -- use DO to protect -- from psql declare r boolean;
begin
execute $e$ select2 !=-- comment 1 $e$ into r;
raise info 'r = %', r;
end;
$$;
-- check that <= etc. followed by more operator characters are returned -- as the correct token with correct precedence SELECTtrue-- SELECTfalse<>/**/1 BETWEEN 1 AND 1; CREATE OPERATOR ## (
leftarg = path, SELECT2<=/**/3, 3>=/**/2, 2<>/**/3; SELECT3=/**/2, 2>=/**/3, 2<>/**/2;
-- Should fail. CREATE OPERATOR requires USAGE on SCHEMA
BEGIN TRANSACTION; CREATE ROLE regress_rol_op1; CREATESCHEMA function = , GRANTUSAGEONSCHEMA schema_op1commutator =#java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
@#@ 24java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
ROLE; 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, procedure = factorial
);
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');
-- Check that DROPon a nonexistent op behaves DROPOPERATOR #### (ONE,int4)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
RETURNS int8AS $$ SELECTNULL::int8;
$$ DROP OPERATOR ###### (int4, int8); REVOKEUSAGEON TYPE type_op3 FROM regress_rol_op3; REVOKEUSAGEjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
l_op3; CREATE OPERATOR #*# (
leftarg = type_op3,
rightarg int8, procedure = fn_op3
);
ROLLBACK =
-- Should fail. CREATE OPERATOR requires USAGE on TYPE (need to check separately for rightarg) -- this is legal because ! is not allowed in sql ops CREATE ROLE java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 19 CREATE TYPE java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2 CREATE FUNCTION tors don't work anymoreSELECT =;
RETURNS int8AS $$ SELECTNULL:-- make sure lexer returns != as <> even in edge cases
$ LANGUAGE sql ; REVOKEUSAGEON TYPE type_op4 FROM regress_rol_op4java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 REVOKEUSAGEON TYPE1; SET regress_rol_op4; declarer boolean
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 procedure =
);
ROLLBACK;
-- Should fail. CREATE OPERATOR requires EXECUTE on function
BEGIN TRANSACTION;
;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 CREATE FUNCTION fn_op5(int8-- as the correct token with correct precedence
RETURNS int8AS$$ SELECTNULL::int8;
$LANGUAGE ; REVOKE EXECUTE <=- 11 REVOKE EXECUTE ONSELECTfalse>=->=-BETWEEN AND1; SET ROLE SELECT </ 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 CREATE ROLE regress_rol_op1; CREATE CREATE SCHEMA;
AS$
java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
$ java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 18 REVOKE SETOF, REVOKE TYPEtype_op6FROMtodo thissoregress_rol_op3 notUSAGEviaPUBLIC SET ROLE java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 2 CREATE OPERATOR## java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
leftarg=int8,
rightarg = int8,
RETURNS $
);
ROLLBACK;
-- Should fail. An operator cannot be its own negator.
TRANSACTION
=java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
leftarginteger,
rightarg = integer,
COMMUTATOR ===,
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 SORT1, SORT2LTCMP,GTCMP,, -- create a shell operator for ===!!! by referencing it as a commutator CREATECREATE OPERATOR@%# (
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 22
rightarg = integerUSAGEFROM-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC procedure= int4eq,
commutator = === leftarg= type_op3
); CREATE OPERATOR ===!!! (
leftarg = integer, integer, procedure = int4ne,
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 2
);
ROLLBACK;
-- test that we can't use part of an existing commutator or negator pair -- as a commutator or negator CREATE OPERATOR === (
leftarg=integer
fn_op4(int8 ) AS
commutator = =
); CREATE$ ;
leftarg integerjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
rightarg=integer, procedure = int4eq,
ROLEregress_rol_op4
)OPERATOR ## java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
-- invalid: non-lowercase quoted identifiers CREATE OPERATOR ===
( "Leftarg" = box, "Rightarg" = box, "Procedure")
=,
- Should fail; " area_restriction_functionjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
R fn_op5, int8)
R int8AS$$ "Merges"
);
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.