Skip to content

Commit

Permalink
opt: copy ColSet in CreateLocalityOptimizedLookupJoinPrivateIncluding…
Browse files Browse the repository at this point in the history
…Cols

`CreateLocalityOptimizedLookupJoinPrivateIncludingCols` was mutating a
`opt.ColSet` field of another `LookupJoinPrivate` because it was calling
`ColSet.UnionWith` without copying the `ColSet` first. This commit fixes
the bug.

Fixes #88126

Release note: None
  • Loading branch information
mgartner committed Sep 19, 2022
1 parent 87ed064 commit 67f18b3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/sql/opt/xform/join_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,9 @@ func (c *CustomFuncs) CreateLocalityOptimizedLookupJoinPrivateIncludingCols(
lookupExpr, remoteLookupExpr memo.FiltersExpr, private *memo.LookupJoinPrivate, cols opt.ColSet,
) *memo.LookupJoinPrivate {
newPrivate := c.CreateLocalityOptimizedLookupJoinPrivate(lookupExpr, remoteLookupExpr, private)
// Make a copy of the columns to avoid mutating the original
// LookupJoinPrivate's columns.
newPrivate.Cols = newPrivate.Cols.Copy()
newPrivate.Cols.UnionWith(cols)
return newPrivate
}
Expand Down

0 comments on commit 67f18b3

Please sign in to comment.