From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id D6AF62C209 for ; Wed, 24 Apr 2019 15:56:20 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R9T4bCp9-vnV for ; Wed, 24 Apr 2019 15:56:20 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 7ED712BABC for ; Wed, 24 Apr 2019 15:56:20 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: invalid integer type in arithmetic operations References: <72941eba60647c98f4559cbd0c862bade990d761.1556120090.git.kshcherbatov@tarantool.org> From: Vladislav Shpilevoy Message-ID: <0929e575-2d28-7cd0-36bc-0a1bf1af76fe@tarantool.org> Date: Wed, 24 Apr 2019 22:56:18 +0300 MIME-Version: 1.0 In-Reply-To: <72941eba60647c98f4559cbd0c862bade990d761.1556120090.git.kshcherbatov@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org, Kirill Shcherbatov , korablev@tarantool.org > 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) > return FIELD_TYPE_NUMBER; > + } > return FIELD_TYPE_SCALAR; > } >