Use ModelSQL.lock to lock table when validating SQL constraint
Since c8771e45b861 locking table must be performed at the start of the
transaction which is managed by the Transaction.lock_table
method which is
used by ModelSQL.lock
but not Database.lock
.
Closes #13626 (closed)