[Tarantool-patches] [PATCH v1 2/2] sql: ignore \0 in string passed to Lua-function

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Wed Mar 31 23:25:23 MSK 2021


Good job on the patch!

See 2 comments below.

1. Please, add a changelog file.

On 30.03.2021 13:21, Mergen Imeev via Tarantool-patches wrote:
> Prior to this patch string passed to user-defined Lua-function from SQL
> was cropped in case it contains '\0'. At the same time, it wasn't
> cropped if it is passed to the function from BOX. After this patch the
> string won't be cropped when passed from SQL if it contain '\0'.
> 
> Closes #5938
> ---
>  src/box/sql/func.c                            |  3 ++-
>  .../gh-5938-wrong-string-length.test.lua      | 19 ++++++++++++++++++-
>  2 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index c3c14bd22..7d5a55d3f 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -120,7 +120,8 @@ port_vdbemem_dump_lua(struct port *base, struct lua_State *L, bool is_flat)
>  			lua_pushnumber(L, sql_value_double(param));
>  			break;
>  		case MP_STR:
> -			lua_pushstring(L, (const char *) sql_value_text(param));
> +			lua_pushlstring(L, (const char *) sql_value_text(param),
> +					(size_t) sql_value_bytes(param));

2. Unary operators should not have a whitespace after them.

>  			break;
>  		case MP_BIN:
>  		case MP_ARRAY:


More information about the Tarantool-patches mailing list