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 3BEE16ECE3; Mon, 1 Nov 2021 13:11:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3BEE16ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635761509; bh=oqbNckzxwFOadHaStazAAIDRLcZSjpxWMS1cd9EOcxo=; 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=VchaDPDPSX7RZjf+wOZJ7tCPTXUS5iPSqrfilVawxQkmC6qFc5+KOgL8ZpXCSkJTW 4Gz0Ma1IgYArJLK2E6Q8MsNbXJUKd1/e/YJ+nAev19QWOosS3ToRS0AHjpqO3Dy/98 NCr/KEBHlHxtFdQ0xRymB3LSwSb/KEd9379D28U8= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 02E6A6ECE3 for ; Mon, 1 Nov 2021 13:11:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 02E6A6ECE3 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mhUI6-0005WE-54; Mon, 01 Nov 2021 13:11:46 +0300 Date: Mon, 1 Nov 2021 13:11:44 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20211101101144.GA227579@tarantool.org> References: <1243ff4d634abefca92dd265e81a64a4d347b56b.1633105483.git.imeevma@gmail.com> <4dd3b621-96a6-5c23-0c92-3a3cf0f398ee@tarantool.org> <20211020165216.GA203963@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD98893113B6235BE91C46E99D8C26DA1C34F06EDE78E423F14182A05F5380850408844023032C04EFE3108A9F4211A3DF8ADFC32C170DC2485A34BD27B25303ADE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7227E4400968B082FEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FA81DCE0280C9CC68F08D7030A58E5AD1A62830130A00468AEEEE3FBA3A834EE7353EFBB553375662EF5425C000D225826E40F87451A7E270F048F3E11983B5AA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE77A825AB47F0FC8649FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3E97D2AE7161E217F117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AF8E4F18C523FAA9EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B5056C8B14966F4E7F21195E243D0CA925B1 X-C1DE0DAB: 0D63561A33F958A5B45FA3A4F3F108E9C6F5B2847FAF0014B6EFDCFAE89E07AAD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752DA3D96DA0CEF5C48E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B222596F62B8FA9C8A4D0FBA8FDF736E0F3DAB324E9564DFDC60FDB748185EA9C8958318FC8E2351D7E09C32AA3244CC16653D8FFDE5643BD9643320AC1F3A07101BF96129E4011729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsm8N/O5xSHSrdxtgldybLA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D71DD97FFAA6D755DE1CEC4D226FC93C283D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B 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: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thank you the review! My answer below. On Fri, Oct 29, 2021 at 12:11:11AM +0200, Vladislav Shpilevoy wrote: > Hi! Thanks for the fixes! > > >>> + 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. > >> > > I am not sure that I understood correctly. In case of argument being uint we > > can use mem_copy_as_ephemeral() instead of mem_set_uint(), but I am not sure > > if it would be better. > > I mean this: > > ==================== > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index dbeb38bee..2a848be31 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -239,11 +239,10 @@ func_abs_int(struct sql_context *ctx, int argc, struct Mem *argv) > assert(argc == 1); > (void)argc; > struct Mem *arg = &argv[0]; > - if (mem_is_null(arg)) > + if (mem_is_null(arg) || mem_is_uint(arg)) > return; > assert(mem_is_int(arg)); > - uint64_t u = mem_is_uint(arg) ? arg->u.u : (uint64_t)-arg->u.i; > - mem_set_uint(ctx->pOut, u); > + mem_set_uint(ctx->pOut, (uint64_t)-arg->u.i); > } > ==================== > > Up to you. This would work for aggregate function in some cases, but not here. If we apply such diff the result of ABS() for UNSIGNED will be NULL.