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

got wrong result while use expression index #27159

Closed
aytrack opened this issue Aug 12, 2021 · 1 comment · Fixed by #27170
Closed

got wrong result while use expression index #27159

aytrack opened this issue Aug 12, 2021 · 1 comment · Fixed by #27170
Assignees
Labels

Comments

@aytrack
Copy link
Contributor

aytrack commented Aug 12, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t3` (
  `a` date DEFAULT NULL,
  `b` datetime DEFAULT NULL,
  `c` time DEFAULT NULL,
  `d` timestamp NULL DEFAULT NULL,
  `e` year(4) DEFAULT NULL,
  KEY `expression_index` ((adddate(`a`, interval 10 microsecond)))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

insert into t3 values ('2021-01-02', '2021-03-30 08:10:00', '12:01:03', UTC_TIMESTAMP(), 2021);
select * from t3 use index(expression_index) where ADDDATE(a, interval 10 MICROSECOND) = ADDDATE('2021-01-02', interval 10 MICROSECOND);
select * from t3 ignore index(expression_index) where ADDDATE(a, interval 10 MICROSECOND) = ADDDATE('2021-01-02', interval 10 MICROSECOND);

2. What did you expect to see? (Required)

result should be same when use and ignore index

3. What did you see instead (Required)

MySQL root@127.0.0.1:test> select * from t3 use index(expression_index) where ADDDATE(a, interval 10 MICROSECOND) = ADDDATE('2021-01-02', interval 10 MICROSECOND);
+---+---+---+---+---+
| a | b | c | d | e |
+---+---+---+---+---+

0 rows in set
Time: 0.006s
MySQL root@127.0.0.1:test> select * from t3 ignore index(expression_index) where ADDDATE(a, interval 10 MICROSECOND) = ADDDATE('2021-01-02', interval 10 MICROSECOND);
+------------+---------------------+----------+---------------------+------+
| a          | b                   | c        | d                   | e    |
+------------+---------------------+----------+---------------------+------+
| 2021-01-02 | 2021-03-30 08:10:00 | 12:01:03 | 2021-08-12 02:27:35 | 2021 |
+------------+---------------------+----------+---------------------+------+

4. What is your TiDB version? (Required)

MySQL root@127.0.0.1:test> select tidb_version()\G
***************************[ 1. row ]***************************
tidb_version() | Release Version: v5.2.0-alpha-572-g6b8c15301
Edition: Community
Git Commit Hash: 6b8c1530164be17486935b3be250c8aab6072e73
Git Branch: master
UTC Build Time: 2021-08-10 08:52:58
GoVersion: go1.16.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

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

Successfully merging a pull request may close this issue.

4 participants