From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id E7E3B6BD01; Tue, 30 Mar 2021 02:12:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E7E3B6BD01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617059547; bh=cNjAuLdjPqvWBjfPGTACy1pLEee54mjGYcIYv5JYp/A=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Uy+4P622CuqUCS+4X7IL6ImQbMM571K4f4lTVcAzjXbXID6YfnpwVD77hhB2NEL5P hRHE/YlzIQYDAjg4o4HtDwZFjlGk2dTgFn5vUaBqdX/p7r2AT8RMQclXSXqQycD7NN ZFaPiyfnAeOffsMEu6rSSGKFdZFn/7oEvl/7rzzE= 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 106BE6BD0A for ; Tue, 30 Mar 2021 02:07:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 106BE6BD0A Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lR0yo-0005Gw-8y; Tue, 30 Mar 2021 02:07:30 +0300 To: imeevma@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <7b0c755e28e0c5617b544b127fd692b10434b404.1616491731.git.imeevma@gmail.com> Message-ID: <56d8bac9-75c6-f937-fed8-d119f96986e8@tarantool.org> Date: Tue, 30 Mar 2021 01:07:29 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <7b0c755e28e0c5617b544b127fd692b10434b404.1616491731.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E32947A0146560F8BA70927CAA5B950F38D9F182A05F5380850405F07FBAB929805CBB7595029F692492135862025EA80D0078FF6E3BFA98B5E89 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73D5736A43F78B50EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B23888C9749F3CAC8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CE99938B3FD79E1DFBB9A890AA21396283435651D1034E2B4A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE77E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B625DC386152A6764ACC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CFC5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B262FEC7FBD7D1F5BB5C8C57E37DE458BEDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831604167623C6AC6DED792DD908DDF4B51 X-C1DE0DAB: 0D63561A33F958A5F809296820423869E8DE3931D9AC5101D4D06F1BE96D6CA8D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EE19B6E2433CA0934EB718CDD14501CF7BD129192198E8EA327C0FE998A609221FE26F55A095FAE91D7E09C32AA3244C284A2D8634922219B02420D43375F712D08D48398F32B4A6FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojljIiQOC84rQCK1MJBUToXA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382203278133E848ED9C196F43666F21BFCA3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 41/53] sql: introduce mem_convert_to_integer() X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! See 2 comments below. On 23.03.2021 10:36, imeevma@tarantool.org wrote: > This patch introduces mem_convert_to_integer() which is used to convert > a MEM to a MEM that contains integer value. > > Part of #5818 > --- > src/box/sql/mem.c | 114 +++++++++++++++++++++++++++++---------------- > src/box/sql/mem.h | 7 ++- > src/box/sql/vdbe.c | 19 ++++---- > 3 files changed, 88 insertions(+), 52 deletions(-) > > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 1209df1ce..b9bcd3d3a 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -695,6 +695,80 @@ mem_set_cleared(struct Mem *mem) <...> > + > +static inline int > +mem_convert_double_to_integer_lossless(struct Mem *mem) 1. Lets use 'precise'. Here and in other places. And shorten the names. So it would be mem_convert_bool_to_int(), mem_convert_to_int(), etc. > +{ > + double d = mem->u.r; > + if (d < 0 && d >= (double)INT64_MIN && (double)(int64_t)d == d) { > + mem_set_integer(mem, (int64_t)d, true); > + return 0; > + } > + if (d >= 0 && d < (double)UINT64_MAX && (double)(uint64_t)d == d) { > + mem_set_integer(mem, (int64_t)(uint64_t)d, false); 2. Isn't mem_set_unsigned() faster? Or we can't set FIELD_TYPE_UNSIGNED?