Skip to content

An exception is thrown while creating a tube #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rybakit opened this issue Mar 13, 2015 · 14 comments
Closed

An exception is thrown while creating a tube #26

rybakit opened this issue Mar 13, 2015 · 14 comments
Assignees

Comments

@rybakit
Copy link
Collaborator

rybakit commented Mar 13, 2015

$t = new \Tarantool();
$t->authenticate('tester', 'tester');
$t->call('queue.create_tube', ['foo', 'fifo']);

Output:

PHP Fatal error:  Uncaught exception 'Exception' with message 'Query error 32: 
unsupported Lua type 'function'' in ...

The tube is created though.

@kostja
Copy link
Contributor

kostja commented Mar 26, 2015

This mis a server-side error: msgpack can't represent a Lua function object returned by crate_tube. 'call' is designed to have calling convention similar to select and return an array of tuples. To do server-side code execution, we added 'eval' to the binary protocol in 1.6, it can return arbitrary msgpack.

We need to make eval available in PHP. Note, that eval requiers a different set of grants compared to call - it requires global 'execute' privilege, as it allows to execute arbitrary Lua code.

@kostja
Copy link
Contributor

kostja commented Mar 26, 2015

So I would consider it an enhancement request to support eval in PHP driver.
The alternative is to make sure msgpack can pack anything on the server side.

@rybakit
Copy link
Collaborator Author

rybakit commented Mar 26, 2015

Thanks for the detailed answer. I wonder if it make sense to throw a proper exception for these sort of errors, something like Tarantool\UnsupportedTypeException, or at least TarantoolExeption (or Exception) to be able to handle them accordingly?

@kostja
Copy link
Contributor

kostja commented Mar 26, 2015

Yes, I agree. @bigbes ?

@bigbes
Copy link
Contributor

bigbes commented Mar 26, 2015

@kostja, Yes, i agree, it's part of next branch 0.1.* .

@rybakit
Copy link
Collaborator Author

rybakit commented Mar 26, 2015

Another option could be to return a special Tarantool\LuaFunction object, which could be later evaluated by Tarantool::eval(). Don't know how useful it will be though.

@bigbes
Copy link
Contributor

bigbes commented Apr 22, 2015

Tarantool::evaluate() request is already created and i think #36 is all that needs to be done in this issue.

@bigbes bigbes closed this as completed Apr 22, 2015
@rybakit
Copy link
Collaborator Author

rybakit commented Jun 24, 2015

@kostja @bigbes The same problem with eval:

$t->eval('return queue.create_tube', ['foo', 'fifo']);
Exception: Query error 32: unsupported Lua type 'function'

$t->eval('queue.create_tube', ['foo', 'fifo']);
Exception: Query error 32: eval:1: '=' expected near '<eof>'

Also,

$t->call('queue.statistics')
Query error 22: Tuple/Key must be MsgPack array

but the result of the queue.statistics call is a table: https://github.com/tarantool/queue/blob/master/queue/abstract.lua#L356.

@kostja
Copy link
Contributor

kostja commented Jun 24, 2015

  • Eugene Leonovich [email protected] [15/06/24 11:02]:

    @kostja @bigbes The same problem with eval:

    $t->eval('return queue.create_tube', ['foo', 'fifo']);
    Exception: Query error 32: unsupported Lua type 'function'
    
    $t->eval('queue.create_tube', ['foo', 'fifo']);
    Exception: Query error 32: eval:1: '=' expected near '<eof>'

You apparently are misusing eval.

Should be $t->eval("return queue.create_tube('foo', 'fifo')")

http://tarantool.org - a NoSQL database in a Lua script

@rybakit
Copy link
Collaborator Author

rybakit commented Jun 24, 2015

Ah, my bad. But could you please explain why $t->call('queue.statistics') fails?

@rtsisyk
Copy link
Contributor

rtsisyk commented Jun 24, 2015

Wednesday, June 24, 2015 12:41 AM -07:00 from Eugene Leonovich [email protected]:

@kostja @bigbes The same problem with eval :
$t->eval('return queue.create_tube', ['foo', 'fifo']);
Exception: Query error 32: unsupported Lua type 'function'

Try $t->eval('return queue.create_tube(...)', ['foo', 'fifo']);

Eval uses loadstring() under the hood:

fun = loadstrring("eval expression")
msgpack_encode(fun(msgpack_decode(arguments)))

WBR,
Roman Tsisyk [email protected]
http://tarantool.org/ - an efficient in-memory data store and a Lua application server

@rybakit
Copy link
Collaborator Author

rybakit commented Jun 25, 2015

@rtsisyk Any hint why call('queue.statistics') fails with Tuple/Key must be MsgPack array?

@kostja
Copy link
Contributor

kostja commented Jun 25, 2015

  • Eugene Leonovich [email protected] [15/06/25 11:14]:

    @rtsisyk Any hint why call('queue.statistics') fails with Tuple/Key must be MsgPack array?

Could you please show here the output of queue.statistics() from
the console?

http://tarantool.org - a NoSQL database in a Lua script

@rybakit
Copy link
Collaborator Author

rybakit commented Jun 25, 2015

> queue.statistics()
---
- - t:
      tasks:
      - total: 1
      - ready: 1
      - taken: 0
      - buried: 0
      - done: 0
      - delayed: 0
      calls:
      - put: 1
...

@bigbes bigbes self-assigned this Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants