(PDB-950) Added validation for regexps in queries

This commit adds a validation for regexps in queries as was proposed in PDB-950
> I was thinking about it too, but HSQLDB supports Java regexp rules. Do we support 2 different regexp syntaxes depending on which DB is used?

Yes we do, for good or bad. And what's more, HSQLDB is not the major case we support ... PG is. We've been reducing support for HSQLDB if anything.

> Just found a difference between Java and POSIX regexp syntax in character classes: http://www.regular-expressions.info/posixbrackets.html
> But overall they look similar to each other.

We'd need to dig in deep to ensure this at least, or I'd be very very careful at least to say that its safe to make a 1 to 1 mapping. I'm wary basically :-).

> I think I can create 2 different validators: for HSQLDB and for PG. However, I am not sure if it is possible to validate PG(POSIX) regexp without executing DB query (which can probably affect the performance). Do you want me to do this?

Well, its okay to validate this way, but you might as well do the full query at the same time and instead throw a more meaningful error when it fails. This is not validation up front really, having said that I wouldn't expect a query to pause if a regexp is incorrect, it should throw an error quite quickly. Maybe this is just overall a more 'correct' approach? The JDBC driver should be expressing a reasonably correct regular expression error. The problem stems from the fact that its then hard to tell the user which query in the context of our AST style querying language that actually failed, because once its SQL its hard to track it back to the original part.

Overall this is an interesting problem.