From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id E11C8245EE for ; Wed, 10 Jul 2019 07:01:17 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yyOKmvc7rEPr for ; Wed, 10 Jul 2019 07:01:17 -0400 (EDT) Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id A27792106F for ; Wed, 10 Jul 2019 07:01:17 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 07/12] sql: move LIKE UConverter object to collation library Date: Wed, 10 Jul 2019 14:01:06 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org, korablev@tarantool.org Cc: kostja@tarantool.org, Kirill Shcherbatov Moved UConverter object to collation library. This is required to get rid of sqlRegisterBuiltinFunctions function in further patches. Needed for #4113, #2200, #2233 --- src/box/sql/func.c | 13 ++----------- src/lib/coll/coll.c | 7 ++++++- src/lib/coll/coll.h | 2 ++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index ae75a1c3c..21ce78c24 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -46,8 +46,6 @@ #include #include -static UConverter* pUtf8conv; - /* * Return the collating function associated with a function. */ @@ -659,7 +657,8 @@ randomBlob(sql_context * context, int argc, sql_value ** argv) } } -#define Utf8Read(s, e) ucnv_getNextUChar(pUtf8conv, &(s), (e), &status) +#define Utf8Read(s, e) \ + ucnv_getNextUChar(icu_utf8_conv, &(s), (e), &status) #define SQL_END_OF_STRING 0xffff #define SQL_INVALID_UTF8_SYMBOL 0xfffd @@ -1732,14 +1731,6 @@ sql_is_like_func(struct sql *db, struct Expr *expr, int *is_like_ci) void sqlRegisterBuiltinFunctions(void) { - /* - * Initialize default case map for UPPER/LOWER functions - * This structure is not freed at db exit, but that is ok. - */ - UErrorCode status = U_ZERO_ERROR; - - pUtf8conv = ucnv_open("utf8", &status); - assert(pUtf8conv); /* * The following array holds FuncDef structures for all of the functions * defined in this file. diff --git a/src/lib/coll/coll.c b/src/lib/coll/coll.c index 98e4d0e64..fa27bf34e 100644 --- a/src/lib/coll/coll.c +++ b/src/lib/coll/coll.c @@ -34,10 +34,12 @@ #include "diag.h" #include "assoc.h" #include +#include #include #include "tt_static.h" struct UCaseMap *icu_ucase_default_map = NULL; +struct UConverter *icu_utf8_conv = NULL; #define mh_name _coll struct mh_coll_key_t { @@ -420,7 +422,9 @@ coll_init() UErrorCode err = U_ZERO_ERROR; coll_cache = mh_coll_new(); icu_ucase_default_map = ucasemap_open("", 0, &err); - if (coll_cache == NULL || icu_ucase_default_map == NULL) + icu_utf8_conv = ucnv_open("utf8", &err); + if (coll_cache == NULL || icu_ucase_default_map == NULL || + icu_utf8_conv == NULL) panic("Can not create system collations cache"); } @@ -428,5 +432,6 @@ void coll_free() { ucasemap_close(icu_ucase_default_map); + ucnv_close(icu_utf8_conv); mh_coll_delete(coll_cache); } diff --git a/src/lib/coll/coll.h b/src/lib/coll/coll.h index 1f5b29a2e..dc343539e 100644 --- a/src/lib/coll/coll.h +++ b/src/lib/coll/coll.h @@ -55,6 +55,8 @@ struct UCollator; /** Default universal casemap for case transformations. */ extern struct UCaseMap *icu_ucase_default_map; +/** Default universal utf8 converter. */ +extern struct UConverter *icu_utf8_conv; /** * Collation. It has no unique features like name, id or owner. -- 2.21.0