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 DDA3C6F872; Fri, 30 Apr 2021 00:02:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DDA3C6F872 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619730129; bh=uXoqqusGSfozojjvdsWHCx9DdHWgGe6ywPZ1U0aieK8=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=QOTRk3gK6yXLmTK8Od694MuffjwZRy1gzeHWJ+JnTR3soEo6ZBsallZfpeUA4Cg/E gTRL+VP2dWrARtHa4mFwO/0ADVDbpP8o203guu6GUCsU3+3ucHjtEIgollNd0oz8Ef vDfu3hVtgUpWiQIAJZoQF9qQHzT++HpmfnQQikvE= Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 DF6116F872 for ; Fri, 30 Apr 2021 00:02:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DF6116F872 Received: by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1lcDnT-0000iv-6I; Fri, 30 Apr 2021 00:02:07 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <05d176765118a7357b5b15d7fcfc08104463522c.1619542456.git.imeevma@gmail.com> Message-ID: <4b765060-a56e-e5d7-2b3a-5adb3a4bd40c@tarantool.org> Date: Thu, 29 Apr 2021 23:02:06 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <05d176765118a7357b5b15d7fcfc08104463522c.1619542456.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD95978C26455E69BE0890FB394E039F71AA2C815CBBA0C08E7182A05F53808504098EC0EACB603DF6CD67D9437B44BC130019D61E34157E4041319AC84FCB50247 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7922D113DFDC6D5A3EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379B0255B5E5688AF88638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2D5F27493A8A424DA371ACCDDCB41AFFAE8578C74B6F99271D2E47CDBA5A96583C09775C1D3CA48CF17B107DEF921CE79117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE70F3DDF2BBF19B93A9FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE76E3465A6F608DDB8D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C0E30F873561A58086CD04E86FAF290E2D80F2F7FAB647BC981DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B67393CE827C55B5F775ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD9380091DD32562D3BE8E0247079BED78 X-C1DE0DAB: 0D63561A33F958A5F10171A56D01EC9D3D1F0DB3BCED93F87EB2D5F9A416916ED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34AC632F0BE69382F3469F5204B2A03FE0859B2789D91A74DE3468CF053094230387A56F4CA6B87B881D7E09C32AA3244C81572C7195F531D002522E2068C98B6681560E2432555DBB729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojVCmWsvwT1HbqqPPv96v/tA== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110D9E78AAFD4FAF7D123BA9ED43FAD9E4007FD25DC8DE6ABBE07784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 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: 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! > 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. > + return; > + if (!mem_is_null(res)) > + sql_result_value(context, res); > + mem_destroy(res); > }