1
1
box .cfg
2
2
{
3
- pid_file = nil ,
4
- background = false ,
5
- log_level = 5 ,
6
- listen = 3301
3
+ pid_file = nil ,
4
+ background = false ,
5
+ log_level = 5 ,
6
+ listen = 3301
7
7
}
8
8
local function create_spaces_and_indecies ()
9
- space1 = box .schema .space .create (' primary_only_index' , { if_not_exists = true })
10
- space1 :create_index (' primary' , {type = ' hash' , parts = {1 , ' unsigned' }, if_not_exists = true })
9
+ space1 = box .schema .space .create (' primary_only_index' , { if_not_exists = true })
10
+ space1 :create_index (' primary' , {type = ' hash' , parts = {1 , ' unsigned' }, if_not_exists = true })
11
11
12
- performanceSpace = box .schema .space .create (' performance' , { if_not_exists = true })
13
- performanceSpace :create_index (' primary' , {type = ' hash' , parts = {1 , ' unsigned' }, if_not_exists = true })
12
+ performanceSpace = box .schema .space .create (' performance' , { if_not_exists = true })
13
+ performanceSpace :create_index (' primary' , {type = ' hash' , parts = {1 , ' unsigned' }, if_not_exists = true })
14
14
15
- space2 = box .schema .space .create (' primary_and_secondary_index' , { if_not_exists = true })
16
- space2 :create_index (' hashIndex' , {type = ' hash' , parts = {1 , ' unsigned' }, if_not_exists = true })
17
- space2 :create_index (' treeIndex' , {type = ' tree' , parts = {1 , ' unsigned' }, if_not_exists = true })
15
+ space2 = box .schema .space .create (' primary_and_secondary_index' , { if_not_exists = true })
16
+ space2 :create_index (' hashIndex' , {type = ' hash' , parts = {1 , ' unsigned' }, if_not_exists = true })
17
+ space2 :create_index (' treeIndex' , {type = ' tree' , parts = {1 , ' unsigned' }, if_not_exists = true })
18
+
19
+ space3 = box .schema .space .create (' with_scalar_index' , { if_not_exists = true })
20
+ space3 :create_index (' primary' , {type = ' tree' , parts = {1 , ' scalar' }, if_not_exists = true })
18
21
end
19
22
20
23
local function init ()
21
- create_spaces_and_indecies ()
24
+ create_spaces_and_indecies ()
22
25
23
- box .schema .user .create (' notSetPassword' , { if_not_exists = true })
24
- box .schema .user .create (' emptyPassword' , { password = ' ' , if_not_exists = true })
26
+ box .schema .user .create (' notSetPassword' , { if_not_exists = true })
27
+ box .schema .user .create (' emptyPassword' , { password = ' ' , if_not_exists = true })
25
28
26
- box .schema .user .create (' operator' , {password = ' operator' , if_not_exists = true })
27
- box .schema .user .grant (' operator' ,' read,write,execute' ,' universe' , { if_not_exists = true })
28
- box .schema .user .grant (' guest' ,' read,write,execute' ,' universe' , { if_not_exists = true })
29
- box .schema .user .passwd (' admin' , ' adminPassword' )
29
+ box .schema .user .create (' operator' , {password = ' operator' , if_not_exists = true })
30
+ box .schema .user .grant (' operator' ,' read,write,execute' ,' universe' , { if_not_exists = true })
31
+ box .schema .user .grant (' guest' ,' read,write,execute' ,' universe' , { if_not_exists = true })
32
+ box .schema .user .passwd (' admin' , ' adminPassword' )
30
33
end
31
34
32
35
local function space_TreeIndexMethods ()
33
- space = box .schema .space .create (' space_TreeIndexMethods' , { if_not_exists = true })
34
- space :create_index (' treeIndex' , {type = ' tree' , parts = {1 , ' unsigned' }, if_not_exists = true })
36
+ space = box .schema .space .create (' space_TreeIndexMethods' , { if_not_exists = true })
37
+ space :create_index (' treeIndex' , {type = ' tree' , parts = {1 , ' unsigned' }, if_not_exists = true })
35
38
36
- space :auto_increment {' asdf' , 10.1 }
37
- space :auto_increment {' zcxv' }
38
- space :auto_increment {2 , 3 }
39
+ space :auto_increment {' asdf' , 10.1 }
40
+ space :auto_increment {' zcxv' }
41
+ space :auto_increment {2 , 3 }
39
42
end
40
43
41
44
box .once (' init' , init )
@@ -44,21 +47,21 @@ box.once('space_TreeIndexMethods', space_TreeIndexMethods)
44
47
local log = require (' log' )
45
48
46
49
function log_connect ()
47
- local m = ' Connection. user=' .. box .session .user () .. ' id=' .. box .session .id ()
48
- log .info (m )
50
+ local m = ' Connection. user=' .. box .session .user () .. ' id=' .. box .session .id ()
51
+ log .info (m )
49
52
end
50
53
function log_disconnect ()
51
- local m = ' Disconnection. user=' .. box .session .user () .. ' id=' .. box .session .id ()
52
- log .info (m )
54
+ local m = ' Disconnection. user=' .. box .session .user () .. ' id=' .. box .session .id ()
55
+ log .info (m )
53
56
end
54
57
55
58
function log_auth ()
56
- local m = ' Authentication attempt'
57
- log .info (m )
59
+ local m = ' Authentication attempt'
60
+ log .info (m )
58
61
end
59
62
function log_auth_ok (user_name )
60
- local m = ' Authenticated user ' .. user_name
61
- log .info (m )
63
+ local m = ' Authenticated user ' .. user_name
64
+ log .info (m )
62
65
end
63
66
64
67
box .session .on_connect (log_connect )
@@ -67,37 +70,38 @@ box.session.on_auth(log_auth)
67
70
box .session .on_auth (log_auth_ok )
68
71
69
72
function return_null ()
70
- log .info (' return_null called' )
71
- return require (' msgpack' ).NULL
73
+ log .info (' return_null called' )
74
+ return require (' msgpack' ).NULL
72
75
end
73
76
74
77
function return_tuple_with_null ()
75
- log .info (' return_tuple_with_null called' )
76
- return { require (' msgpack' ).NULL }
78
+ log .info (' return_tuple_with_null called' )
79
+ return { require (' msgpack' ).NULL }
77
80
end
78
81
79
82
function return_tuple ()
80
- log .info (' return_tuple called' )
81
- return { 1 , 2 }
83
+ log .info (' return_tuple called' )
84
+ return { 1 , 2 }
82
85
end
83
86
84
87
85
88
function return_array ()
86
- log .info (' return_array called' )
87
- return {{ " abc" , " def" }}
89
+ log .info (' return_array called' )
90
+ return {{ " abc" , " def" }}
88
91
end
89
92
90
93
function return_scalar ()
91
- log .info (' return_scalar called' )
92
- return 1
94
+ log .info (' return_scalar called' )
95
+ return 1
93
96
end
94
97
95
98
function return_nothing ()
96
- log .info (' return_nothing called' )
99
+ log .info (' return_nothing called' )
97
100
end
98
101
99
102
local truncate_space = function (name )
100
103
local space = box .space [name ]
104
+
101
105
if space then
102
106
log .info (" Truncating space %s..." , name )
103
107
space :truncate ()
@@ -107,11 +111,9 @@ local truncate_space = function(name)
107
111
end
108
112
end
109
113
110
- function clear_data ()
111
- log .info (' clearing data...' )
112
-
113
- truncate_space (' primary_only_index' )
114
- truncate_space (' performance' )
115
- truncate_space (' primary_and_secondary_index' )
116
- truncate_space (' space_TreeIndexMethods' )
114
+ function clear_data (spaceNames )
115
+ log .info (' clearing data...' )
116
+ for _ , spaceName in ipairs (spaceNames ) do
117
+ truncate_space (spaceName )
118
+ end
117
119
end
0 commit comments