mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
366f368d06
Trailing escape ('ab\') is disallowed in SQL, in standardese: "If an escape character is specified, then [...] If there is not a partitioning of the string PVC into substrings such that each substring has length 1 (one) or 2, no substring of length 1 (one) is the escape character ECV, and each substring of length 2 is the escape character ECV followed by either the escape character ECV, an <underscore> character, or the <percent> character, then an exception condition is raised: data exception - invalid escape sequence." I first thought this is checked already higher up in the stack, at least for const needles, as single trailing backslashes ('ab\') are rejected, but then I realized that ClickHouse quotes by default. I.e., double trailing backslashes ('ab\\') are not rejected but when interpreted as LIKE needle ('ab\') they should.
14 lines
362 B
SQL
14 lines
362 B
SQL
DROP TABLE IF EXISTS tab;
|
|
|
|
CREATE TABLE tab (haystack String, pattern String) engine = MergeTree() ORDER BY haystack;
|
|
|
|
INSERT INTO tab VALUES ('haystack', 'pattern\\');
|
|
|
|
-- const pattern
|
|
SELECT haystack LIKE 'pattern\\' from tab; -- { serverError 25 }
|
|
|
|
-- non-const pattern
|
|
SELECT haystack LIKE pattern from tab; -- { serverError 25 }
|
|
|
|
DROP TABLE IF EXISTS tab;
|