From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org, korablev@tarantool.org Cc: kostja@tarantool.org, vdavydov.dev@gmail.com, Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [PATCH v1 11/12] sql: move LIKE UConverter object to collation library Date: Mon, 8 Jul 2019 14:26:17 +0300 [thread overview] Message-ID: <1d45e96a5f07a7520085b3e542fb6e544607cb11.1562584567.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1562584567.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 e137f6999..6000b7971 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -48,8 +48,6 @@ #include <unicode/uchar.h> #include <unicode/ucol.h> -static UConverter* pUtf8conv; - /* * Return the collating function associated with a function. */ @@ -787,7 +785,8 @@ sql_builtin_random_blob(struct func *func, struct port *args, struct port *ret) return sqlVdbeMemSetStr(val, p, n, 0, SQL_DYNAMIC) != 0 ? -1 : 0; } -#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 @@ -2054,14 +2053,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-08 11:26 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-08 11:26 [PATCH v1 00/12] sql: uniform SQL and Lua functions subsystem Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 01/12] sql: rfc for SQL and Lua functions Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 10/12] sql: remove SQL_PreferBuiltin flag Kirill Shcherbatov 2019-07-08 11:26 ` Kirill Shcherbatov [this message] 2019-07-08 11:26 ` [PATCH v1 12/12] sql: use schema's func hash instead of FuncDef hash Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 02/12] sql: get rid of SOUNDEX, MATCH Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 03/12] sql: get rid of LIKELY, UNLIKELY and LIKEHOOD Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 04/12] box: introduce Lua persistent functions Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 05/12] sql: put analyze helpers to FuncDef cache Kirill Shcherbatov 2019-07-09 15:56 ` [tarantool-patches] " n.pettik 2019-07-08 11:26 ` [PATCH v1 06/12] sql: rework LIKE case-insensitive mode Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 07/12] sql: replace bool is_derived_coll marker with flag Kirill Shcherbatov 2019-07-09 16:13 ` [tarantool-patches] " n.pettik 2019-07-08 11:26 ` [PATCH v1 08/12] sql: refactor builtins signatures with port Kirill Shcherbatov 2019-07-08 11:26 ` [PATCH v1 09/12] box: use own vtab per each function object Kirill Shcherbatov
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=1d45e96a5f07a7520085b3e542fb6e544607cb11.1562584567.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=korablev@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH v1 11/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