1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
# name: test/sql/catalog/dependencies/test_schema_dependency.test
# description: Schema dependencies
# group: [dependencies]
# single schema and dependencies
statement ok con1
CREATE SCHEMA s1
statement ok con1
CREATE TABLE s1.integers(i INTEGER)
query I con1
SELECT * FROM s1.integers
----
# can't drop: dependency
statement error con1
DROP SCHEMA s1
----
table "integers" depends on schema "s1".
query I con1
SELECT * FROM s1.integers
----
# we can drop with cascade though
statement ok con1
DROP SCHEMA s1 CASCADE
# this also drops the table
statement error con1
SELECT * FROM s1.integers
----
Catalog Error: Table with name "s1.integers" does not exist because schema "s1" does not exist.
# schemas and dependencies
# create a schema and a table inside the schema
statement ok con1
CREATE SCHEMA s1
statement ok con1
CREATE TABLE s1.integers(i INTEGER)
statement ok con1
BEGIN TRANSACTION
statement ok con2
BEGIN TRANSACTION
# drop the table in con1
statement ok con1
DROP TABLE s1.integers
# we can't drop the schema from con2 because the table still exists for con2!
statement error con2
DROP SCHEMA s1
----
table "integers" depends on schema "s1".
# now rollback the table drop
statement ok con1
ROLLBACK
statement ok con2
ROLLBACK
# the table exists again
query I con1
SELECT * FROM s1.integers
----
# try again, but this time we commit
statement ok con1
BEGIN TRANSACTION
statement ok con2
BEGIN TRANSACTION
# drop the schema entirely now
statement ok con1
DROP SCHEMA s1 CASCADE
# we can still query the table from con2
query I con2
SELECT * FROM s1.integers
----
# even after we commit
statement ok con1
COMMIT
query I con2
SELECT * FROM s1.integers
----
# however if we end the transaction in con2 the schema is gone
statement ok con2
ROLLBACK
statement error con2
CREATE TABLE s1.dummy(i INTEGER)
----
Schema with name s1 does not exist
|