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 465A06EC5F; Tue, 13 Apr 2021 23:56:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 465A06EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618347397; bh=LDHaPLdpVa13JWRPqXjAdqUMVkSgc0DU8FR17kkZhTM=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=JU8qxXtvpPdxAAUvq0ZF23Rp/TSWlhwK52NszpA4iDMna3wh+aWUemWrVh0xSm6vT JBDFvKHUnX53H8XKMg5U3w2cMrFLHUSCyP3lxckyB3KWii4XnE2PV7lE5F0xcm4/LE mzpgsfMLcM/67ctzCmQUFdEdbEpcsImgXiEaht6M= Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (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 AF4416EC5F for ; Tue, 13 Apr 2021 23:56:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AF4416EC5F Received: by smtp38.i.mail.ru with esmtpa (envelope-from ) id 1lWQ5K-0000hQ-TU; Tue, 13 Apr 2021 23:56:35 +0300 Date: Tue, 13 Apr 2021 23:56:33 +0300 To: Vladislav Shpilevoy Message-ID: <20210413205633.GB21144@tarantool.org> References: <69aa47b1575b768da04cc579e70038f5be272027.1617984948.git.imeevma@gmail.com> <23d58d25-f012-f0c2-8c52-1f56fadb28eb@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <23d58d25-f012-f0c2-8c52-1f56fadb28eb@tarantool.org> X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E748094FADAEB10E66ADA4C48BE3C291E66DA182A05F538085040FE365BC1E0A396BCB2CE6BDC66BC9BC8F70915CA3D6B94068CCCEAB60AE6629A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7464E3E47589AE1E5EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B9ECF1867A781AFF8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B24BC9EFAFACA65437F1B1DC02DFE630D9EBA8952C4932A151D2E47CDBA5A96583C09775C1D3CA48CFE97D2AE7161E217F117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7E9512AC99003B6BE9FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7707EA43B1100CC3ED32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C0B6CB25BBC1AB87D9CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3727597FF642BA4D735872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD709C0CAEBE9468110EDCF9167ADD54EA X-C1DE0DAB: 0D63561A33F958A5D820F161A6403DA9237E5AA8F1C9CA73C2E13A53BFF30A43D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34197948450CB5442A74ADE5C1E204D42A252D214D2F52EF594AF53E845251B1E000CBE61060FB38641D7E09C32AA3244C54CC8BD87B733819CB6B0F3DDA3ED6CA408A6A02710B7304FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnA7/qPBUIXETL+kLainyEg== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306ED535463D63CAB4C08B2CE6BDC66BC9BC8B67A942A63B4089A5105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v5 24/52] sql: introduce mem_set_int() 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: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thank you for the review! My answers below. On Tue, Apr 13, 2021 at 01:32:47AM +0200, Vladislav Shpilevoy wrote: > Good job on the fixes! > > See 3 comments below. > > > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > > index 937fa3272..075000218 100644 > > --- a/src/box/sql/mem.c > > +++ b/src/box/sql/mem.c > > @@ -1384,8 +1393,9 @@ vdbe_mem_numerify(struct Mem *mem) > > if ((mem->flags & (MEM_Int | MEM_UInt | MEM_Real | MEM_Null)) != 0) > > return 0; > > if ((mem->flags & MEM_Bool) != 0) { > > - mem->u.u = mem->u.b; > > - MemSetTypeFlag(mem, MEM_UInt); > > + mem->u.u = (uint64_t)mem->u.b; > > + mem->flags = MEM_UInt; > > + mem->field_type = FIELD_TYPE_UNSIGNED; > > 1. Field type wasn't set before. Why did you change that? > Since now I cannot say where field-type and MEM-type are compatible and where they are not, I just set field-type everywhere. Also, since there is no proper rule to determine field-type of the MEM I set the smallest field-type possible for the value of the MEM. This looks like something useless for me, but it is better than checking if field-type is field_type_MAX everywhere end set field-type in case it isn't. > > return 0; > > } > > assert((mem->flags & (MEM_Blob | MEM_Str)) != 0); > > @@ -1454,20 +1464,23 @@ sqlVdbeMemCast(Mem * pMem, enum field_type type) > > return 0; > > } > > if ((pMem->flags & MEM_Bool) != 0) { > > - pMem->u.u = pMem->u.b; > > - MemSetTypeFlag(pMem, MEM_UInt); > > + pMem->u.u = (uint64_t)pMem->u.b; > > + pMem->flags = MEM_UInt; > > + pMem->field_type = FIELD_TYPE_UNSIGNED; > > 2. Ditto. > Same. > > return 0; > > } > > @@ -1801,10 +1826,15 @@ mem_convert_to_integer(struct Mem *mem) > > double d = mem->u.r; > > if (d >= (double)UINT64_MAX || d < (double)INT64_MIN) > > return -1; > > - if (d < (double)INT64_MAX) > > - mem_set_int(mem, (int64_t) d, d < 0); > > - else > > - mem_set_int(mem, (uint64_t) d, false); > > + if (d < 0.) { > > + mem->u.i = (int64_t)d; > > + mem->flags = MEM_Int; > > + mem->field_type = FIELD_TYPE_INTEGER; > > + } else { > > + mem->u.u = (uint64_t)d; > > + mem->flags = MEM_UInt; > > + mem->field_type = FIELD_TYPE_UNSIGNED; > > 3. Previously it was FIELD_TYPE_INTEGER in both cases. Why > did you change that? Same.