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

Can't find column when uses the clustered index #23906

Closed
wjhuang2016 opened this issue Apr 7, 2021 · 3 comments · Fixed by #23933
Closed

Can't find column when uses the clustered index #23906

wjhuang2016 opened this issue Apr 7, 2021 · 3 comments · Fixed by #23933
Assignees
Labels
component/expression severity/critical sig/planner SIG: Planner sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@wjhuang2016
Copy link
Member

wjhuang2016 commented Apr 7, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `tbl_1` (
  `col_5` bigint(20) unsigned DEFAULT NULL,
  `col_6` double NOT NULL,
  `col_7` tinyint(4) NOT NULL DEFAULT '-47',
  `col_8` smallint(5) unsigned NOT NULL,
  `col_9` date DEFAULT NULL,
  PRIMARY KEY (`col_8`,`col_6`,`col_7`) /*T![clustered_index] CLUSTERED */,
  KEY `idx_5` (`col_9`,`col_8`),
  KEY `idx_6` (`col_6`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE ( `col_7` ) (
  PARTITION `p0` VALUES LESS THAN (-87),
  PARTITION `p1` VALUES LESS THAN (-44),
  PARTITION `p2` VALUES LESS THAN (46),
  PARTITION `p3` VALUES LESS THAN (118),
  PARTITION `p4` VALUES LESS THAN (127)
);
desc select  /*+ use_index_merge( tbl_1 ) */ col_5 from tbl_1 where tbl_1.col_6 >= 9637.317973853435 or tbl_1.col_9 in ( '1975-07-15' , '1999-11-30' ) and tbl_1.col_8 = 6073 and tbl_1.col_5 in ( 6390338814472142299 ) or tbl_1.col_8 <= 17132 or tbl_1.col_6 <> 4755.671685443747 or tbl_1.col_8 <= 39946 and tbl_1.col_6 in ( 6283.76957320476 , 6046.095273053335 , 9637.317973853435 , 7405.304278203997 , 3924.166154298398 , 7651.113042850394 , 4618.630644850198 , 5969.08193059866 , 6283.76957320476 , 6283.76957320476 ) and tbl_1.col_6 in ( 7150.103012479594 , 8579.144890325371 , 9495.762329500238 ) and tbl_1.col_9 <> '1999-11-30';

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

No error

3. What did you see instead (Required)

ERROR 1105 (HY000): Can't find column clustered_index_go_c_1617801763.tbl_1.col_7 in schema Column: [clustered_index_go_c_1617801763.tbl_1.col_5,clustered_index_go_c_1617801763.tbl_1.col_6,clustered_index_go_c_1617801763.tbl_1.col_8,clustered_index_go_c_1617801763.tbl_1.col_9] Unique key: []

4. What is your TiDB version? (Required)

master

@wjhuang2016 wjhuang2016 added the type/bug The issue is confirmed as a bug. label Apr 7, 2021
@eurekaka eurekaka self-assigned this Apr 9, 2021
@tangenta
Copy link
Contributor

tangenta commented Apr 9, 2021

Minimal reproducible case:

drop table if exists t;
create table t (a int, b int, c int, primary key (a, b) clustered, key idx_c(c));
select /*+ use_index_merge(t) */ c from t where c > 10 or a < 1;

This is introduced in #22940 (support pruning common handle columns).

@eurekaka
Copy link
Contributor

eurekaka commented Apr 9, 2021

Another reproduction:

MySQL [test]> create table t (
    ->   c1 float, c2 int, c3 int,
    ->   primary key (c1) /*T![clustered_index] CLUSTERED */,
    ->   key idx_1 (c2), key idx_2 (c3)
    -> );
Query OK, 0 rows affected (0.02 sec)

MySQL [test]> desc select /*+ use_index_merge(t) */ c3 from t where c3 = 1 or c2 = 1;
ERROR 1105 (HY000): Can't find column test.t.c1 in schema Column: [test.t.c2,test.t.c3] Unique key: []

@ti-srebot
Copy link
Contributor

ti-srebot commented Apr 14, 2021

Bug

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

5. Affected versions

[v5.0.0:v5.0.0]

6. Fixed versions

v5.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression severity/critical sig/planner SIG: Planner sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants