Skip to content

Commit 1418996

Browse files
committed
planner: document dead-end nil signal in makeBushyTree and fix test edges
1 parent 23acb64 commit 1418996

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

pkg/planner/core/joinorder/join_order.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,9 @@ func makeJoinWithDetector(detector *ConflictDetector, left, right *Node, vertexH
945945
if !checkResult.Connected() {
946946
checkResult = detector.TryCreateCartesianCheckResult(left, right)
947947
if checkResult == nil {
948+
// Dead end: no edge connects these fragments and cartesian
949+
// fallback is unavailable (see #69986 for the nil-deref panic
950+
// this would cause if we returned an error instead).
948951
return nil, nil
949952
}
950953
}
@@ -989,6 +992,9 @@ func makeBushyTree(ctx base.PlanContext, detector *ConflictDetector, cartesianNo
989992
return nil, err
990993
}
991994
if newJoin == nil {
995+
// Dead end: no real edge spans these fragments and cartesian
996+
// fallback is unavailable. Propagate nil to let the caller
997+
// fall through to the partial plan already built.
992998
return nil, nil
993999
}
9941000
iterNodes = append(iterNodes, newJoin)

pkg/planner/core/joinorder/join_order_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,18 @@ func TestMakeBushyTreeDeadEnd(t *testing.T) {
127127
detector := &ConflictDetector{
128128
allInnerJoin: false,
129129
innerEdges: []*edge{
130-
{tes: intset.NewFastIntSet(0, 1), idx: 0, joinType: base.InnerJoin, skipRules: true},
130+
{tes: intset.NewFastIntSet(0, 1), idx: 0, joinType: base.InnerJoin, skipRules: false},
131131
{
132132
tes: intset.NewFastIntSet(0, 1, 2, 3),
133133
idx: 2,
134134
joinType: base.InnerJoin,
135-
skipRules: true,
135+
skipRules: false,
136136
leftVertexes: intset.NewFastIntSet(0, 1),
137137
rightVertexes: intset.NewFastIntSet(2, 3),
138138
},
139139
},
140140
nonInnerEdges: []*edge{
141-
{tes: intset.NewFastIntSet(2, 3), idx: 1, joinType: base.LeftOuterJoin, skipRules: true,
141+
{tes: intset.NewFastIntSet(2, 3), idx: 1, joinType: base.LeftOuterJoin, skipRules: false,
142142
leftVertexes: intset.NewFastIntSet(2), rightVertexes: intset.NewFastIntSet(3)},
143143
},
144144
}

0 commit comments

Comments
 (0)