Skip to content

Commit 1c2c145

Browse files
winorosti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#59763
Signed-off-by: ti-chi-bot <[email protected]>
1 parent e2696ed commit 1c2c145

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

pkg/planner/core/stats.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ func fillIndexPath(ds *logicalop.DataSource, path *util.AccessPath, conds []expr
189189
}
190190
// Don't add one column twice to the index. May cause unexpected errors.
191191
if !alreadyHandle {
192+
path.FullIdxCols = append(path.FullIdxCols, handleCol)
193+
path.FullIdxColLens = append(path.FullIdxColLens, types.UnspecifiedLength)
192194
path.IdxCols = append(path.IdxCols, handleCol)
193195
path.IdxColLens = append(path.IdxColLens, types.UnspecifiedLength)
194196
// Also updates the map that maps the index id to its prefix column ids.

tests/integrationtest/r/planner/core/issuetest/planner_issue.result

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ KEY `idx_65` (`col_36`(5))
760760
with cte_192 ( col_1101,col_1102,col_1103,col_1104 ) AS ( select /*+ use_index_merge( tl6e913fb9 ) */ replace( tl6e913fb9.col_36 , tl6e913fb9.col_36 , tl6e913fb9.col_36 ) as r0 , space( 0 ) as r1 , min( distinct tl6e913fb9.col_36 ) as r2 , count( distinct tl6e913fb9.col_36 ) as r3 from tl6e913fb9 where tl6e913fb9.col_36 between 'n92ok$B%W#UU%O' and '()c=KVQ=T%-vzGJ' and tl6e913fb9.col_36 in ( 'T+kf' ,'Lvluod2H' ,'3#Omx@pC^fFkeH' ,'=b$z' ) group by tl6e913fb9.col_36 having tl6e913fb9.col_36 = 'xjV@' or IsNull( tl6e913fb9.col_36 ) ) ( select 1,col_1101,col_1102,col_1103,col_1104 from cte_192 where not( IsNull( cte_192.col_1102 ) ) order by 1,2,3,4,5 limit 72850972 );
761761
1 col_1101 col_1102 col_1103 col_1104
762762
drop table if exists t;
763+
<<<<<<< HEAD
763764
create table t(a int, primary key (a));
764765
insert into t values(1), (2);
765766
select * from t t1 left join t t2 on t1.a=t2.a limit 1, 1;
@@ -797,3 +798,32 @@ MergeJoin_8 12475.01 root inner join, left key:test.t1.a, test.t1.b, right key:
797798
└─IndexReader_39(Probe) 9980.01 root index:Selection_38
798799
└─Selection_38 9980.01 cop[tikv] not(isnull(test.t1.b))
799800
└─IndexFullScan_37 9990.00 cop[tikv] table:t1, index:idx(a, b) keep order:true, stats:pseudo
801+
=======
802+
create table t (id int unique key, c int);
803+
insert into t values (1, 10);
804+
insert into t values (2, 20);
805+
insert into t values (3, 30);
806+
select _tidb_rowid from t where id in (1, 2, 3);
807+
_tidb_rowid
808+
1
809+
2
810+
3
811+
drop table if exists t, t1;
812+
create table t(a int);
813+
create table t1(a int primary key, b int, index idx(b));
814+
insert into t values(1), (2), (123);
815+
insert into t1 values(2, 123), (123, 2);
816+
set tidb_opt_fix_control='44855:on';
817+
explain select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;
818+
id estRows task access object operator info
819+
Projection_9 12.50 root test.t.a, test.t1.a, test.t1.b
820+
└─IndexJoin_12 12.50 root inner join, inner:IndexReader_11, outer key:test.t.a, inner key:test.t1.a, equal cond:eq(test.t.a, test.t1.a)
821+
├─TableReader_20(Build) 9990.00 root data:Selection_19
822+
│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t.a))
823+
│ └─TableFullScan_18 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
824+
└─IndexReader_11(Probe) 12.50 root index:IndexRangeScan_10
825+
└─IndexRangeScan_10 12.50 cop[tikv] table:t1, index:idx(b) range: decided by [eq(test.t1.a, test.t.a) eq(test.t1.b, 123)], keep order:false, stats:pseudo
826+
select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;
827+
a a b
828+
2 2 123
829+
>>>>>>> f66e8b1e796 (planner: fix the possible panic when fixcontrol#44855 enabled (#59763))

tests/integrationtest/t/planner/core/issuetest/planner_issue.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ with cte_192 ( col_1101,col_1102,col_1103,col_1104 ) AS ( select /*+ use_index_
530530

531531
# TestIssue59926
532532
drop table if exists t;
533+
<<<<<<< HEAD
533534
create table t(a int, primary key (a));
534535
insert into t values(1), (2);
535536
# safe to directly compare the output since the data is stored in one region. so the output is ordered in fact
@@ -544,3 +545,20 @@ create table t2(a int, b int, index idx(a));
544545
explain select /*+ merge_join(t1) */ * from t1 join t2 on t1.a=t2.a and t2.b=t1.b;
545546
explain select /*+ no_hash_join(t1), no_index_join(t1,t2), no_index_hash_join(t1,t2) */ * from t1 join t2 on t1.a=t2.a and t2.b=t1.b;
546547

548+
=======
549+
create table t (id int unique key, c int);
550+
insert into t values (1, 10);
551+
insert into t values (2, 20);
552+
insert into t values (3, 30);
553+
select _tidb_rowid from t where id in (1, 2, 3);
554+
555+
# TestIssue59762
556+
drop table if exists t, t1;
557+
create table t(a int);
558+
create table t1(a int primary key, b int, index idx(b));
559+
insert into t values(1), (2), (123);
560+
insert into t1 values(2, 123), (123, 2);
561+
set tidb_opt_fix_control='44855:on';
562+
explain select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;
563+
select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;
564+
>>>>>>> f66e8b1e796 (planner: fix the possible panic when fixcontrol#44855 enabled (#59763))

0 commit comments

Comments
 (0)