From d6bd25cc5241428001a30749b647df8ccdec82e8 Mon Sep 17 00:00:00 2001 From: DrewKimball Date: Wed, 21 Sep 2022 13:40:10 -0700 Subject: [PATCH] opt: mark SimplifyRange as essential This commit marks the `SimplifyRange` normalization rule as essential during random rule-disabling tests. This is necessary because `RangeExpr` is expected to maintain the invariant that its input is always an `AndExpr`. Other rules can replace the `AndExpr` with a different expression over the course of normalization, at which point the `RangeExpr` needs to be removed. Otherwise, various code-paths that depend on the invariant may panic (for example, predicate implication). Fixes #88352 Release note: None --- pkg/sql/opt/xform/optimizer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/sql/opt/xform/optimizer.go b/pkg/sql/opt/xform/optimizer.go index e830c1f77b89..271c8d86dc4f 100644 --- a/pkg/sql/opt/xform/optimizer.go +++ b/pkg/sql/opt/xform/optimizer.go @@ -1042,6 +1042,8 @@ func (o *Optimizer) disableRulesRandom(probability float64) { // Needed to make sure that dummy columns are pruned so that the // database name is retrieved correctly. int(opt.PruneScanCols), + // Needed to ensure that the input of a RangeExpr is always an AndExpr. + int(opt.SimplifyRange), ) var disabledRules RuleSet