mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-23 16:57:19 +02:00
33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
|
--
|
||
|
-- Test extension script protection against search path overriding
|
||
|
--
|
||
|
CREATE ROLE regress_seg_role;
|
||
|
SELECT current_database() AS datname \gset
|
||
|
GRANT CREATE ON DATABASE :"datname" TO regress_seg_role;
|
||
|
SET ROLE regress_seg_role;
|
||
|
CREATE SCHEMA regress_seg_schema;
|
||
|
CREATE FUNCTION regress_seg_schema.exfun(i int) RETURNS int AS $$
|
||
|
BEGIN
|
||
|
CREATE EXTENSION seg VERSION '1.2';
|
||
|
|
||
|
CREATE FUNCTION regress_seg_schema.compare(oid, regclass) RETURNS boolean AS
|
||
|
'BEGIN RAISE EXCEPTION ''overloaded compare() called by %'', current_user; END;' LANGUAGE plpgsql;
|
||
|
|
||
|
CREATE OPERATOR = (LEFTARG = oid, RIGHTARG = regclass, PROCEDURE = regress_seg_schema.compare);
|
||
|
|
||
|
ALTER EXTENSION seg UPDATE TO '1.3';
|
||
|
|
||
|
RETURN i;
|
||
|
END; $$ LANGUAGE plpgsql;
|
||
|
CREATE SCHEMA test_schema
|
||
|
CREATE TABLE t(i int) PARTITION BY RANGE (i)
|
||
|
CREATE TABLE p1 PARTITION OF t FOR VALUES FROM (1) TO (regress_seg_schema.exfun(2));
|
||
|
DROP SCHEMA test_schema CASCADE;
|
||
|
NOTICE: drop cascades to 3 other objects
|
||
|
DETAIL: drop cascades to table test_schema.t
|
||
|
drop cascades to extension seg
|
||
|
drop cascades to operator test_schema.=(oid,regclass)
|
||
|
RESET ROLE;
|
||
|
DROP OWNED BY regress_seg_role;
|
||
|
DROP ROLE regress_seg_role;
|