From: "n.pettik" <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Subject: [tarantool-patches] Re: [PATCH 2/3] Add surrogate ID for BINARY collation Date: Wed, 31 Oct 2018 18:47:45 +0300 [thread overview] Message-ID: <2A51C9E8-2A24-4F04-ABF1-0983F4322E82@tarantool.org> (raw) In-Reply-To: <f72b09c8-2994-6edc-8151-83fb9b42fab7@tarantool.org> > On 31 Oct 2018, at 15:34, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> wrote: > > Hi! Thanks for the patch! See 3 comments below. > >> diff --git a/src/box/key_def.h b/src/box/key_def.h >> index 20e79f9fe..ecdc199d9 100644 >> --- a/src/box/key_def.h >> +++ b/src/box/key_def.h >> @@ -78,6 +78,23 @@ extern const struct key_part_def key_part_def_default; >> */ >> #define COLL_NONE UINT32_MAX >> +/** >> + * In SQL explicitly specified binary collation and absence of >> + * any collation are different in behaviour: according to ANSI >> + * it is prohibited to compare strings with different explicitly >> + * indicated collations. However, if one of collation is default, >> + * (i.e. absent) the second one will be forced. >> + * So, lets introduce another id to indicate explicitly specified >> + * binary collation. > > 1. Sorry, I am not sure that we can use imperative while > describing not functions. OK, I’ll re-phrase it (still strange rule). > > 2. I see, that you actually created a 'phantom' collation. > A collation, that has no a record in the collation cache, > but is visible to a user via space format. I think for > externally visible changes you should consult Kostja. > Alternatively, it is possible to create binary collation > in the same way as unicode and unicode_ci - via insertion > into _collation in upgrade script. > > Also, I see a bug that we can create a collation in > _collation with id = COLL_NONE and COLL_BINARY, but which > actually are not NONE nor BINARY. Storing such identifiers > in _collation should be prohibited (if we will leave current > 'phantom' binary collation as is). Furthermore COLL_NONE > for unknown reason is declared in key_def.h instead of > coll_id.h. It should be moved out. It is worth to create a > separate commit with refactoring right before this one. I asked Vladimir before implementing this patch, and we decided to avoid adding real collation struct to cache, since in this case we would get *tiny but still* overhead in the form of calling additional collations functions. However, I agree that creating collations with ids COLL_NONE and COLL_BINARY should be banned. I am going to re-ask Vladimir and Konstantin and in case they don’t mind, I will expose patch-set with additional commit containing these checks. > >> + */ >> +#define COLL_BINARY (UINT32_MAX - 1) >> + >> +static inline bool >> +coll_is_missing(uint32_t coll_id) >> +{ >> + return coll_id == COLL_NONE || coll_id == COLL_BINARY; >> +} > > Hence, this should be moved to coll_id.h as well and > renamed to coll_id_is_missing. Ok, I am going to put this refactoring in a separate commit as well and resend patch-set as v2. > >> diff --git a/test/sql/collation.test.lua b/test/sql/collation.test.lua >> index 935dea824..f9d653717 100644 >> --- a/test/sql/collation.test.lua >> +++ b/test/sql/collation.test.lua >> @@ -42,4 +42,12 @@ cn = remote.connect(box.cfg.listen) >> cn:execute('select 1 limit ? collate not_exist', {1}) >> cn:close() >> + >> +-- Explicitly set BINARY collation has ID. > > 3. Please, add more tests, especially for box when you set id to > 4294967294. > >> +-- >> +box.sql.execute("CREATE TABLE t (id INT PRIMARY KEY, a TEXT, b TEXT COLLATE BINARY);") >> +box.space.T:format()[2]['collation'] >> +box.space.T:format()[3]['collation'] >> +box.sql.execute("DROP TABLE t;") >> + >> box.schema.user.revoke('guest', 'read,write,execute', 'universe')
next prev parent reply other threads:[~2018-10-31 15:47 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-25 11:00 [tarantool-patches] [PATCH 0/3] Change collation compatibility rules according to ANSI SQL Nikita Pettik 2018-10-25 11:00 ` [tarantool-patches] [PATCH 1/3] sql: do not add explicit <COLLATE "BINARY"> clause Nikita Pettik 2018-10-25 11:00 ` [tarantool-patches] [PATCH 2/3] Add surrogate ID for BINARY collation Nikita Pettik 2018-10-31 12:34 ` [tarantool-patches] " Vladislav Shpilevoy 2018-10-31 15:47 ` n.pettik [this message] 2018-11-01 11:37 ` Konstantin Osipov 2018-11-01 12:22 ` Vladislav Shpilevoy 2018-11-01 12:58 ` Konstantin Osipov 2018-11-01 13:08 ` n.pettik 2018-11-01 15:39 ` Konstantin Osipov [not found] ` <95CB17D5-E3ED-4B05-A289-983E2FD0DE37@gmail.com> 2018-11-01 17:45 ` n.pettik 2018-11-01 20:00 ` Konstantin Osipov 2018-11-01 20:06 ` Konstantin Osipov 2018-11-01 20:20 ` n.pettik 2018-10-25 11:00 ` [tarantool-patches] [PATCH 3/3] sql: change collation compatibility rules Nikita Pettik 2018-10-31 12:34 ` [tarantool-patches] " Vladislav Shpilevoy 2018-11-12 23:46 ` n.pettik
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=2A51C9E8-2A24-4F04-ABF1-0983F4322E82@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='[tarantool-patches] Re: [PATCH 2/3] Add surrogate ID for BINARY collation' \ /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