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: allow cascading action when default is set implicitly to null #39136

Merged

Commits on Aug 6, 2019

  1. sql: allow cascading action when default is set implicitly to null

    Add support for implicitly setting the default value of a column
    to null, for cascading tables for both ON DELETE and ON UPDATE.
    
    Previously, if a user set a reference to a column and added a
    SET DEFAULT for an ON DELETE/UPDATE cascading action, without an
    explicit default expression, CRDB would forbid it. Postgres does not
    distinguish between SET NULL and the absence of a default expression.
    Thus, the change is to also have CRDB not distinguish between the two
    cases.
    
    In the situation where a user creates a table with an explicit
    default null via SET NULL, CRDB does not allow the user to create the
    table at all. This deviates from how postgres handles it. Postgres
    allows the user to create the table but throws an error if a
    cascading action occurs that uses the default value. The new changes
    now prevent the user from creating a table when they constrain the
    columns to be non-nullable, and implicitly set the default to NULL.
    This is done to match the behavior for the explicit case of setting
    the default to NULL.
    
    Resolves: cockroachdb#38975
    
    Release note (sql change): Columns without an explicit default value now
    support foreign keys with the SET DEFAULT action, in the same way as the
    SET NULL and SET DEFAULT NULL cases.
    Tyler314 committed Aug 6, 2019
    Configuration menu
    Copy the full SHA
    0af26a0 View commit details
    Browse the repository at this point in the history