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 1820A6EC55; Sat, 9 Oct 2021 00:55:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1820A6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633730136; bh=d+P/57Hsklen8c4sMcGKCRKHN5Dl8PXe2cBZQL7N/Gg=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=zDIONgCsK0EtVeBqB28yjfQEVMO4yw2POhLnFwgJma2S3aZnxeROA+Huwdlt6rqra SKj+FWLWKcym6tWwrP9Ah/LMfwTEu8psdDuP/UVf6XL/hcecFA/SPi7SsRmTnsHn2o R+h+LIr0/dGFVM1yNNEybki0T3oy9RX/bafbicD4= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 2B7706EC55 for ; Sat, 9 Oct 2021 00:55:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2B7706EC55 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mYxq2-0006GY-6X; Sat, 09 Oct 2021 00:55:34 +0300 Message-ID: <4dd3b621-96a6-5c23-0c92-3a3cf0f398ee@tarantool.org> Date: Fri, 8 Oct 2021 23:55:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <1243ff4d634abefca92dd265e81a64a4d347b56b.1633105483.git.imeevma@gmail.com> Content-Language: en-US In-Reply-To: <1243ff4d634abefca92dd265e81a64a4d347b56b.1633105483.git.imeevma@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9A6D4E3B1981C4C7D1676026DFCB81A25119F3452106D1766182A05F538085040FF7DB9511FD7B3551C5EB84A52BC9F0F987F4C16F9B3DCC072E61BFF9A10F4B2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE745C0EDBD94D46193EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063786F1F539FBE87B778638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D823555C01F17C3E50513014519CF5762C117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A59DF66B6B5F73838AF2C5655D3FE260AE50E38CBC9FC6A13CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA755C623DA9A0966939410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349A401E2B4D763A4A90554428DC26E9663DE2003AA6F4E93549AF9DB6564324F2843F05164C5FA20F1D7E09C32AA3244CC07899EA9F9D80BF07A43AA21E6A619D30452B15D76AEC14729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMZ06aokA6bqgok7+bFZQZQ== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D13CEAD8D91D08A8F20BD853BA7155E853841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/8] sql: refactor ABS() funcion 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" Hi! Thanks for the patch! On 01.10.2021 18:29, imeevma@tarantool.org wrote: > Part of #4145 > --- > src/box/sql/func.c | 83 +++++++++++++++++----------------------------- > 1 file changed, 30 insertions(+), 53 deletions(-) > > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index b23636d7e..54b03f359 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -237,6 +237,32 @@ step_group_concat(struct sql_context *ctx, int argc, struct Mem *argv) > ctx->is_aborted = true; > } > > +/** Implementations of the ABS() function. */ > +static void > +func_abs_int(struct sql_context *ctx, int argc, struct Mem *argv) > +{ > + assert(argc == 1); > + (void)argc; > + struct Mem *arg = &argv[0]; > + if (arg->type == MEM_TYPE_NULL) > + return; 1. Need mem_is_null(). The same for the other places if there are more. > + assert(mem_is_int(arg)); > + uint64_t u = mem_is_uint(arg) ? arg->u.u : (uint64_t)-arg->u.i; 2. You could make return when mem_is_uint(). It would remove '?' and mem_set_uint() which would calls mem_clear() inside. > + mem_set_uint(ctx->pOut, u);