[tarantool-patches] Re: [PATCH 2/2] sql: remove GLOB from Tarantool

Alexander Turenko alexander.turenko at tarantool.org
Fri Nov 9 15:18:28 MSK 2018


Hi!

See comments below.

WBR, Alexander Turenko.

On Thu, Nov 08, 2018 at 06:09:23PM +0300, Nikita Tatunov wrote:
> Hello! thank you for the review.
> 
> Issues:
> https://github.com/tarantool/tarantool/issues/3251 <https://github.com/tarantool/tarantool/issues/3251>
> https://github.com/tarantool/tarantool/issues/3334 <https://github.com/tarantool/tarantool/issues/3334>
> 
> Branch:
> https://github.com/tarantool/tarantool/tree/N_Tatunov/gh-3251-where-like-hangs <https://github.com/tarantool/tarantool/tree/N_Tatunov/gh-3251-where-like-hangs>
> 

It seems you forgot to push the new changes.

> @@ -913,7 +899,7 @@ likeFunc(sqlite3_context *context, int argc, sqlite3_value **argv)
>  	sqlite3_like_count++;
>  #endif
>  	int res;
> -	res = sql_utf8_pattern_compare(zB, zA, *is_like_ci, escape);
> +	res = sql_utf8_pattern_compare(zB, zA, is_like_ci, escape);
>  	if (res == SQL_INVALID_PATTERN) {
>  		const char *const err_msg =
>  			"LIKE pattern can only contain UTF-8 characters";
> @@ -1698,24 +1684,20 @@ setLikeOptFlag(sqlite3 * db, const char *zName, u8 flagVal)
>   * @retval none.
>   */
>  void
> -sqlite3RegisterLikeFunctions(sqlite3 *db, int is_case_sensitive)
> +sqlite3RegisterLikeFunctions(sqlite3 *db, int *is_case_insensitive)
>  {
>  	/*
>  	 * FIXME: after introducing type <BOOLEAN> LIKE must
>  	 * return that type: TRUE if the string matches the
>  	 * supplied pattern and FALSE otherwise.
>  	 */
> -	int *is_like_ci;
> -	if (is_case_sensitive)
> -		is_like_ci = (void *)&case_sensitive_like;
> -	else
> -		is_like_ci = (void *)&case_insensitive_like;
> -	sqlite3CreateFunc(db, "LIKE", AFFINITY_INTEGER, 2, 0, is_like_ci,
> -			  likeFunc, 0, 0, 0);
> -	sqlite3CreateFunc(db, "LIKE", AFFINITY_INTEGER, 3, 0, is_like_ci,
> -			  likeFunc, 0, 0, 0);
> +	int is_like_ci = SQLITE_PTR_TO_INT(is_case_insensitive);
> +	sqlite3CreateFunc(db, "LIKE", AFFINITY_INTEGER, 2, 0,
> +			  is_case_insensitive, likeFunc, 0, 0, 0);
> +	sqlite3CreateFunc(db, "LIKE", AFFINITY_INTEGER, 3, 0,
> +			  is_case_insensitive, likeFunc, 0, 0, 0);
>  	setLikeOptFlag(db, "LIKE",
> -		       is_case_sensitive ? (SQLITE_FUNC_LIKE |
> +		       !(is_like_ci) ? (SQLITE_FUNC_LIKE |
>  		       SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
>  }

I think sqlite3RegisterLikeFunctions should accept int as the second
parameter.

BTW, it seems that we add SQLITE_FUNC_CASE into flags, so maybe we can
read it in likeFunc and don't pass additional parameter at all? It is
just raw idea, I don't know the mechanics of sql functions much.

> diff --git a/test/sql-tap/collation.test.lua b/test/sql-tap/collation.test.lua
> index eb4f43a90..dbbe1c0fe 100755
> --- a/test/sql-tap/collation.test.lua
> +++ b/test/sql-tap/collation.test.lua
> @@ -219,7 +219,7 @@ local like_testcases =
>          {0, {"Aab", "aaa"}} },
>      {"2.1.2",
>          "EXPLAIN QUERY PLAN SELECT * FROM tx1 WHERE s1 LIKE 'A%';",
> -        {0, {0, 0, 0, "/USING COVERING INDEX I1/"}} },
> +        {0, {0, 0, 0, "SEARCH TABLE TX1 USING COVERING INDEX I1 (S1>? AND S1<?)"}}},

What is this hunk about?




More information about the Tarantool-patches mailing list