Fix #21: Locks not available inside WHEN and ON statements