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

Whether the intermediate state setting of alter constraint is appropriate #44737

Closed
zimulala opened this issue Jun 16, 2023 · 1 comment · Fixed by #47633
Closed

Whether the intermediate state setting of alter constraint is appropriate #44737

zimulala opened this issue Jun 16, 2023 · 1 comment · Fixed by #47633
Assignees
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@zimulala
Copy link
Contributor

zimulala commented Jun 16, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

When we using alter constraint to switch from not enforced to enforced, we may not see the constraint information when executing show create table.

tidb/ddl/constraint.go

Lines 216 to 242 in 052c17f

if enforced {
originalState := constraintInfo.State
switch constraintInfo.State {
case model.StatePublic:
job.SchemaState = model.StateWriteReorganization
constraintInfo.State = model.StateWriteReorganization
constraintInfo.Enforced = enforced
ver, err = updateVersionAndTableInfoWithCheck(d, t, job, tblInfo, originalState != constraintInfo.State)
case model.StateWriteReorganization:
job.SchemaState = model.StateWriteOnly
constraintInfo.State = model.StateWriteOnly
ver, err = updateVersionAndTableInfoWithCheck(d, t, job, tblInfo, originalState != constraintInfo.State)
case model.StateWriteOnly:
err = w.verifyRemainRecordsForCheckConstraint(dbInfo, tblInfo, constraintInfo, job)
if err != nil {
if !table.ErrCheckConstraintViolated.Equal(err) {
return ver, errors.Trace(err)
}
constraintInfo.Enforced = !enforced
}
constraintInfo.State = model.StatePublic
ver, err = updateVersionAndTableInfoWithCheck(d, t, job, tblInfo, originalState != constraintInfo.State)
if err != nil {
return ver, errors.Trace(err)
}
job.FinishTableJob(model.JobStateDone, model.StatePublic, ver, tblInfo)
}

2. What did you expect to see? (Required)

see the constraint information

3. What did you see instead (Required)

may not see the constraint information

4. What is your TiDB version? (Required)

master
After #44455

@zimulala zimulala added the sig/sql-infra SIG: SQL Infra label Jun 16, 2023
@zimulala
Copy link
Contributor Author

PTAL @fzzf678

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants