[tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview

Vladimir Davydov vdavydov.dev at gmail.com
Tue Jun 4 19:31:59 MSK 2019


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.



More information about the Tarantool-patches mailing list