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

release-20.2: sql: prevent DROP SCHEMA CASCADE from droping types with references #61259

Merged
merged 2 commits into from
Mar 2, 2021

Commits on Mar 1, 2021

  1. sql: prevent DROP SCHEMA CASCADE from droping types with references

    Before this patch, a DROP SCHEMA CASCADE could cause database corruption
    by dropping types which were referenced by other tables. This would lead to
    bad errors like:
    
    ```
    ERROR: object already exists: desc 687: type ID 685 in descriptor not found: descriptor not found
    SQLSTATE: 42710
    ```
    
    And doctor errors like:
    ```
       Table 687: ParentID  50, ParentSchemaID 29, Name 't': type ID 685 in descriptor not found: descriptor not found
    ```
    
    Fixes cockroachdb#59021.
    
    Release note (bug fix): Fixed a bug where `DROP SCHEMA ... CASCADE` could
    result in types which are referenced being dropped.
    ajwerner committed Mar 1, 2021
    Configuration menu
    Copy the full SHA
    a3c3180 View commit details
    Browse the repository at this point in the history
  2. sql: deal with properly removing type backreferences during DROP SCHEMA

    Before this commit we'd errantly skip dropping type references under a false
    assumption that all the types were also being dropped. This could lead to
    dangling backreferences to types from tables in other schemas.
    
    Release note (bug fix): Fixed a bug whereby dropping a schema with a table
    that used a user-defined type which was not being dropped (because it is
    in a different schema) would result in a descriptor corruption due to a
    dangling back-reference to a dropped table on the type descriptor.
    ajwerner committed Mar 1, 2021
    Configuration menu
    Copy the full SHA
    8ad76d4 View commit details
    Browse the repository at this point in the history