Skip to content

sql: support adding constraints or columns with constraints #8773

@dt

Description

@dt

currently we enforce constraints when adding/changing rows, and thus, if the table starts empty, can inductively assume they hold for all rows.

however when adding a constraint to an existing table (or when adding a column with a constraint to an existing table), without the base case of an empty table, our inductive proof no longer holds.

To resolve this, we can add the constraint in a special state (non-public or unvalidated) at which point it is applied to a new writes, then scan for existing violations and, if none are found, update the constraint's state to indicate it now holds.

When adding new columns, the situation is slightly more complicated: the backfill of DEFAULT values must be done before we can check for violations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions