Document `c_func_iproto_multireturn` compat option
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
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 https://github.com/tarantool/tarantool/commit/96ee6d9b64e2a06649fcc477b6068f2cbe122115.
Definition of done
- Add a new page for
c_func_iproto_multireturnincompatmodule docs - Add a "see also" link to this page on the
compat.c_func_iproto_multireturndescription in the configuration reference
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the compat root document and the configuration reference section for compat.c_func_iproto_multireturn. Add the new option page using the provided old/new C-function and box.func examples, then add a see-also link from the configuration reference; the definition of done lists both required updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100