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

plan: make USE INDEX(PRIMARY) works on the integer primary key #7298

Merged
merged 5 commits into from
Aug 8, 2018

Conversation

zz-jason
Copy link
Member

@zz-jason zz-jason commented Aug 7, 2018

What have you changed? (mandatory)

Take this as an example:

TiDB(localhost:4000) > create table t(a bigint primary key);
Query OK, 0 rows affected (0.11 sec)

TiDB(localhost:4000) > select * from t use index(`primary`) where a = 1;
ERROR 1176 (42000): Key 'primary' doesn't exist in table 't'

TiDB(localhost:4000) > explain select * from t ignore index(`primary`) where a = 1;
ERROR 1176 (42000): Key 'primary' doesn't exist in table 't'

This PR fixes this issue, makes the use index(primary) works when the primary key is an integer column. After this PR:

TiDB(localhost:4000) > explain select * from t use index(`primary`) where a = 1;
+-------------------+-------+------+------------------------------------------------------+
| id                | count | task | operator info                                        |
+-------------------+-------+------+------------------------------------------------------+
| TableReader_6     | 1.00  | root | data:TableScan_5                                     |
| └─TableScan_5     | 1.00  | cop  | table:t, range:[1,1], keep order:false, stats:pseudo |
+-------------------+-------+------+------------------------------------------------------+
2 rows in set (0.01 sec)

TiDB(localhost:4000) > explain select * from t ignore index(`primary`) where a = 1;
+-------------------+-------+------+------------------------------------------------------+
| id                | count | task | operator info                                        |
+-------------------+-------+------+------------------------------------------------------+
| TableReader_6     | 1.00  | root | data:TableScan_5                                     |
| └─TableScan_5     | 1.00  | cop  | table:t, range:[1,1], keep order:false, stats:pseudo |
+-------------------+-------+------+------------------------------------------------------+
2 rows in set (0.00 sec)

What is the type of the changes? (mandatory)

  • Bug fix (non-breaking change which fixes an issue)

How has this PR been tested? (mandatory)

  • existing tests
  • newly added unit test

Does this PR affect documentation (docs/docs-cn) update? (mandatory)

No

Does this PR affect tidb-ansible update? (mandatory)

No

Does this PR need to be added to the release notes? (mandatory)

release note:
Fix the the primary key doesn't exist error when the primary key is the table handle.

Refer to a related PR or issue link (optional)

Benchmark result if necessary (optional)

Add a few positive/negative examples (optional)

@zz-jason zz-jason added type/bugfix This PR fixes a bug. sig/planner SIG: Planner release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Aug 7, 2018
@zz-jason
Copy link
Member Author

zz-jason commented Aug 7, 2018

/run-all-tests

winkyao
winkyao previously approved these changes Aug 7, 2018
Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

coocood
coocood previously approved these changes Aug 8, 2018
Copy link
Member

@coocood coocood left a comment

Choose a reason for hiding this comment

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

LGTM

@coocood coocood added the status/LGT2 Indicates that a PR has LGTM 2. label Aug 8, 2018
@zz-jason zz-jason dismissed stale reviews from coocood and winkyao via 31ad818 August 8, 2018 05:14
@zz-jason
Copy link
Member Author

zz-jason commented Aug 8, 2018

@coocood @winoros PTAL

@jackysp
Copy link
Member

jackysp commented Aug 8, 2018

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants