From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: invalid integer type in arithmetic operations
Date: Thu, 25 Apr 2019 02:03:05 +0300 [thread overview]
Message-ID: <04E0C86F-84E5-400F-ACE0-80FD6799E4E3@tarantool.org> (raw)
In-Reply-To: <0929e575-2d28-7cd0-36bc-0a1bf1af76fe@tarantool.org>
> On 24 Apr 2019, at 22:56, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> wrote:
>> diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
>> index b3613d3ea..9b52e90f3 100644
>> --- a/src/box/sql/expr.c
>> +++ b/src/box/sql/expr.c
>> @@ -342,8 +342,19 @@ sql_expr_coll(Parse *parse, Expr *p, bool *is_explicit_coll, uint32_t *coll_id,
>> enum field_type
>> sql_type_result(enum field_type lhs, enum field_type rhs)
>> {
>> - if (sql_type_is_numeric(lhs) || sql_type_is_numeric(rhs))
>> + if (sql_type_is_numeric(lhs) || sql_type_is_numeric(rhs)) {
>> + if (lhs == FIELD_TYPE_NUMBER || rhs == FIELD_TYPE_NUMBER)
>> + return FIELD_TYPE_NUMBER;
>> + if (lhs == FIELD_TYPE_INTEGER || rhs == FIELD_TYPE_INTEGER)
>> + return FIELD_TYPE_INTEGER;
>> + /*
>> + * FIXME: FIELD_TYPE_UNSIGNED static type is not
>> + * allowed yet.
>> + */
>> + assert(lhs == FIELD_TYPE_UNSIGNED ||
>> + rhs == FIELD_TYPE_UNSIGNED);
>
> How does it work? If it is not allowed, then lhs and rhs should not
> be equal to FIELD_TYPE_UNSIGNED, and this assertion should fail, it is not?
>
> (I did not test, just looked at the diff in the mailing list)
Execution flaw hits this branch if both operands are numeric.
We consider only _INTEGER, _NUMBER and _UNSIGNED be
numeric types. If we hit this assertion, then both operands should
be _UNSIGNED (if I’m not mistaken, condition should be logical
AND not OR).
Surely, we still can create space and set format with unsigned types
from Lua, so strictly speaking UNSIGNED is allowed even now.
But we can’t set UNSIGNED as a type of column in SQL, and we don’t
set this type in meta. So in some sense it is not allowed.
Mb it is worth fixing comment. Or return _UNSIGNED instead
of _NUMBER in this case. I guess there will be no severe consequences.
next prev parent reply other threads:[~2019-04-24 23:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-24 15:36 [tarantool-patches] " Kirill Shcherbatov
2019-04-24 19:43 ` [tarantool-patches] " n.pettik
2019-04-25 7:32 ` Kirill Shcherbatov
2019-04-24 19:56 ` Vladislav Shpilevoy
2019-04-24 23:03 ` n.pettik [this message]
2019-04-25 10:49 ` Konstantin Osipov
2019-04-25 10:52 ` Konstantin Osipov
2019-04-25 11:07 ` Kirill Shcherbatov
2019-04-25 11:15 ` Konstantin Osipov
2019-04-25 11:21 ` Kirill Shcherbatov
2019-04-25 10:37 ` 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=04E0C86F-84E5-400F-ACE0-80FD6799E4E3@tarantool.org \
--to=korablev@tarantool.org \
--cc=kshcherbatov@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=v.shpilevoy@tarantool.org \
--subject='[tarantool-patches] Re: [PATCH v1 1/1] sql: invalid integer type in arithmetic operations' \
/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