Skip to content
Snippets Groups Projects
Commit 6fe6f887 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Set 'flags' field to an empty string for system spaces.

parent 208219ea
No related branches found
No related tags found
No related merge requests found
-- Super User ID -- Guest user id - the default user
GUEST = 0 GUEST = 0
-- Super User ID
ADMIN = 1 ADMIN = 1
-- role 'PUBLIC' is special, it's automatically granted to every user
PUBLIC = 2 PUBLIC = 2
--
-- system spaces
--
_schema = box.space[box.schema.SCHEMA_ID] _schema = box.space[box.schema.SCHEMA_ID]
_space = box.space[box.schema.SPACE_ID] _space = box.space[box.schema.SPACE_ID]
_index = box.space[box.schema.INDEX_ID] _index = box.space[box.schema.INDEX_ID]
...@@ -12,13 +17,35 @@ _cluster = box.space[box.schema.CLUSTER_ID] ...@@ -12,13 +17,35 @@ _cluster = box.space[box.schema.CLUSTER_ID]
-- define schema version -- define schema version
_schema:insert{'version', 1, 6} _schema:insert{'version', 1, 6}
-- define system spaces -- define system spaces
_space:insert{_schema.id, ADMIN, '_schema', 'memtx', 0} --
_space:insert{_space.id, ADMIN, '_space', 'memtx', 0} -- _schema
_space:insert{_index.id, ADMIN, '_index', 'memtx', 0} --
_space:insert{_func.id, ADMIN, '_func', 'memtx', 0} _space:insert{_schema.id, ADMIN, '_schema', 'memtx', 0, ''}
_space:insert{_user.id, ADMIN, '_user', 'memtx', 0} --
_space:insert{_priv.id, ADMIN, '_priv', 'memtx', 0} -- _space
_space:insert{_cluster.id, ADMIN, '_cluster', 'memtx', 0} --
_space:insert{_space.id, ADMIN, '_space', 'memtx', 0, ''}
--
-- _index
--
_space:insert{_index.id, ADMIN, '_index', 'memtx', 0, ''}
--
-- _func
--
_space:insert{_func.id, ADMIN, '_func', 'memtx', 0, ''}
--
-- _user
--
_space:insert{_user.id, ADMIN, '_user', 'memtx', 0, ''}
--
-- _priv
--
_space:insert{_priv.id, ADMIN, '_priv', 'memtx', 0, ''}
--
-- _cluster
--
_space:insert{_cluster.id, ADMIN, '_cluster', 'memtx', 0, ''}
-- define indexes -- define indexes
_index:insert{_schema.id, 0, 'primary', 'tree', 1, 1, 0, 'str'} _index:insert{_schema.id, 0, 'primary', 'tree', 1, 1, 0, 'str'}
...@@ -45,8 +72,6 @@ _index:insert{_func.id, 0, 'primary', 'tree', 1, 1, 0, 'num'} ...@@ -45,8 +72,6 @@ _index:insert{_func.id, 0, 'primary', 'tree', 1, 1, 0, 'num'}
_index:insert{_func.id, 1, 'owner', 'tree', 0, 1, 1, 'num'} _index:insert{_func.id, 1, 'owner', 'tree', 0, 1, 1, 'num'}
_index:insert{_func.id, 2, 'name', 'tree', 1, 1, 2, 'str'} _index:insert{_func.id, 2, 'name', 'tree', 1, 1, 2, 'str'}
-- --
-- space schema is: grantor id, user id, object_type, object_id, privilege
-- primary key: user id, object type, object id
_index:insert{_priv.id, 0, 'primary', 'tree', 1, 3, 1, 'num', 2, 'str', 3, 'num'} _index:insert{_priv.id, 0, 'primary', 'tree', 1, 3, 1, 'num', 2, 'str', 3, 'num'}
-- owner index - to quickly find all privileges granted by a user -- owner index - to quickly find all privileges granted by a user
_index:insert{_priv.id, 1, 'owner', 'tree', 0, 1, 0, 'num'} _index:insert{_priv.id, 1, 'owner', 'tree', 0, 1, 0, 'num'}
...@@ -57,20 +82,23 @@ _index:insert{_cluster.id, 0, 'primary', 'tree', 1, 1, 0, 'num'} ...@@ -57,20 +82,23 @@ _index:insert{_cluster.id, 0, 'primary', 'tree', 1, 1, 0, 'num'}
-- node uuid key: node uuid -- node uuid key: node uuid
_index:insert{_cluster.id, 1, 'uuid', 'tree', 1, 1, 1, 'str'} _index:insert{_cluster.id, 1, 'uuid', 'tree', 1, 1, 1, 'str'}
-- --
-- Pre-create user and grants -- Pre-created users and grants
--
_user:insert{GUEST, ADMIN, 'guest', 'user'} _user:insert{GUEST, ADMIN, 'guest', 'user'}
_user:insert{ADMIN, ADMIN, 'admin', 'user'} _user:insert{ADMIN, ADMIN, 'admin', 'user'}
_user:insert{PUBLIC, ADMIN, 'public', 'role'} _user:insert{PUBLIC, ADMIN, 'public', 'role'}
-- space schema is: grantor id, user id, object_type, object_id, privilege
-- primary key: user id, object type, object id
RPL_ID = _user:auto_increment{ADMIN, 'replication', 'role'}[1] RPL_ID = _user:auto_increment{ADMIN, 'replication', 'role'}[1]
-- grant admin access to the universe -- grant admin access to the universe
_priv:insert{1, 1, 'universe', 0, 7} _priv:insert{1, 1, 'universe', 0, 7}
-- grant 'public' role access to 'box.schema.user.info' function -- grant 'public' role access to 'box.schema.user.info' function
_func:insert{1, 1, 'box.schema.user.info', 1} _func:insert{1, 1, 'box.schema.user.info', 1}
_priv:insert{1, 2, 'function', 1, 4} _priv:insert{1, 2, 'function', 1, 4}
-- replication can read universe -- replication can read the entire universe
_priv:insert{1, RPL_ID, 'universe', 0, 1} _priv:insert{1, RPL_ID, 'universe', 0, 1}
-- replication can append to '_cluster' system space -- replication can append to '_cluster' system space
_priv:insert{1, RPL_ID, 'space', box.schema.CLUSTER_ID, 2} _priv:insert{1, RPL_ID, 'space', box.schema.CLUSTER_ID, 2}
-- grant 'guest' role 'public' -- grant role 'public' to 'guest'
_priv:insert{1, 0, 'role', 2, 4} _priv:insert{1, 0, 'role', 2, 4}
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -253,7 +253,7 @@ box.space._user:select(1) ...@@ -253,7 +253,7 @@ box.space._user:select(1)
... ...
box.space._space:select(280) box.space._space:select(280)
--- ---
- - [280, 1, '_space', 'memtx', 0] - - [280, 1, '_space', 'memtx', 0, '']
... ...
us = box.schema.create_space('uniuser_space') us = box.schema.create_space('uniuser_space')
--- ---
...@@ -577,13 +577,13 @@ box.space._user:select() ...@@ -577,13 +577,13 @@ box.space._user:select()
... ...
box.space._space:select() box.space._space:select()
--- ---
- - [272, 1, '_schema', 'memtx', 0] - - [272, 1, '_schema', 'memtx', 0, '']
- [280, 1, '_space', 'memtx', 0] - [280, 1, '_space', 'memtx', 0, '']
- [288, 1, '_index', 'memtx', 0] - [288, 1, '_index', 'memtx', 0, '']
- [296, 1, '_func', 'memtx', 0] - [296, 1, '_func', 'memtx', 0, '']
- [304, 1, '_user', 'memtx', 0] - [304, 1, '_user', 'memtx', 0, '']
- [312, 1, '_priv', 'memtx', 0] - [312, 1, '_priv', 'memtx', 0, '']
- [320, 1, '_cluster', 'memtx', 0] - [320, 1, '_cluster', 'memtx', 0, '']
... ...
box.space._func:select() box.space._func:select()
--- ---
......
...@@ -47,13 +47,13 @@ box.space._cluster:select{} ...@@ -47,13 +47,13 @@ box.space._cluster:select{}
... ...
box.space._space:select{} box.space._space:select{}
--- ---
- - [272, 1, '_schema', 'memtx', 0] - - [272, 1, '_schema', 'memtx', 0, '']
- [280, 1, '_space', 'memtx', 0] - [280, 1, '_space', 'memtx', 0, '']
- [288, 1, '_index', 'memtx', 0] - [288, 1, '_index', 'memtx', 0, '']
- [296, 1, '_func', 'memtx', 0] - [296, 1, '_func', 'memtx', 0, '']
- [304, 1, '_user', 'memtx', 0] - [304, 1, '_user', 'memtx', 0, '']
- [312, 1, '_priv', 'memtx', 0] - [312, 1, '_priv', 'memtx', 0, '']
- [320, 1, '_cluster', 'memtx', 0] - [320, 1, '_cluster', 'memtx', 0, '']
... ...
box.space._index:select{} box.space._index:select{}
--- ---
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment