Rebuilt the advisory lock query in a more convenient form.