Add semantic checking to unique constraints in AST

This avoids the unnecessary creation of an additional legacy query tree
for every statement.
Merge pull request #3048 from cleishm/no-legacy-verify

Add semantic checking to unique constraints in AST