Description
Product: Tarantool / compat
Since: 3.0
Audience/target: dev
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/compat/
SME: @ Buristan
Details
Please create a documentation page for the new compat option:
https://tarantool.io/compat/c_func_iproto_multireturn
In the new behaviour, the multiresults returned by a stored C function
via iproto aren't wrapped in the additional msgpack array (old).
tarantool> compat.c_func_iproto_multireturn = 'old'
---
...
tarantool> net_box.connect(box.cfg.listen):call('myclib.cfunc')
---
- [true, -1]
...
tarantool> compat.c_func_iproto_multireturn = 'new'
---
...
tarantool> net_box.connect(box.cfg.listen):call('myclib.cfunc')
---
- true
- -1
...
The new behaviour is consistent with the local call of the function
via box.func
:
tarantool> box.func['myclib.cfunc']:call()
---
- true
- -1
...
Assume you have a stored C function that returns values like the
following:
char *position = mp_encode_bool(buffer, true);
box_return_mp(ctx, buffer, position);
/* ... */
position = mp_encode_int(buffer, -1);
box_return_mp(ctx, buffer, position);
If you want to preserve the format of the returned array for your C
functions, when the c_func_iproto_multireturn
option is set to "new",
you should add the additional wrapping, like the following:
char *position = mp_encode_array(buffer_with_results, n_results);
position = mp_encode_bool(position, true);
/* ... */
position = mp_encode_int(position, -1);
box_return_mp(ctx, buffer_with_results, position);
The amount of box_return_mp()
calls indicates the number of values to
be returned.
Also, you should update its usage via box.func
if there is any.
Requested by @Buristan in tarantool/tarantool@96ee6d9.
Definition of done
- Add a new page for
c_func_iproto_multireturn
incompat
module docs - Add a "see also" link to this page on the
compat.c_func_iproto_multireturn
description in the configuration reference