partition: fix index join probe side will locate partition error when it's a table range scan (#44414)
close pingcap/tidb#43686
This commit is contained in:
@ -4276,6 +4276,9 @@ func (builder *dataReaderBuilder) buildTableReaderForIndexJoin(ctx context.Conte
|
||||
locateKey[keyColOffsets[i]] = data
|
||||
}
|
||||
p, err := pt.GetPartitionByRow(e.ctx, locateKey)
|
||||
if table.ErrNoPartitionForGivenValue.Equal(err) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -4320,6 +4323,9 @@ func (builder *dataReaderBuilder) buildTableReaderForIndexJoin(ctx context.Conte
|
||||
locateKey[keyColOffsets[i]] = data
|
||||
}
|
||||
p, err := pt.GetPartitionByRow(e.ctx, locateKey)
|
||||
if table.ErrNoPartitionForGivenValue.Equal(err) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -459,7 +459,8 @@ func TestPartitionOnMissing(t *testing.T) {
|
||||
tk.MustExec(`CREATE TABLE tt1 (
|
||||
id INT NOT NULL,
|
||||
listid INT,
|
||||
name varchar(10)
|
||||
name varchar(10),
|
||||
primary key (listid) clustered
|
||||
)
|
||||
PARTITION BY LIST (listid) (
|
||||
PARTITION p1 VALUES IN (1),
|
||||
@ -491,4 +492,14 @@ func TestPartitionOnMissing(t *testing.T) {
|
||||
|
||||
tk.MustQuery(`select /*+ inl_join(tt1)*/ count(*) from tt2
|
||||
left join tt1 on tt1.listid=tt2.listid and tt1.id=tt2.id`).Check(testkit.Rows("5"))
|
||||
tk.MustQuery(`select /*+ inl_join(tt1)*/ count(*) from tt2
|
||||
left join tt1 on tt1.listid=tt2.listid`).Check(testkit.Rows("5"))
|
||||
tk.MustQuery(`explain format = 'brief' select /*+ inl_join(tt1)*/ count(*) from tt2
|
||||
left join tt1 on tt1.listid=tt2.listid`).Check(testkit.Rows(""+
|
||||
"StreamAgg 1.00 root funcs:count(1)->Column#7",
|
||||
"└─IndexJoin 5.00 root left outer join, inner:TableReader, outer key:onmissing.tt2.listid, inner key:onmissing.tt1.listid, equal cond:eq(onmissing.tt2.listid, onmissing.tt1.listid)",
|
||||
" ├─IndexReader(Build) 5.00 root index:IndexFullScan",
|
||||
" │ └─IndexFullScan 5.00 cop[tikv] table:tt2, index:idx_listid(listid) keep order:false",
|
||||
" └─TableReader(Probe) 4.00 root partition:all data:TableRangeScan",
|
||||
" └─TableRangeScan 4.00 cop[tikv] table:tt1 range: decided by [onmissing.tt2.listid], keep order:false"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user