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 47DA86C1AE; Mon, 17 May 2021 14:38:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 47DA86C1AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621251513; bh=w4yPL9lsMRQYFeskdXZRu7OLRATezGYEgl7k1NC05Go=; 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=smZWrBqa2vnARcB6CxOxeIyexSGLeOOcFF5nsTcVRaRDzwNOm7kUUKAwtd6xEJEms FwlWo725sZmF7Zi2UjXZxcbZj45vQBfsR3kDoKLdW0kigw1HUckoXbiRs01tynwzaR J2LXitNrrOyyiinDIRm6uEH7YISxgZvaPUrvt2o8= 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 C29176C1AE for ; Mon, 17 May 2021 14:38:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C29176C1AE Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1libZt-0002Ra-JI; Mon, 17 May 2021 14:38:29 +0300 Date: Mon, 17 May 2021 14:38:28 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20210517113828.GA177059@tarantool.org> References: <05d176765118a7357b5b15d7fcfc08104463522c.1619542456.git.imeevma@gmail.com> <4b765060-a56e-e5d7-2b3a-5adb3a4bd40c@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4b765060-a56e-e5d7-2b3a-5adb3a4bd40c@tarantool.org> X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95978C26455E69BE0BB6090B4F8997C21AA3492AFA30115D5182A05F538085040021A53CF8F18E8BFEC44A131F66629201AC6B8DAB4A7355F6D2D08A40ED5735A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE731D82F3F177D3BCDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378A9F193E39E334918638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CC013D769C7BC67C7094D613CE2B2D02117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10FF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B2303E78B907142AC75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5F2ABC006D260FDF17D64E15C385F906AB905D7FE9B0D2F54D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752546FE575EB473F1410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3474B2583E513159847883A57577683D9F95829A41CC16E105CF79124A7625A69DC4B49BB74F320B321D7E09C32AA3244CCCDF063E9DDD0B8DF7260204413FD68E81560E2432555DBB729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojlIWKWc0dtJ21C2cF3Kij3Q== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382289A2F557E766D1876E9A3D391A71BDA783D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 1/3] sql: initialize MEM used in aggregate functions 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 for the review! My answer and diff below. On Thu, Apr 29, 2021 at 11:02:06PM +0200, Vladislav Shpilevoy wrote: > Hi! Thanks for the patch! > > > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > > index 9c28d5122..d282b2cea 100644 > > --- a/src/box/sql/func.c > > +++ b/src/box/sql/func.c > > @@ -1798,14 +1798,13 @@ minmaxStep(sql_context * context, int NotUsed, sql_value ** argv) > > static void > > minMaxFinalize(sql_context * context) > > { > > - sql_value *pRes; > > - pRes = (sql_value *) sql_aggregate_context(context, 0); > > - if (pRes) { > > - if (pRes->flags) { > > - sql_result_value(context, pRes); > > - } > > - mem_destroy(pRes); > > - } > > + struct Mem *mem = context->pMem; > > + struct Mem *res; > > + if (!mem_is_agg(mem) || mem_get_agg(mem, (void **)&res) != 0) > > You don't need `is_agg` check. `get` does the same already. > Fixed. > > + return; > > + if (!mem_is_null(res)) > > + sql_result_value(context, res); > > + mem_destroy(res); > > } Diff: diff --git a/src/box/sql/func.c b/src/box/sql/func.c index d282b2cea..94302cc56 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -1800,7 +1800,7 @@ minMaxFinalize(sql_context * context) { struct Mem *mem = context->pMem; struct Mem *res; - if (!mem_is_agg(mem) || mem_get_agg(mem, (void **)&res) != 0) + if (mem_get_agg(mem, (void **)&res) != 0) return; if (!mem_is_null(res)) sql_result_value(context, res);