Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: "n.pettik" <korablev@tarantool.org>, tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH 3/6] sql: pass true types of columns to Tarantool
Date: Tue, 30 Oct 2018 00:32:54 +0300	[thread overview]
Message-ID: <2d06ce1c-bd65-221c-6946-bce549796925@tarantool.org> (raw)
In-Reply-To: <723E1B3C-AF45-4129-9C39-B5B2B04E3B28@tarantool.org>

Hi! Thanks for the fixes! See 2 comments below.

>>> +		struct index_def *pk = pUseIndex;
>>>   		assert(pk != NULL);
>>>   -		uint32_t fieldno = pk->def->key_def->parts[0].fieldno;
>>> +		uint32_t fieldno = pk->key_def->parts[0].fieldno;
>>>   		enum affinity_type affinity =
>>>   			tab->def->fields[fieldno].affinity;
>>> -		if (pk->def->key_def->part_count == 1 &&
>>> +		if (pk->key_def->part_count == 1 &&
>>>   		    affinity == AFFINITY_INTEGER && (int)fieldno < nVector) {
>>>   			int reg_pk = rLhs + (int)fieldno;
>>
>> 3. Why do we still need this MustBeInt here? As I understand, here we
>> are trying to use an index for binary search of an LHS, but under the
>> hood it is just tarantool iterators starting from certain keys, it is
>> not? If it is, then tarantool iterators does key validation for us. Can
>> you please check if this opcode is redundant?
> 
> It doesn’t seem to be useless. Consider example:
> 
> CREATE TABLE t1 (id INT PRIMARY KEY);
> SELECT 1.23 IN t1;
> 
> Now, OP_Affinity doesn’t cast REAL to INT - I described reason
> in previous review. So, without OP_MustBeInt query above would
> result in
> 
> Execution failed: Supplied key type of part 0 does not match index part type: expected integer
> 
> Since 1.23 is passed to iterator over integer field. But I guess query above
> is fine - it should simply return 0, not an error since queries like
> 
> SELECT * FROM t1 WHERE id = 1.123;
> SELECT * FROM t1 WHERE id > 1.123;
> INSERT INTO t1 VALUES (1.123);
> 
> are allowed as well.

1. Then I am confused. Look at OP_MustBeInt. It calls
applyAffinity(pIn1, AFFINITY_NUMERIC). NUMERIC is real, so
1.23 cast to NUMERIC should be unchanged, it is not? I
tried this:

tarantool> box.sql.execute("select CAST(1.23 as NUMERIC)")
---
- - [1.23]
...

So 1.23 is already numeric. But applyAffinity function
for unknown reason does this: for target affinity ==
NUMERIC it sees that the original affinity is real and
casts the result to integer. So
applyAffinity(1.23, NUMERIC) == 1, but
SELECT CAST 1.23 as NUMERIC == 1.23.   ?!


> 
>>> diff --git a/test/sql-tap/boundary3.test.lua b/test/sql-tap/boundary3.test.lua
>>> index 5b63e0539..c5d605b65 100755
>>> --- a/test/sql-tap/boundary3.test.lua
>>> +++ b/test/sql-tap/boundary3.test.lua
>>> @@ -125,7 +125,7 @@ test:do_test(
>>>           -- </boundary3-1.3>
>>>       })
>>>   -test:do_execsql_test(
>>> +--[[test:do_execsql_test(
>>
>> 4. Do not silently comment tests. We should either delete it, or fix, or
>> open an issue to fix it later.
> 
> These tests are working. In previous review you asked to enable tests which
> are under ‘if false’, so I forgot about simply commented tests.

2. Sorry, in3.test.lua still has a commented test. orderby5.test.lua too.

  reply	other threads:[~2018-10-29 21:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-17 20:32 [tarantool-patches] [PATCH 0/6] Introduce strict typing for SQL Nikita Pettik
2018-09-17 20:32 ` [tarantool-patches] [PATCH 1/6] sql: split conflict action and affinity for Expr Nikita Pettik
2018-09-19  2:16   ` [tarantool-patches] " Konstantin Osipov
2018-09-27 20:24   ` Vladislav Shpilevoy
2018-10-12 11:18     ` n.pettik
2018-09-17 20:32 ` [tarantool-patches] [PATCH 2/6] sql: annotate SQL functions with return type Nikita Pettik
2018-09-27 20:23   ` [tarantool-patches] " Vladislav Shpilevoy
2018-10-12 11:18     ` n.pettik
2018-09-17 20:32 ` [tarantool-patches] [PATCH 3/6] sql: pass true types of columns to Tarantool Nikita Pettik
2018-09-19  2:23   ` [tarantool-patches] " Konstantin Osipov
2018-10-12 11:19     ` n.pettik
2018-09-27 20:23   ` Vladislav Shpilevoy
2018-10-12 11:18     ` n.pettik
2018-10-17 21:45       ` Vladislav Shpilevoy
2018-10-23 23:28         ` n.pettik
2018-10-29 21:32           ` Vladislav Shpilevoy [this message]
2018-11-02  2:36             ` n.pettik
2018-09-17 20:32 ` [tarantool-patches] [PATCH 4/6] sql: enforce implicit type conversions Nikita Pettik
2018-09-19  2:25   ` [tarantool-patches] " Konstantin Osipov
2018-09-27 20:24   ` Vladislav Shpilevoy
2018-10-12 11:19     ` n.pettik
2018-10-17 21:45       ` Vladislav Shpilevoy
2018-10-23 23:28         ` n.pettik
2018-10-29 21:32           ` Vladislav Shpilevoy
2018-11-02  2:36             ` n.pettik
2018-11-02 11:15               ` Vladislav Shpilevoy
2018-11-02 13:26                 ` n.pettik
2018-09-17 20:32 ` [tarantool-patches] [PATCH 5/6] sql: return result-set type via IProto Nikita Pettik
2018-09-19  2:26   ` [tarantool-patches] " Konstantin Osipov
2018-09-27 20:24   ` Vladislav Shpilevoy
2018-10-12 11:19     ` n.pettik
2018-10-17 21:45       ` Vladislav Shpilevoy
2018-10-23 23:28         ` n.pettik
2018-09-17 20:32 ` [tarantool-patches] [PATCH 6/6] sql: discard numeric conversion by unary plus Nikita Pettik
2018-09-27 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-10-12 11:19     ` n.pettik
2018-09-27 20:24 ` [tarantool-patches] Re: [PATCH 0/6] Introduce strict typing for SQL Vladislav Shpilevoy
2018-10-12 11:18   ` n.pettik
2018-11-03  2:41 ` Kirill Yukhin

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=2d06ce1c-bd65-221c-6946-bce549796925@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 3/6] sql: pass true types of columns to Tarantool' \
    /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