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 6F68B6ECE3; Mon, 1 Nov 2021 16:38:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6F68B6ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635773880; bh=Nz81f7EkMuP5pRDKLH/CHjDeGNdQ7yUGmBvO8yMBrZs=; 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=v7HXkoe13f1CgKF0AvS2U4BLBHjNTqqnfambpItW+sQzWxLoXdcCOGkKLwKMYsAIf 163PFHOmDQw/wBBFBwtERGzWKYqSETR1fQYmzlr/HmM+2bbBcFKkbyPfaEE3L7TxEd ieJ1L0VGMWCvYaUaILG0UunQ4vGBChgMe2+ou110= 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 EC60F6ECE3 for ; Mon, 1 Nov 2021 16:37:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EC60F6ECE3 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mhXVe-0000re-3r; Mon, 01 Nov 2021 16:37:58 +0300 Message-ID: Date: Mon, 1 Nov 2021 14:37:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-US To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org References: <1243ff4d634abefca92dd265e81a64a4d347b56b.1633105483.git.imeevma@gmail.com> <4dd3b621-96a6-5c23-0c92-3a3cf0f398ee@tarantool.org> <20211020165216.GA203963@tarantool.org> <20211101101144.GA227579@tarantool.org> In-Reply-To: <20211101101144.GA227579@tarantool.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD98893113B6235BE91D14F0A97254290008E820E7E92A2F633182A05F53808504093CD0365FEE4A4A1BE117915A74EC6793170D232B025583E531096418E6076A5 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72847AA60176ABEF3EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375C4806A08D329A618638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D82735ACE600FAEB53F97E65A2D411DCF1117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F2CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6CF11E2829993B7FCEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B50548A429534AA05E45A375172376824AC8 X-C1DE0DAB: 0D63561A33F958A5A0E788867E355D8894C23412092F9AD55A70A1BD3F7B1934D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752DA3D96DA0CEF5C48E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3463DBE2ADA183F62F87F0E5419AD59C83598DDD43455F97985650C253CC8B0BACD1FE2761B9CDCBAE1D7E09C32AA3244C60D4AA2C11B54DD4CE5DD8D8A58DDABF3A76366E8A9DE7CA729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsm8N/O5xSHTucx3eajdBog== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DE2A529BD3F8B1FD8EDA87A123DD7839F3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B 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" >>>>> + 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. Sorry, I forgot that we need to copy the result into pOut.