-
Notifications
You must be signed in to change notification settings - Fork 65
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
Implement Start
for adding columns with NOT NULL
and no DEFAULT
#37
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
andrew-farries
force-pushed
the
start-not-null-col-with-no-default
branch
from
July 20, 2023 14:16
0e8a875
to
8f330f8
Compare
exekias
approved these changes
Jul 20, 2023
exekias
reviewed
Jul 20, 2023
exekias
reviewed
Jul 20, 2023
Remove the validation restriction that `NOT NULL` columns without `DEFAULT` are not supported.
Demonstrate adding a `NOT NULL` column without a `DEFAULT`.
Assert that the `INSERT` statement was not successful.
`addCheckConstraint` -> `addNotNullConstraint` `CheckConstraintName` -> `NotNullConstraintName` to be more specific and not cause confusion with any future constraints.
andrew-farries
force-pushed
the
start-not-null-col-with-no-default
branch
from
July 21, 2023 06:45
a1aaed3
to
1715aff
Compare
andrew-farries
added a commit
that referenced
this pull request
Jul 21, 2023
…LT` (#38) Implement `Rollback` for **add column** operations that add a `NOT NULL` column without a `DEFAULT`. Support for starting such an operation was added in #37. See that PR for a description of the steps involved. In order to roll back, there is nothing to be done as the rollback for the **add column** operation already removes the new column, which also removes any constraints defined on the column. This PR adds an `afterRollback` hook to the tests to verify that the constraint has been dropped.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement
Start
for add column operations that add aNOT NULL
column without aDEFAULT
.To add such a column without forcing a exclusive lock while a full table scan is performed, these steps need to be followed:
On
Start
:CHECK IS NOT NULL
constraint to the new column, but withNOT VALID
, to avoid the scan.up
SQL.On
Complete
ALTER TABLE VALIDATE CONSTRAINT
).NOT NULL
attribute to the column. The presence of a validNOT NULL
constraint on the column means that addingNOT NULL
to the column does not perform a full table scan.See this post for a summary of these steps.