From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6F61643D67A for ; Tue, 15 Oct 2019 16:49:32 +0300 (MSK) Date: Tue, 15 Oct 2019 16:49:31 +0300 From: Nikita Pettik Message-ID: <20191015134931.GB88253@tarantool.org> References: <05d61e713763e45d0e1d59d8c71699f9820a42cc.1568639944.git.kshcherbatov@tarantool.org> <20190925155156.GA42042@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH v1 2/3] sql: better LUA arguments conversion for UDFs List-Id: Tarantool development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirill Shcherbatov Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org 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] > ... > ---