-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
partition: make ExchangePartition follow check constraints(part1) #46021
partition: make ExchangePartition follow check constraints(part1) #46021
Conversation
Hi @jiyfhust. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @jiyfhust. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #46021 +/- ##
================================================
+ Coverage 73.0847% 73.4362% +0.3514%
================================================
Files 1335 1359 +24
Lines 397994 412370 +14376
================================================
+ Hits 290873 302829 +11956
- Misses 88382 90995 +2613
+ Partials 18739 18546 -193
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/test check-dev |
@jiyfhust: The specified target(s) for
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
It is ready for review now. @mjonss |
ddl/partition.go
Outdated
pCons := getWriteableConstraintExpr(pt.Constraints) | ||
nCons := getWriteableConstraintExpr(nt.Constraints) | ||
if len(pCons) > 0 { | ||
if err := verifyFunc(nschemaName, nt.Name.L, "", pCons); err != nil { |
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.
Would it be possible to combine this with the verification in checkExchangePartitionRecordValidation
so we can do a single scan of the non-partitioned table, and fail at the first row that neither match the partition or the partitioned tables condition?
PTAL @mjonss |
ddl/partition.go
Outdated
@@ -2446,6 +2453,21 @@ func (w *worker) onExchangeTablePartition(d *ddlCtx, t *meta.Meta, job *model.Jo | |||
job.State = model.JobStateRollingback | |||
return ver, errors.Trace(err) | |||
} | |||
if variable.EnableCheckConstraint.Load() { |
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.
I would prefer if the check is combined with the checkExchangePartitionRecordValidation
above, to only do a single scan of the non-partitioned table.
/retest |
1 similar comment
/retest |
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.
Please create a followup issue, to test null handling in validation, since I assume there may be hidded issues in non-list cases?
buf.WriteString("mod(") | ||
buf.WriteString(pi.Expr) | ||
buf.WriteString(", %?) != %?") |
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.
Are there any tests that validates NULLs for Hash partitions? (not blocking this PR, just curious)
if variable.EnableCheckConstraint.Load() { | ||
ncc, ok := ntbl.(CheckConstraintTable) | ||
if !ok { | ||
return errors.Errorf("exchange partition process assert table partition failed") | ||
} | ||
nCons := ncc.WritableConstraint() | ||
if len(nCons) > 0 { | ||
buf.Reset() | ||
buf.WriteString("select 1 from %n.%n partition(%n) where ") | ||
buf.WriteString(genConstraintCondition(nCons)) | ||
buf.WriteString(" limit 1") | ||
err = verifyFunc(buf.String(), pschemaName, pt.Name.L, partitionName) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
} |
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.
More of a note, a future improvement may be to run the validations in parallel.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mjonss, tiancaiamao The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
Issue created #47167. |
/retest |
2 similar comments
/retest |
/retest |
What problem does this PR solve?
Issue Number: close #45922
Problem Summary:
What is changed and how it works?
Part1:
only verify records by check constraints.
prohibiting insert or update records which not satisfy check constraints is not included.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.