Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH v1 2/3] sql: better LUA arguments conversion for UDFs
Date: Tue, 15 Oct 2019 16:49:31 +0300	[thread overview]
Message-ID: <20191015134931.GB88253@tarantool.org> (raw)
In-Reply-To: <c4766811-74aa-c46c-c4ca-940c991a5a90@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]
> ...
> ---

  parent reply	other threads:[~2019-10-15 13:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1568639944.git.kshcherbatov@tarantool.org>
     [not found] ` <05d61e713763e45d0e1d59d8c71699f9820a42cc.1568639944.git.kshcherbatov@tarantool.org>
     [not found]   ` <20190925155156.GA42042@tarantool.org>
     [not found]     ` <673fe725-f68d-e4f6-3ed0-25a4bc6255ad@tarantool.org>
2019-10-15 13:10       ` [Tarantool-patches] [tarantool-patches] Re: [PATCH v1 1/3] sql: errors for UDFs returning too many values Nikita Pettik
2019-10-16 14:10         ` Kirill Shcherbatov
2019-10-17 12:51           ` Nikita Pettik
     [not found]     ` <c4766811-74aa-c46c-c4ca-940c991a5a90@tarantool.org>
2019-10-15 13:49       ` Nikita Pettik [this message]
2019-10-16 14:09         ` [Tarantool-patches] [tarantool-patches] Re: [PATCH v1 2/3] sql: better LUA arguments conversion for UDFs Kirill Shcherbatov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191015134931.GB88253@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH v1 2/3] sql: better LUA arguments conversion for UDFs' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox