[Tarantool-patches] [tarantool-patches] Re: [PATCH v1 2/3] sql: better LUA arguments conversion for UDFs

Nikita Pettik korablev at tarantool.org
Tue Oct 15 16:49:31 MSK 2019


On 08 Oct 11:38, Kirill Shcherbatov wrote:
> >>  		case MP_UINT: {
> >> -			sql_int64 val = sql_value_int64(param);
> >> +			sql_uint64 val = sql_value_uint64(param);
> > 
> > If this is a bug, please move it to a separate patch and provide
> > test case.
> > 
> >>  			mpstream_encode_uint(&stream, val);
> 
> Formally, it is a bug, but nobody can reproduce it. sql_value_int64 and sql_value_uint64 do
> exactly the same thing inside while mpstream_encode_uint internally casts val variable
> to uint64_t.
> 
> I need mention the scenario when this code works: it should be uint64_t passed to
> C-language UDF. I've analyzed it carefully, and everything is ok there.
> This test case is big enough and is not important: C-language UDFs are already covered
> by tests.
> 
> I believe that fixing this problem (same as a problem below) silently in scope of "better LUA
> arguments conversion for UDFs" is ok.  

Ok, as you wish.
 
> >> -			sqlVdbeMemSetNull(val);
> >> +			sqlVdbeMemSetNull(&val[i]);
> >>
> > These two places also look like bugs as well...
> UDF function may return multiple values, but we can't handle such situation
> normally in SQL. This must be banned. I've included a path that does it in
> a separate letter.
> >> +                        param_list = {'any'}, returns = 'scalar',
> > 
> > Why did you have to change types? What is the difference between them,
> > if the base type is not map or array?
> This doesn't makes sense now. Ok, let's do not change param_list arguments.
> 
> > Btw, is this documented fact that nil is converted to NULL?
> > So box.NULL and nil means the same in SQL..
> This behavior is confirmed as OK by Kostya. I've included  TarantoolBot request
> to document it.
> 
> =======================================================
> 
> Start using comprehensive serializer luaL_tofield() to prepare
> LUA arguments for UDFs. This allows to support cdata types
> returned from Lua function.
> 
> Needed for #4387
> 
> @TarantoolBot document
> Title: UDF returning nil or box.NULL in SQL
> 
> Values nil and box.NULL returned by UDF in SQL
> both transformed to SQL NULL and are equal.
> 
> Example:
> tarantool> box.execute("SELECT LUA('return nil') is NULL
>                                and LUA('return nil') is NULL")

Two conditions are equal. I guess second one should be 'return box.NULL'.
The rest is OK.

> ---
> - metadata:
>   - name: LUA('return nil') is NULL and LUA('return nil') is NULL
>     type: boolean
>   rows:
>   - [true]
> ...
> ---


More information about the Tarantool-patches mailing list