Skip to content

Commit

Permalink
Merge #55212
Browse files Browse the repository at this point in the history
55212: sql: bugfix to vtable lookup joins r=jordanlewis a=jordanlewis

Previously, vtable lookup joins had a memory aliasing bug that could
cause incorrect results in some circumstances. This bug is now fixed.

Fixes #55140

Release note (bug fix): prevent a crash in prerelease 20.2 binaries in
plans that use the new virtual table lookup join feature.

Co-authored-by: Jordan Lewis <[email protected]>
  • Loading branch information
craig[bot] and jordanlewis committed Oct 8, 2020
2 parents 6cab8b3 + be6cdc4 commit 7bc2bf9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/sql/rowcontainer/datum_row_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ func (c *RowContainer) NumCols() int {
return c.numCols
}

// At accesses a row at a specific index.
// At accesses a row at a specific index. Note that it does *not* copy the row:
// callers must copy the row if they wish to mutate it.
func (c *RowContainer) At(i int) tree.Datums {
// This is a hot-path: do not add additional checks here.
chunk, pos := c.getChunkAndPos(i)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/virtual_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (v *vTableLookupJoinNode) Next(params runParams) (bool, error) {
for {
// Check if there are any rows left to emit from the last input row.
if v.run.rows.Len() > 0 {
v.run.row = v.run.rows.At(0)
copy(v.run.row, v.run.rows.At(0))
v.run.rows.PopFirst(params.ctx)
return true, nil
}
Expand Down

0 comments on commit 7bc2bf9

Please sign in to comment.