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

Projects
None yet
4 participants
@zz-jason
Copy link
Member

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

This comment has been minimized.

Copy link
Member Author

commented Aug 7, 2018

/run-all-tests

@winkyao
Copy link
Member

left a comment

LGTM

@coocood
Copy link
Member

left a comment

LGTM

@coocood coocood added the status/LGT2 label Aug 8, 2018

@zz-jason zz-jason dismissed stale reviews from coocood and winkyao via 31ad818 Aug 8, 2018

@zz-jason

This comment has been minimized.

Copy link
Member Author

commented Aug 8, 2018

@coocood

coocood approved these changes Aug 8, 2018

@jackysp

This comment has been minimized.

Copy link
Member

commented Aug 8, 2018

/run-all-tests

@coocood coocood merged commit 2babfd9 into pingcap:master Aug 8, 2018

11 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
jenkins-ci-tidb/common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
jenkins-ci-tidb/mybatis-test Jenkins job succeeded.
Details
jenkins-ci-tidb/sqllogic-test Jenkins job succeeded.
Details
jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@zz-jason zz-jason deleted the zz-jason:dev/fix-pkishandle branch Aug 8, 2018

zz-jason added a commit to zz-jason/tidb that referenced this pull request Aug 8, 2018

zz-jason added a commit that referenced this pull request Aug 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.