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

ddl, config: add a variable to control the max index length #15012

Merged
merged 5 commits into from
Mar 2, 2020

Conversation

zimulala
Copy link
Contributor

What problem does this PR solve?

Before #13727(v3.0.8):

create table t (a varchar(1000) primary key);
Query OK, 0 rows affected

After #13727:

tidb> create table t (a varchar(1000) primary key);
ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes

Therefore, in v3.0.8 and after, such statements will report an error, which is not compatible with the behavior of versions before v3.0.8.

What is changed and how it works?

Add a variable to control the max index length. And the value range is [3072, 3072*4].
The default value is 3072, it is consistent with MySQL.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Add a variable to control the maximum index length.

@zimulala zimulala added type/compatibility priority/release-blocker This issue blocks a release. Please solve it ASAP. needs-cherry-pick-3.0 labels Feb 28, 2020
@codecov
Copy link

codecov bot commented Feb 28, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@74e5b62). Click here to learn what that means.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #15012   +/-   ##
===========================================
  Coverage          ?   80.2819%           
===========================================
  Files             ?        502           
  Lines             ?     131458           
  Branches          ?          0           
===========================================
  Hits              ?     105537           
  Misses            ?      17553           
  Partials          ?       8368

@zimulala
Copy link
Contributor Author

zimulala commented Mar 2, 2020

PTAL @bb7133 @tangenta

Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated
// DefMaxIndexLength is the maximum index length. This value is consistent with MySQL.
DefMaxIndexLength = 3072
// DefTiDBMaxIndexLength is the maximum index length for TiDB v3.0.7 and previous version.
DefTiDBMaxIndexLength = 3072 * 4
Copy link
Contributor

@tangenta tangenta Mar 2, 2020

Choose a reason for hiding this comment

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

In the old implementation, the index length was not in bytes, but in characters.
That means if we set max-index-length to 12288 (3072 * 4), the following statement is valid in current PR but it is invalid in TiDB v3.0.7-.

create table t12 (a varchar(12288) character set ascii primary key);

Is it acceptable?

Copy link
Contributor Author

@zimulala zimulala Mar 2, 2020

Choose a reason for hiding this comment

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

It is acceptable.
We want to make the following statement is valid in current TiDB like in TiDB v3.0.7-.

create table t12 (a varchar(3072) character set utf8mb4 primary key);

config/config.toml.example Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

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

LGTM

@zimulala zimulala added require-LGT3 Indicates that the PR requires three LGTM. status/LGT2 Indicates that a PR has LGTM 2. component/DDL labels Mar 2, 2020
Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

djshow832
djshow832 previously approved these changes Mar 2, 2020
Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

LGTM

@zimulala zimulala added status/can-merge Indicates a PR has been approved by a committer. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Mar 2, 2020
@zimulala zimulala merged commit 1771cf8 into pingcap:master Mar 2, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Mar 2, 2020

/run-all-tests

sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Mar 2, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Mar 2, 2020

cherry pick to release-3.0 in PR #15057

@zimulala zimulala deleted the max-idx-len branch March 2, 2020 03:51
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Mar 3, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Mar 3, 2020

cherry pick to release-4.0 in PR #15083

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. require-LGT3 Indicates that the PR requires three LGTM. sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. type/compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants