From 266d8f7f7275c03ae7f4f8f6188b0a0e4e6ac3ba Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Tue, 12 Dec 2023 09:22:50 +0800 Subject: [PATCH] planner: check nil pointer in rule_result_reorder to avoid panic (#48100) (#48116) close pingcap/tidb#45044 --- planner/core/rule_result_reorder.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/planner/core/rule_result_reorder.go b/planner/core/rule_result_reorder.go index a182501cc05e1..577072e21777e 100644 --- a/planner/core/rule_result_reorder.go +++ b/planner/core/rule_result_reorder.go @@ -106,6 +106,9 @@ func (rs *resultReorder) extractHandleCol(lp LogicalPlan) *expression.Column { switch x := lp.(type) { case *LogicalSelection, *LogicalLimit: handleCol := rs.extractHandleCol(lp.Children()[0]) + if handleCol == nil { + return nil // fail to extract handle column from the child, just return nil. + } if x.Schema().Contains(handleCol) { // some Projection Operator might be inlined, so check the column again here return handleCol