Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

lightning: evaluate all generated columns even if they are virtual #1407

Merged
merged 3 commits into from
Aug 6, 2021

Conversation

kennytm
Copy link
Collaborator

@kennytm kennytm commented Aug 3, 2021

What problem does this PR solve?

Fix #1404

What is changed and how it works?

Expression indices rely on a virtual generated column, which is not calculated by Lightning (unless depended by a stored generated column). This caused the virtual generated column to contain invalid value and thus invalidate the index.

This PR just calculates all generated columns no matter they are virtual or stored.

Check List

Tests

  • Integration test

Code changes

Side effects

  • Possible performance regression
    • Tables with only virtual generated columns will experience longer encoding time.

Related changes

  • Need to cherry-pick to the release branch
    • release-4.0, 5.0, 5.1 (everywhere that creating an index on virtual generated column is allowed)

Release note

  • Expression index and index depending on virtual generated columns are now valid. Previously these indices are broken when importing through Lightning local or importer backend.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 3, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • YuJuncen
  • glorv

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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@glorv
Copy link
Collaborator

glorv commented Aug 4, 2021

Why do this PR need to be cherry-picked into 4.0 and 5.0?

@kennytm
Copy link
Collaborator Author

kennytm commented Aug 4, 2021

@glorv the following schema works on 4.0 and I believe Lightning before this PR won't populate the b unique index correctly.

create table a(a int primary key, b int as (a + 1) virtual unique);

also, this flag exists on 4.0: https://docs.pingcap.com/zh/tidb/v4.0/tidb-configuration-file#allow-expression-index-%E4%BB%8E-v400-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5

@ti-chi-bot ti-chi-bot added the status/LGT1 LGTM1 label Aug 4, 2021
@@ -11,3 +11,6 @@ ssl-key = "/tmp/backup_restore_test/certs/tidb.key"
cluster-ssl-ca = "/tmp/backup_restore_test/certs/ca.pem"
cluster-ssl-cert = "/tmp/backup_restore_test/certs/tidb.pem"
cluster-ssl-key = "/tmp/backup_restore_test/certs/tidb.key"

[experimental]
allow-expression-index = true
Copy link
Member

Choose a reason for hiding this comment

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

It's removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

still needed when cherry-picking.

@ti-chi-bot ti-chi-bot added status/LGT2 LGTM2 and removed status/LGT1 LGTM1 labels Aug 6, 2021
@glorv
Copy link
Collaborator

glorv commented Aug 6, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 031fab4

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1417.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1418.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1419.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lightning] admin check failed after importing table with expression index using local backend
6 participants