cockroach
cockroach copied to clipboard
opt: propagate extra columns for lock operators
A lock operator needs access to all primary key columns of the relations it locks. Therefore, all primary key columns should be propagated by a SELECT
clause with locking even if they weren't explicitly projected. Previously, only explicitly projected columns were considered when handling a nested scope, as for a subquery. This could lead to an internal error when the lock operator did not have access to the expected columns. This commit fixes the bug by propgating all primary key columns, not just explicit ones.
Fixes #129647
Release note (bug fix): Fixed a bug that could cause an internal error if a table with an implicit (rowid) primary key was locked from within a subquery, like this:
SELECT * FROM (SELECT * FROM foo WHERE x = 2) FOR UPDATE;