select 'a\' like 'a\'; -- error - LIKE pattern must not end with escape character select 'a' like 'a\'; -- f - query runs This doesn't make sense. The LIKE pattern is incorrect in both.
I've also checked around constant folding and runtime non-literal values by inserting into cte's and temp tables. Same outcome.
``` WITH a AS (SELECT 'xyz' AS value) SELECT value LIKE 'xyz\' AS result FROM a; ``` f
Working as designed.
Execution optimization combined with non-compilation.
You may not get a failure if the condition is proven to evaluate to false before encountering the malformed part of the expression. There is no compilation step that evaluates the supplied text for correctness independent of its usage. The input string running out of characters while the test string still has some is known to result in a false outcome.