Fixes #4526: change validation query for the database