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

*: fix wrong replace or insert-on-dup behavior on prefixed clustered index #23091

Merged
merged 7 commits into from
Mar 9, 2021
Merged

*: fix wrong replace or insert-on-dup behavior on prefixed clustered index #23091

merged 7 commits into from
Mar 9, 2021

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Mar 3, 2021

What problem does this PR solve?

Issue Number: closes #23069, closes #23063

Problem Summary:

two question caused those two issues:

  • check duplicate logic for replace/insert-on-duplicate need use full row column value but use prefixed index value
  • on duplicate update for no-touched column need using full row column value but use prefixed index value

What is changed and how it works?

What's Changed, How it Works:

  • refactor and using TruncateIndexValue to truncate row value to prefix value to check index constrict
  • DecodeRawRowData shouldn't use handle value when handle's column is prefixed column

Related changes

  • n/a

Check List

Tests

  • Unit test

Side effects

  • n/a

Release note

  • n/a

This change is Reviewable

@lysu lysu added the type/bugfix This PR fixes a bug. label Mar 3, 2021
@lysu lysu requested a review from a team as a code owner March 3, 2021 14:04
@lysu lysu requested review from lzmhhh123 and removed request for a team March 3, 2021 14:04
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 3, 2021
@github-actions github-actions bot added sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels Mar 3, 2021
@lysu lysu requested review from coocood and tangenta March 4, 2021 02:34
@tangenta
Copy link
Contributor

tangenta commented Mar 9, 2021

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 9, 2021
if err != nil {
return nil, err
}
}
return toBeCheckRows, nil
}

func getKeysNeedCheckOneRow(ctx sessionctx.Context, t table.Table, row []types.Datum, nUnique int, handleCols []*table.Column, result []toBeCheckedRow) ([]toBeCheckedRow, error) {
func getKeysNeedCheckOneRow(ctx sessionctx.Context, t table.Table, row []types.Datum, nUnique int, handleCols []*table.Column,
idxHandleCols []*model.IndexColumn, result []toBeCheckedRow) ([]toBeCheckedRow, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pass the primary index directly instead of its IndexColumn slice?

dt, err = tablecodec.Unflatten(dt, &col.FieldType, ctx.GetSessionVars().Location())
if err != nil {
return nil, nil, err
if notPrefixCol {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about
useHandleData := if col.IsCommonHandleColumn(meta) && !types.CommonHandleNeedRestoredData(&col.FieldType) && if notPrefixCol

if useHandleData {
...
} else {
...
}

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • tangenta
  • wjhuang2016

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 9, 2021
Signed-off-by: lysu <[email protected]>
@lysu
Copy link
Contributor Author

lysu commented Mar 9, 2021

/run-all-tests

@coocood
Copy link
Member

coocood commented Mar 9, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 3c7a2df

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 9, 2021
@ti-chi-bot ti-chi-bot merged commit b8f6ac0 into pingcap:master Mar 9, 2021
@lysu lysu deleted the dev-fix-replace-on-dup-clustered branch March 9, 2021 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
5 participants