sql/schemachanger: Enable adding/dropping path of check constraint
Previously, we emit unimplemented operations on the adding and dropping
path of check constraint and constraint name. This PR enables this feature
as it will unblock certain DDL statement in the declarative schema changer
such as ALTER PRIMARY KEY USING HASH.
The two most notable changes are (commit 4 and commit 5):
1). Implemented the logic to validate a check constraint in backfill.go
and plumb it in to the Validator used in declarative schema changer
for unique index and check constraint validation.
2). Introduced two new status -- Check_Constraint_Validating and
Check_Constraint_Validated, and the the adding/dropping path
of a check constraint is now
ABSENT <--> VALIDATING <--> VALIDATED <--> PUBLIC
RFAL!
Let's table this until the next release. This was a valiant and impressive effort, but time has run out.
If it's any consolation, we experienced something similar in the last cycle with ADD COLUMN. We thought we were so close! Retrospectively, I'm glad we gave that the proper treatment it deserved in the subsequent (current) release cycle. I'm having similar gut feelings here for constraints in general.
Also, who knows what unknown problems the hash-sharding will reveal, and that's all still to be done.
I'm going to close this in favor of a sequence of smaller PRs, as tracked in issue https://github.com/cockroachdb/cockroach/issues/89665