No space defined
swar0g opened this issue · 2 comments
PHP 5.6.30-1~dotdeb+7.1 (cli) (built: Jan 21 2017 14:50:59)
Tarantool 1.7.4 (Binary) bba87e42-c93f-4823-a51a-36069400f80f
PHP module compiled from github repo
Server script looks like:
box.cfg {
listen = 3301,
background = true,
log = 'deploy.log',
pid_file = 'deploy.pid'
}
space = box.space.deploy
if not space then
space = box.schema.create_space('deploy')
space:create_index('primary', { parts = {1, 'STR'}, type='HASH' })
end
Attempt to execute following code:
$tt = new Tarantool("127.0.0.1",3301);
var_dump($tt->select('deploy'));
failed with "Uncaught exception 'Exception' with message 'No space 'deploy' defined'"
At the same time console call box.space.deploy returns
---
- index:
0: &0
unique: true
parts:
- type: string
fieldno: 1
id: 0
space_id: 512
name: primary
type: HASH
primary: *0
on_replace: 'function: 0x4174bab8'
temporary: false
id: 512
engine: memtx
enabled: true
name: deploy
field_count: 0
@swar0g thank you for detailed issue. You haven't grant access for user guest to space deploy. Use box.schema.user.grant('guest', 'read,write', 'space', 'deploy') in Lua to fix this.
BTW this can be rewritten
space = box.space.deploy
if not space then
space = box.schema.create_space('deploy')
space:create_index('primary', { parts = {1, 'STR'}, type='HASH' })
end
with this
box.once('init-deploy', function()
local space = box.schema.create_space('deploy')
space:create_index('primary', { parts = {1, 'STR'}, type='HASH' })
box.schema.user.grant('guest', 'read,write', 'space', 'deploy')
end)
And try to avoid global variables. Suggested codestyle is located here: https://tarantool.org/doc/1.7/dev_guide/lua_style_guide.html
Thank you very much, also for usefull tips. It works like a charm.