-
Notifications
You must be signed in to change notification settings - Fork 0
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
table: support check constraint in insert and update #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
table/tables/tables.go
Outdated
t.tableID = tblInfo.ID | ||
t.physicalTableID = physicalTableID | ||
t.allocs = allocs | ||
t.meta = tblInfo | ||
t.Columns = cols | ||
t.PublicConstraints = constraints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about rename t.PublicConstraints
to t.Constraints
, which means the constraints in all state?
} | ||
writeableConstraint := make([]*table.Constraint, 0, len(t.PublicConstraints)) | ||
for _, con := range t.PublicConstraints { | ||
if con.State == model.StateDeleteOnly || con.State == model.StateDeleteReorganization { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constraint only has 3 state: None -> WriteOnly -> Public, but the code correctness here is ok.
if shouldWriteBinlog(ctx) && !t.canSkipUpdateBinlog(col, value) { | ||
binlogColIDs = append(binlogColIDs, col.ID) | ||
binlogOldRow = append(binlogOldRow, oldData[col.Offset]) | ||
binlogNewRow = append(binlogNewRow, value) | ||
} | ||
} | ||
|
||
if len(t.WritableConstraint()) != 0 { | ||
for _, constraint := range t.WritableConstraint() { | ||
ok, isNull, err := constraint.ConstraintExpr.EvalInt(ctx, chunk.MutRowFromDatums(rowToCheck).ToRow()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be EvalBool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EvalBool
has some problem, which sometimes can not return correct isNull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* mysql: Add NO_AUTO_CREATE_USER detection * mysql: Update Default SQL Mode * Include No_auto_create_user and only_full_group_by
What problem does this PR solve?
close pingcap#17425
What is changed and how it works?
Constraint
classUpdateRecord
andAddRecord
Check List
Tests
Code changes
Side effects
Related changes
Release note