[tarantool-patches] Re: [PATCH 2/2] sql: make LIKE predicate dependent on collation
n.pettik
korablev at tarantool.org
Thu Aug 1 13:27:07 MSK 2019
>>> * @param pisComplete True if the only wildcard is '%' in the
>>> * last character.
>>> * @retval True if the given expr is a LIKE operator & is
>>> @@ -276,9 +274,20 @@ like_optimization_is_valid(Parse *pParse, Expr *pExpr, Expr **ppPrefix,
>>> */
>>> return 0;
>>> }
>>> +
>>> + /* Only for "binary" and "unicode_ci" collations. */
>>
>> Why only two collations? Why not “unicode” for instance?
>> What if collation is a part of expression, not field:
>> … a COLLATE “unicode” LIKE … ?
> For instance, we consider the following query '... WHERE x LIKE "A%" COLLATE "unicode"' (strength - tertiary). The optimization will be: "A" <= x < "B". Let's take x == "aaa". Comparison of "aaa" and "A" gives us '1'. Comparison of "aaa" and "B" gives us '-1'. In other words, "A" <= "aaa" < "B", but it is a bad result, because "aaa" is not LIKE "A%" COLLATE "unicode”.
Ok, but occasionally test suite didn’t include test case
checking this situation. I’ve added it alongside with
clarifying comments and minor fixes and put on
the branch: np/sql-like-collation
https://github.com/tarantool/tarantool/tree/np/sql-like-collation
With these fixes LGTM.
More information about the Tarantool-patches
mailing list