Added locking-related SQL queries.