From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 4 Jun 2019 19:31:59 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview Message-ID: <20190604163159.5lctqc4kaclxo3rh@esperanza> References: <5eab44d0494d7622ef5fbb77c45229a09212d9bc.1559219194.git.roman.habibov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5eab44d0494d7622ef5fbb77c45229a09212d9bc.1559219194.git.roman.habibov@tarantool.org> To: Roman Khabibov Cc: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org List-ID: On Thu, May 30, 2019 at 03:36:02PM +0300, Roman Khabibov wrote: > diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua > index 89d6e3d52..f2a1be639 100644 > --- a/src/box/lua/upgrade.lua > +++ b/src/box/lua/upgrade.lua > @@ -737,6 +737,30 @@ local function upgrade_to_2_1_3() > end > end > > +local function create_vcollation_space() > + local _collation = box.space._collation > + local format = _collation:format() > + create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID) > + box.space[box.schema.VCOLLATION_ID]:format(format) > +end > + > +local function upgrade_to_2_1_4() > + local _collation = box.space._collation > + local _index = box.space._index > + > + -- System space format usually is in order "id, owner, name...". > + -- The fields "name", "owner" are swapped in "_collation" format, > + -- due to the field "owner" was added after the "_collation" creation. > + box.space._index:delete{276, 1} > + log.info("update index name on _collation") > + box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true}, > + {{1, 'string'}}} > + log.info("create index owner on _collation") > + box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false}, > + {{2, 'unsigned'}}} I don't understand this part. Why do you need to create 'owner' index? Why do you need to update 'name' index? > + create_vcollation_space() > +end > + > local function get_version() > local version = box.space._schema:get{'version'} > if version == nil then > @@ -768,6 +792,7 @@ local function upgrade(options) > {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true}, > {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true}, > {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true}, > + {version = mkversion(2, 1, 4), func = upgrade_to_2_1_4, auto = true} Should be in upgrade_to_2_2_1. > } > > for _, handler in ipairs(handlers) do > diff --git a/src/box/schema_def.h b/src/box/schema_def.h > index eeeeb950b..77c004690 100644 > --- a/src/box/schema_def.h > +++ b/src/box/schema_def.h > @@ -72,6 +72,8 @@ enum { > BOX_SCHEMA_ID = 272, > /** Space id of _collation. */ > BOX_COLLATION_ID = 276, > + /** Space id of _vcollation. */ > + BOX_VCOLLATION_ID = 277, > /** Space id of _space. */ > BOX_SPACE_ID = 280, > /** Space id of _vspace view. */ > diff --git a/src/box/sysview.c b/src/box/sysview.c > index 96c5e78ca..0d1259af0 100644 > --- a/src/box/sysview.c > +++ b/src/box/sysview.c > @@ -402,6 +402,14 @@ vsequence_filter(struct space *source, struct tuple *tuple) > ((PRIV_WRDA | PRIV_X) & effective); > } > > +static bool > + vcollation_filter(struct space *source, struct tuple *tuple) > + { > + (void) source; > + (void) tuple; > + return true; > + } > + Bad indentation.