issue #19593: attaching a list relation pays attention to locks

Has the lockfix commit as well, which is in its own pull request.