Commit d8eb072
committed
opt: fix optional filter removal for lookup join
Fixes #159660
Previously, we don't reset the `optionalMultiValFilterSuffixLen` when we
find a necessary multi-val filter for a column. This would cause an incorrect
removal of an unoptional filter.
For example,
- Index: (x, y ,z)
- ON filters: x = 1, z IN (1, 2)
- Optional filters: y IN (3, 4)
Since the filters are processed with the order of columns in the index,
the filters will be processed in the order of `x = 1`, `y IN (3, 4)`,
`z IN (1, 2)`.
When the processing reaches `y IN (3, 4)`, since it is an optional filter,
`optionalMultiValFilterSuffixLen = 1`. But `z IN (1, 2)` is actually a
necessary filter, with `optionalMultiValFilterSuffixLen` not being reset,
it will be eventually wrongly removed.
Release note (bug fix): Fixed a bug causing a query predicate to be ignored
when the predicate is on a column following one or more ENUM columns in an
index, the predicate constrains the column to multiple values, and a lookup
join to the index is chosen for the query plan. This bug was introduced in
24.3.0 and present in all versions since.1 parent e29fd33 commit d8eb072
File tree
4 files changed
+47
-0
lines changed- pkg/sql/opt
- lookupjoin
- testdata
- xform/testdata/rules
4 files changed
+47
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
351 | 352 | | |
352 | 353 | | |
353 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
194 | 201 | | |
195 | 202 | | |
196 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3123 | 3123 | | |
3124 | 3124 | | |
3125 | 3125 | | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
3126 | 3158 | | |
3127 | 3159 | | |
3128 | 3160 | | |
| |||
0 commit comments