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

ddl: tidb panic while query hash partition table with is null condition #23849

Merged
merged 26 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e0469fc
Merge pull request #1 from pingcap/master
Howie59 Mar 15, 2021
7d60de6
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Mar 18, 2021
0297c4a
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/Pingcap/tidb
Howie59 Apr 1, 2021
0738204
fix issue #23802
Howie59 Apr 1, 2021
4749140
add test
Howie59 Apr 2, 2021
d4aa60c
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/Pingcap/tidb
Howie59 Apr 5, 2021
73a1aa7
merge master
Howie59 Apr 5, 2021
07896d9
Merge branch 'master' into issue-23802
Howie59 Apr 7, 2021
0362a4b
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Apr 8, 2021
7c5327f
Merge branch 'master' into issue-23802
Howie59 Apr 13, 2021
382f2ce
Merge branch 'master' of https://github.com/pingcap/tidb
Howie59 Apr 15, 2021
1108209
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Apr 16, 2021
bf43b07
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Apr 17, 2021
9e41542
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Apr 19, 2021
dfc62d3
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Apr 20, 2021
0a469b2
Merge branch 'master' into issue-23802
Howie59 Apr 20, 2021
15dabc2
Merge branch 'master' into issue-23802
Howie59 Apr 21, 2021
27572fa
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Apr 23, 2021
b74d2d5
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb
Howie59 Apr 23, 2021
11ad4ec
Merge branch 'master' into issue-23802
Howie59 Apr 25, 2021
19a850b
add test
Howie59 Apr 25, 2021
75e9f66
Merge branch 'master' into issue-23802
Howie59 Apr 25, 2021
634ea2c
Merge branch 'master' of https://jackfan.us.kg.cnpmjs.org/pingcap/tidb i…
Howie59 May 26, 2021
af50bd4
drop table
Howie59 May 26, 2021
56fd857
Merge branch 'issue-23802' of https://jackfan.us.kg.cnpmjs.org/Howie59/t…
Howie59 May 26, 2021
02ae9d4
Merge branch 'master' into issue-23802
qw4990 Jun 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3473,6 +3473,20 @@ func (s *testIntegrationSuite) TestIssue23736(c *C) {
c.Assert(tk.MustUseIndex("select /*+ stream_agg() */ count(1) from t0 where c > 10 and b < 2", "c"), IsFalse)
}

// https://github.com/pingcap/tidb/issues/23802
func (s *testIntegrationSuite) TestPanicWhileQueryTableWithIsNull(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

tk.MustExec("drop table if exists NT_HP27193")
tk.MustExec("CREATE TABLE `NT_HP27193` ( `COL1` int(20) DEFAULT NULL, `COL2` varchar(20) DEFAULT NULL, `COL4` datetime DEFAULT NULL, `COL3` bigint(20) DEFAULT NULL, `COL5` float DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin PARTITION BY HASH ( `COL1`%`COL3` ) PARTITIONS 10;")
Howie59 marked this conversation as resolved.
Show resolved Hide resolved
_, err := tk.Exec("select col1 from NT_HP27193 where col1 is null;")
c.Assert(err, IsNil)
Howie59 marked this conversation as resolved.
Show resolved Hide resolved
tk.MustExec("INSERT INTO NT_HP27193 (COL2, COL4, COL3, COL5) VALUES ('m', '2020-05-04 13:15:27', 8, 2602)")
_, err = tk.Exec("select col1 from NT_HP27193 where col1 is null;")
c.Assert(err, IsNil)
}

func (s *testIntegrationSuite) TestIssue23846(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down
11 changes: 7 additions & 4 deletions planner/core/rule_partition_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ func (s *partitionProcessor) findUsedPartitions(ctx sessionctx.Context, tbl tabl
partIdx[i].Index = i
colLen = append(colLen, types.UnspecifiedLength)
}
datchedResult, err := ranger.DetachCondAndBuildRangeForPartition(ctx, conds, partIdx, colLen)
detachedResult, err := ranger.DetachCondAndBuildRangeForPartition(ctx, conds, partIdx, colLen)
if err != nil {
return nil, nil, err
}
ranges := datchedResult.Ranges
ranges := detachedResult.Ranges
used := make([]int, 0, len(ranges))
for _, r := range ranges {
if r.IsPointNullable(ctx.GetSessionVars().StmtCtx) {
Expand All @@ -142,7 +142,10 @@ func (s *partitionProcessor) findUsedPartitions(ctx sessionctx.Context, tbl tabl
break
}
}
pos, isNull, err := pe.EvalInt(ctx, chunk.MutRowFromDatums(r.HighVal).ToRow())
highLowVals := make([]types.Datum, 0, len(r.HighVal)+len(r.LowVal))
highLowVals = append(highLowVals, r.HighVal...)
highLowVals = append(highLowVals, r.LowVal...)
pos, isNull, err := pe.EvalInt(ctx, chunk.MutRowFromDatums(highLowVals).ToRow())
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -170,7 +173,7 @@ func (s *partitionProcessor) findUsedPartitions(ctx sessionctx.Context, tbl tabl
ret = append(ret, used[i])
}
}
return ret, datchedResult.RemainedConds, nil
return ret, detachedResult.RemainedConds, nil
}

func (s *partitionProcessor) convertToIntSlice(or partitionRangeOR, pi *model.PartitionInfo, partitionNames []model.CIStr) []int {
Expand Down