Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: DROP SCHEMA CASCADE breaks types that have cross schema references #59020

Closed
arulajmani opened this issue Jan 14, 2021 · 1 comment
Closed
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@arulajmani
Copy link
Collaborator

Describe the problem

Currently, CRDB does not support DROP TYPE CASCADE, but we don't check for dependencies when the type is being dropped as part of a DROP SCHEMA CASCADE. This is problematic when the type is involved in a cross schema reference.

To Reproduce

[email protected]:26257/movr> create schema sc;
CREATE SCHEMA

Time: 31ms total (execution 9ms / network 22ms)

[email protected]:26257/movr> create type sc.abc as enum ('a', 'b', 'c');
CREATE TYPE

Time: 8ms total (execution 8ms / network 0ms)

[email protected]:26257/movr> create table t(k INT PRIMARY KEY, a sc.abc);
CREATE TABLE

Time: 59ms total (execution 8ms / network 52ms)

[email protected]:26257/movr> DROP SCHEMA sc;
ERROR: schema "sc" is not empty and CASCADE was not specified
SQLSTATE: 2BP01
[email protected]:26257/movr> DROP SCHEMA sc CASCADE;
DROP SCHEMA

Time: 34ms total (execution 11ms / network 23ms)

[email protected]:26257/movr> Insert into t values(1, 'a');
ERROR: type with ID 60 does not exist
SQLSTATE: 42704

Expected behavior
Similar to DROP TYPE CASCADE, the column that uses the enum being dropped should be dropped.

Additional data / screenshots
In the short term, when dropping a schema which contains types, we should ascertain that none of the types have cross schema references. If they exist, we should fail the DROP SCHEMA CASCADE, until the user manually removes the columns that use that type.
In the long term, we should really be supporting DROP TYPE CASCADE : #51480

Related to: #51889

@arulajmani arulajmani added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jan 14, 2021
@arulajmani
Copy link
Collaborator Author

GitHub crapped out on me and I accidentally opened 2 of these. Closing this as duplicate of #59021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

No branches or pull requests

1 participant