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

planner, executor: return TableDual when tryFastPlan is promised to be false #10676

Merged
merged 4 commits into from Jun 4, 2019

Conversation

Projects
None yet
3 participants
@XuHuaiyu
Copy link
Contributor

commented Jun 3, 2019

What problem does this PR solve?

Fix #10678 .
Before this commit:

CREATE TABLE `t` (
  `pk` bigint(11) signed NOT NULL,
  PRIMARY KEY (`pk`)
);
tidb> SELECT `pk` FROM `t` WHERE `pk` = 18446744073709551615;
ERROR 1690 (22003): constant 18446744073709551615 overflows bigint

tidb> SELECT `pk` FROM `t` WHERE `pk` = 18446744073709551616;
Empty set (0.00 sec)
drop table t;
CREATE TABLE `t` (
  `pk` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`pk`)
);

tidb> desc select * from t where pk = 18446744073709551615;
+-------------------+-------+------+----------------------------------------------------------------------------+
| id                | count | task | operator info                                                              |
+-------------------+-------+------+----------------------------------------------------------------------------+
| TableReader_6     | 0.33  | root | data:TableScan_5                                                           |
| └─TableScan_5     | 0.33  | cop  | table:t, range:[18446744073709551615,+inf], keep order:false, stats:pseudo |
+-------------------+-------+------+----------------------------------------------------------------------------+
2 rows in set (0.00 sec)


After this commit:

CREATE TABLE `t` (
  `pk` bigint(11) signed NOT NULL,
  PRIMARY KEY (`pk`)
);
tidb> SELECT `pk` FROM `t` WHERE `pk` = 18446744073709551615;
Empty set (0.00 sec)
tidb> SELECT `pk` FROM `t` WHERE `pk` = 18446744073709551616;
Empty set (0.00 sec)
drop table t;
CREATE TABLE `t` (
  `pk` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`pk`)
);
tidb> desc select * from t where pk = 18446744073709551615;
+-------------+-------+------+--------------------------------------+
| id          | count | task | operator info                        |
+-------------+-------+------+--------------------------------------+
| Point_Get_1 | 1.00  | root | table:t, handle:18446744073709551615 |
+-------------+-------+------+--------------------------------------+
1 row in set (0.00 sec)

What is changed and how it works?

  1. Return TableDual when the constant overflows the range of the primary key type .
  2. Do not cache the prepared plan when the plan is TableDual.

Check List

Tests

  • Integration test

Code changes

  • Has exported function/method change

Side effects

N/A

Related changes

  • Need to cherry-pick to the release branch
@codecov

This comment has been minimized.

Copy link

commented Jun 3, 2019

Codecov Report

Merging #10676 into master will decrease coverage by 0.1047%.
The diff coverage is 70%.

@@               Coverage Diff                @@
##             master     #10676        +/-   ##
================================================
- Coverage   78.3279%   78.2232%   -0.1048%     
================================================
  Files           414        414                
  Lines         87666      87722        +56     
================================================
- Hits          68667      68619        -48     
- Misses        13854      13984       +130     
+ Partials       5145       5119        -26
@qw4990
Copy link
Contributor

left a comment

LGTM

Show resolved Hide resolved planner/core/point_get_plan.go Outdated
Show resolved Hide resolved planner/core/point_get_plan.go
@zz-jason
Copy link
Member

left a comment

LGTM

@zz-jason

This comment has been minimized.

Copy link
Member

commented Jun 4, 2019

/run-all-tests

@zz-jason zz-jason added status/LGT2 and removed status/LGT1 labels Jun 4, 2019

@XuHuaiyu XuHuaiyu merged commit b6cf05a into pingcap:master Jun 4, 2019

14 checks passed

ci/circleci Your tests passed on CircleCI!
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/build_check_race Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev_2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/common-test job succeeded
Details
idc-jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/mybatis-test job succeeded
Details
idc-jenkins-ci-tidb/sqllogic-test-1 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/sqllogic-test-2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@XuHuaiyu XuHuaiyu deleted the XuHuaiyu:point_get_overflow branch Jun 4, 2019

XuHuaiyu added a commit to XuHuaiyu/tidb that referenced this pull request Jun 4, 2019

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.