|
| 1 | +-- Test use of namespace pg_ext_aux |
| 2 | +-- Test 1: Create database object in pg_ext_aux should fail normally |
| 3 | +create table pg_ext_aux.extaux_t(a int, b int); |
| 4 | +ERROR: permission denied to create "pg_ext_aux.extaux_t" |
| 5 | +DETAIL: System catalog modifications are currently disallowed. |
| 6 | +create view pg_ext_aux.extaux_v as select oid, relname from pg_class; |
| 7 | +ERROR: permission denied to create "pg_ext_aux.extaux_v" |
| 8 | +DETAIL: System catalog modifications are currently disallowed. |
| 9 | +create materialized view pg_ext_aux.extaux_mv as select oid, relname from pg_class; |
| 10 | +ERROR: permission denied to create "pg_ext_aux.extaux_mv" |
| 11 | +DETAIL: System catalog modifications are currently disallowed. |
| 12 | +-- shell type is created successfully |
| 13 | +create type pg_ext_aux.extaux_shell_type; |
| 14 | +-- concreate type will fail |
| 15 | +create type pg_ext_aux.extaux_concreat_type AS (sum int, count int); |
| 16 | +ERROR: permission denied to create "pg_ext_aux.extaux_concreat_type" |
| 17 | +DETAIL: System catalog modifications are currently disallowed. |
| 18 | +-- create function will success |
| 19 | +create function pg_ext_aux.extaux_add1(i integer) returns integer AS $$ |
| 20 | +begin |
| 21 | + return i + 1; |
| 22 | +end; |
| 23 | +$$ language plpgsql; |
| 24 | +-- Test 2: Create database object in pg_ext_aux should success |
| 25 | +-- if allow_system_table_mods is on |
| 26 | +set allow_system_table_mods = on; |
| 27 | +create table pg_ext_aux.extaux_t(a int, b text); |
| 28 | +create view pg_ext_aux.extaux_v as select * from pg_ext_aux.extaux_t; |
| 29 | +create materialized view pg_ext_aux.extaux_mv as select * from pg_ext_aux.extaux_t; |
| 30 | +create type pg_ext_aux.extaux_concreat_type AS (sum int, count int); |
| 31 | +set allow_system_table_mods = off; |
| 32 | +-- Test 3: Check that the array type is not created |
| 33 | +-- these relations have its reltype, but have no array type |
| 34 | +select typname, typarray from pg_type where oid = (select reltype from pg_class where relname='extaux_t'); |
| 35 | + typname | typarray |
| 36 | +---------+---------- |
| 37 | +(0 rows) |
| 38 | + |
| 39 | +select typname, typarray from pg_type where oid = (select reltype from pg_class where relname='extaux_v'); |
| 40 | + typname | typarray |
| 41 | +---------+---------- |
| 42 | +(0 rows) |
| 43 | + |
| 44 | +select typname, typarray from pg_type where oid = (select reltype from pg_class where relname='extaux_mv'); |
| 45 | + typname | typarray |
| 46 | +---------+---------- |
| 47 | +(0 rows) |
| 48 | + |
| 49 | +-- Test 4: check function works |
| 50 | +select pg_ext_aux.extaux_add1(7); |
| 51 | + extaux_add1 |
| 52 | +------------- |
| 53 | + 8 |
| 54 | +(1 row) |
| 55 | + |
| 56 | +-- Test 5: Check that these relations are protected |
| 57 | +-- fail: should not allowed to insert by user |
| 58 | +insert into pg_ext_aux.extaux_t values(1,'hello'); |
| 59 | +ERROR: permission denied: "extaux_t" is a system catalog |
| 60 | +-- fail: should not allowed to refresh by user |
| 61 | +refresh materialized view pg_ext_aux.extaux_mv; |
| 62 | +ERROR: cannot swap toast files by links for system catalogs (cluster.c:1424) |
| 63 | +-- fail: should not allow to be dropped by user |
| 64 | +drop view pg_ext_aux.extaux_v; |
| 65 | +ERROR: permission denied: "extaux_v" is a system catalog |
| 66 | +drop materialized view pg_ext_aux.extaux_mv; |
| 67 | +ERROR: permission denied: "extaux_mv" is a system catalog |
| 68 | +drop table pg_ext_aux.extaux_t; |
| 69 | +ERROR: permission denied: "extaux_t" is a system catalog |
| 70 | +-- Test 6: type and functions may be dropped normally |
| 71 | +drop type pg_ext_aux.extaux_shell_type; |
| 72 | +drop type pg_ext_aux.extaux_concreat_type; |
| 73 | +drop function pg_ext_aux.extaux_add1(i integer); |
| 74 | +-- Clean up |
| 75 | +set allow_system_table_mods = on; |
| 76 | +drop view pg_ext_aux.extaux_v; |
| 77 | +drop materialized view pg_ext_aux.extaux_mv; |
| 78 | +drop table pg_ext_aux.extaux_t; |
| 79 | +reset allow_system_table_mods; |
0 commit comments