From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org, korablev@tarantool.org Cc: kostja@tarantool.org, Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v2 07/12] sql: move LIKE UConverter object to collation library Date: Wed, 10 Jul 2019 14:01:06 +0300 [thread overview] Message-ID: <ff03c5ec5f1e5c146b082252be1e533f470c823c.1562756438.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1562756438.git.kshcherbatov@tarantool.org> 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 <unicode/uchar.h> #include <unicode/ucol.h> -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 <unicode/ucol.h> +#include <unicode/ucnv.h> #include <unicode/ucasemap.h> #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
next prev parent reply other threads:[~2019-07-10 11:01 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-10 11:00 [tarantool-patches] [PATCH v2 00/12] sql: uniform SQL and Lua functions subsystem Kirill Shcherbatov 2019-07-10 11:00 ` [tarantool-patches] [PATCH v2 01/12] sql: get rid of SOUNDEX, MATCH Kirill Shcherbatov 2019-07-10 18:45 ` [tarantool-patches] " Konstantin Osipov 2019-07-12 8:44 ` Kirill Yukhin 2019-07-10 11:00 ` [tarantool-patches] [PATCH v2 10/12] sql: refactor builtins signatures with port Kirill Shcherbatov 2019-07-10 18:47 ` [tarantool-patches] " Konstantin Osipov 2019-07-11 7:33 ` Kirill Shcherbatov 2019-07-10 11:00 ` [tarantool-patches] [PATCH v2 11/12] box: use own vtab per each function object Kirill Shcherbatov 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 12/12] sql: use schema's func hash instead of FuncDef hash Kirill Shcherbatov 2019-07-10 20:22 ` [tarantool-patches] " Konstantin Osipov 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 02/12] sql: get rid of LIKELY, UNLIKELY and LIKEHOOD Kirill Shcherbatov 2019-07-10 19:02 ` [tarantool-patches] " Konstantin Osipov 2019-07-11 7:38 ` Kirill Shcherbatov 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 03/12] sql: put analyze helpers to FuncDef cache Kirill Shcherbatov 2019-07-10 19:04 ` [tarantool-patches] " Konstantin Osipov 2019-07-12 8:47 ` Kirill Yukhin 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 04/12] sql: rework LIKE case-insensitive mode Kirill Shcherbatov 2019-07-10 19:09 ` [tarantool-patches] " Konstantin Osipov 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 05/12] sql: replace bool is_derived_coll marker with flag Kirill Shcherbatov 2019-07-10 19:10 ` [tarantool-patches] " Konstantin Osipov 2019-07-12 8:48 ` Kirill Yukhin 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 06/12] sql: remove SQL_PreferBuiltin flag Kirill Shcherbatov 2019-07-10 19:11 ` [tarantool-patches] " Konstantin Osipov 2019-07-10 11:01 ` Kirill Shcherbatov [this message] 2019-07-12 8:49 ` [tarantool-patches] Re: [PATCH v2 07/12] sql: move LIKE UConverter object to collation library Kirill Yukhin 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 08/12] sql: rfc for SQL and Lua functions Kirill Shcherbatov 2019-07-10 19:17 ` [tarantool-patches] " Konstantin Osipov 2019-07-10 19:18 ` Konstantin Osipov 2019-07-11 7:40 ` Kirill Shcherbatov 2019-07-11 13:59 ` Kirill Yukhin 2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 09/12] box: introduce Lua persistent functions Kirill Shcherbatov 2019-07-10 19:26 ` [tarantool-patches] " Konstantin Osipov 2019-07-12 21:49 ` Konstantin Osipov 2019-07-13 13:55 ` Kirill Yukhin 2019-07-13 14:17 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=ff03c5ec5f1e5c146b082252be1e533f470c823c.1562756438.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=korablev@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v2 07/12] sql: move LIKE UConverter object to collation library' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox