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
C stored function works different when called locally and remotely #4799
Comments
C stored function always returns an array. Local call introduced with box.func used to convert resulting array to multireturn in contrast to netbox call that serializes it to a tuple. This patch makes resulting behavior consistent by making the local call always return a tuple as well. Closes #4799
It does not concern only C stored functions - Lua ones show the same bevaiour. Setup:
Local calls:
Remote calls:
As one can see, result for
I have no idea why current call replaced call_16, but it looks like we shouldn't touch it... |
No, I am not talking about calling Lua functions as variables. I am talking about working with registered functions using box API: |
We will check this issue after #7000 |
I had to investigate this behavior twice now, so I'll just keep a record of what I found here: Implementation detailsstruct portWhen the stored procedure is called if it has any return values those are stored LUA stored procedures have FFI stored procedures have And to extract values from that port a table of virtual methods is used with box.schema.func.callIn case when the proc is called via IPROTO_CALLWhen the proc is called via So in case of a LUA stored proc (see But in case of an FFI stored proc (see This effectively means that when calling an FFI stored proc the |
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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). ```hl 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`: ```hl tarantool> box.func['myclib.cfunc']:call() --- - true - -1 ... ``` Assume you have a stored C function that returns values like the following: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any.
This patch sets the aforementioned option to new. This is a breaking change that makes the behaviour of the stored C functions called locally and remotely via iproto consistent. Closes tarantool#4799 Relates to tarantool#8576 NO_DOC=see previous commit
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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). ```hl 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`: ```hl tarantool> box.func['myclib.cfunc']:call() --- - true - -1 ... ``` Assume you have a stored C function that returns values like the following: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any. (cherry picked from commit df59e65)
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any.
This patch sets the aforementioned option to new. This is a breaking change that makes the behaviour of the stored C functions called locally and remotely via iproto consistent. Closes tarantool#4799 Relates to tarantool#8576 NO_DOC=see previous commit
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any. (cherry picked from commit df59e65)
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any. (cherry picked from commit 4a27779)
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any.
This patch sets the aforementioned option to new. This is a breaking change that makes the behaviour of the stored C functions called locally and remotely via iproto consistent. Closes tarantool#4799 Relates to tarantool#8576 NO_DOC=see previous commit
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any.
This patch sets the aforementioned option to new. This is a breaking change that makes the behaviour of the stored C functions called locally and remotely via iproto consistent. Closes tarantool#4799 Relates to tarantool#8576 NO_DOC=see previous commit
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any. (cherry picked from commit 1e15260)
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). The reason is the usage of `port_dump_msgpack()` for SQL processing in `tx_process_sql()` and inside `iproto_session_push()`. So, global changes in `port_c_dump_msgpack()` (or on port creation) require some syncing with the aforementioned routines too. Hence, the new `port_c_unwrap_multireturn()` routine is introduced to check when we don't need to wrap the results in the additional msgpack array. Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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); ``` Also, you should update its usage via `box.func` if there is any.
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_sql()`, since this is dump format used in the SQL ports, see `port_sql_dump_msgpack()` in the <src/box/sql/port.c> * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_sql()` otherwise (old). Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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.
This patch sets the aforementioned option to new. This is a breaking change that makes the behaviour of the stored C functions called locally and remotely via iproto consistent. Closes tarantool#4799 Relates to tarantool#8576 NO_DOC=see previous commit
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_sql()`, since this is dump format used in the SQL ports, see `port_sql_dump_msgpack()` in the <src/box/sql/port.c> * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_sql()` otherwise (old). Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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.
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_sql()`, since this is dump format used in the SQL ports, see `port_sql_dump_msgpack()` in the <src/box/sql/port.c> * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_sql()` otherwise (old). Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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.
This patch sets the aforementioned option to new. This is a breaking change that makes the behaviour of the stored C functions called locally and remotely via iproto consistent. Closes tarantool#4799 Relates to tarantool#8576 NO_DOC=see previous commit
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_sql()`, since this is dump format used in the SQL ports, see `port_sql_dump_msgpack()` in the <src/box/sql/port.c> * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_sql()` otherwise (old). Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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.
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_wrapped()`, since this is dump format with additional msgpack array encoded. * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_wrapped()` otherwise (old). Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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.
This patch sets the aforementioned option to new. This is a breaking change that makes the behaviour of the stored C functions called locally and remotely via iproto consistent. Closes tarantool#4799 Relates to tarantool#8576 NO_DOC=see previous commit
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_wrapped()`, since this is dump format with additional msgpack array encoded. * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_wrapped()` otherwise (old). Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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.
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_wrapped()`, since this is dump format with additional msgpack array encoded. * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_wrapped()` otherwise (old). Needed for #4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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.
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_wrapped()`, since this is dump format with additional msgpack array encoded. * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_wrapped()` otherwise (old). Needed for tarantool#4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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. (cherry picked from commit 96ee6d9)
With this option enabled (new), the multiresults returned by a stored C function via iproto aren't wrapped in the additional msgpack array (old). Due to new behaviour some renames are performed: * `port_c_dump_msgpack()` -> `port_c_dump_msgpack_wrapped()`, since this is dump format with additional msgpack array encoded. * `port_c_dump_msgpack16()` -> `port_c_dump_msgpack()`, since this format is now the default new format of a msgpack dump. The behaviour of the C port msgpack dumping depends on the `c_func_iproto_multireturn` option: * uses `port_c_dump_msgpack()` if set to true (new), * uses `port_c_dump_msgpack_wrapped()` otherwise (old). Needed for #4799 @TarantoolBot document Title: Document `c_func_iproto_multireturn` compat option 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: ```c 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: ```c 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. (cherry picked from commit 96ee6d9)
Example. Run this from tarantool sources root folder:
Result of the function depends on from where it was called. When I call a Lua function, it returns the same result regardless of how I call it.
I don't know what a behaviour is correct - return an array in both cases, or multireturn. Seems like C functions always returned an array, because there was no other way to call them except via netbox, until
box.func
was introduced. I don't know. But behaviour should be at least the same.The text was updated successfully, but these errors were encountered: