|
| 1 | +-- |
| 2 | +-- CREATE_SCHEMA |
| 3 | +-- |
| 4 | +-- Schema creation with elements. |
| 5 | +CREATE ROLE regress_create_schema_role SUPERUSER; |
| 6 | +-- Cases where schema creation fails as objects are qualified with a schema |
| 7 | +-- that does not match with what's expected. |
| 8 | +-- This checks all the object types that include schema qualifications. |
| 9 | +CREATE SCHEMA AUTHORIZATION regress_create_schema_role |
| 10 | + CREATE SEQUENCE schema_not_existing.seq; |
| 11 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 12 | +CREATE SCHEMA AUTHORIZATION regress_create_schema_role |
| 13 | + CREATE TABLE schema_not_existing.tab (id int); |
| 14 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 15 | +CREATE SCHEMA AUTHORIZATION regress_create_schema_role |
| 16 | + CREATE VIEW schema_not_existing.view AS SELECT 1; |
| 17 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 18 | +CREATE SCHEMA AUTHORIZATION regress_create_schema_role |
| 19 | + CREATE INDEX ON schema_not_existing.tab (id); |
| 20 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 21 | +CREATE SCHEMA AUTHORIZATION regress_create_schema_role |
| 22 | + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab |
| 23 | + EXECUTE FUNCTION schema_trig.no_func(); |
| 24 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 25 | +-- Again, with a role specification and no schema names. |
| 26 | +SET ROLE regress_create_schema_role; |
| 27 | +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE |
| 28 | + CREATE SEQUENCE schema_not_existing.seq; |
| 29 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 30 | +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE |
| 31 | + CREATE TABLE schema_not_existing.tab (id int); |
| 32 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 33 | +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE |
| 34 | + CREATE VIEW schema_not_existing.view AS SELECT 1; |
| 35 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 36 | +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE |
| 37 | + CREATE INDEX ON schema_not_existing.tab (id); |
| 38 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 39 | +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE |
| 40 | + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab |
| 41 | + EXECUTE FUNCTION schema_trig.no_func(); |
| 42 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_create_schema_role) |
| 43 | +-- Again, with a schema name and a role specification. |
| 44 | +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE |
| 45 | + CREATE SEQUENCE schema_not_existing.seq; |
| 46 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_schema_1) |
| 47 | +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE |
| 48 | + CREATE TABLE schema_not_existing.tab (id int); |
| 49 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_schema_1) |
| 50 | +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE |
| 51 | + CREATE VIEW schema_not_existing.view AS SELECT 1; |
| 52 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_schema_1) |
| 53 | +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE |
| 54 | + CREATE INDEX ON schema_not_existing.tab (id); |
| 55 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_schema_1) |
| 56 | +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE |
| 57 | + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab |
| 58 | + EXECUTE FUNCTION schema_trig.no_func(); |
| 59 | +ERROR: CREATE specifies a schema (schema_not_existing) different from the one being created (regress_schema_1) |
| 60 | +RESET ROLE; |
| 61 | +-- Cases where the schema creation succeeds. |
| 62 | +-- The schema created matches the role name. |
| 63 | +CREATE SCHEMA AUTHORIZATION regress_create_schema_role |
| 64 | + CREATE TABLE regress_create_schema_role.tab (id int); |
| 65 | +\d regress_create_schema_role.tab |
| 66 | + Table "regress_create_schema_role.tab" |
| 67 | + Column | Type | Collation | Nullable | Default |
| 68 | +--------+---------+-----------+----------+--------- |
| 69 | + id | integer | | | |
| 70 | + |
| 71 | +DROP SCHEMA regress_create_schema_role CASCADE; |
| 72 | +NOTICE: drop cascades to table regress_create_schema_role.tab |
| 73 | +-- Again, with a different role specification and no schema names. |
| 74 | +SET ROLE regress_create_schema_role; |
| 75 | +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE |
| 76 | + CREATE TABLE regress_create_schema_role.tab (id int); |
| 77 | +\d regress_create_schema_role.tab |
| 78 | + Table "regress_create_schema_role.tab" |
| 79 | + Column | Type | Collation | Nullable | Default |
| 80 | +--------+---------+-----------+----------+--------- |
| 81 | + id | integer | | | |
| 82 | + |
| 83 | +DROP SCHEMA regress_create_schema_role CASCADE; |
| 84 | +NOTICE: drop cascades to table tab |
| 85 | +-- Again, with a schema name and a role specification. |
| 86 | +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE |
| 87 | + CREATE TABLE regress_schema_1.tab (id int); |
| 88 | +\d regress_schema_1.tab |
| 89 | + Table "regress_schema_1.tab" |
| 90 | + Column | Type | Collation | Nullable | Default |
| 91 | +--------+---------+-----------+----------+--------- |
| 92 | + id | integer | | | |
| 93 | + |
| 94 | +DROP SCHEMA regress_schema_1 CASCADE; |
| 95 | +NOTICE: drop cascades to table regress_schema_1.tab |
| 96 | +RESET ROLE; |
| 97 | +-- Clean up |
| 98 | +DROP ROLE regress_create_schema_role; |
0 commit comments