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 577AC70358; Wed, 15 Sep 2021 00:24:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 577AC70358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1631654652; bh=9PS+dSEESr+jm7l5RDDM8Ka36M3L+ADChW8f7nhCmYU=; 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=pzuAbwcY082EQK5HdpJnpCfmZV17lTqj1bmxmAaw3TQG/cqlfCNhoYKm13BmXBxVe fhovfz+NBHmDV1j72YTY5KlKtrJfZgFW3Q4Zje1fnFazZII82RQHclEIqakRYdyovm ESap+A2cEnqB//0PxVipa2K5R2kF3NwRmyh8vqUM= 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 E9A3870358 for ; Wed, 15 Sep 2021 00:24:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E9A3870358 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mQFuT-0007o0-BA; Wed, 15 Sep 2021 00:24:09 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <094e9605f220dbc257dbe43cdd3432934ddd5975.1631289462.git.imeevma@gmail.com> Message-ID: <92b42bb0-428f-ea55-4b95-02e09df4edd7@tarantool.org> Date: Tue, 14 Sep 2021 23:24:08 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <094e9605f220dbc257dbe43cdd3432934ddd5975.1631289462.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2FD33F16D892CA5215E5B7E73120F3783D00894C459B0CD1B904E996C2491AECFABE3FB9CE7280C7964C7EFB8636A5956677EA5CD51374AFCE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C6068CE86C2B75F5EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DA5CEC9EE7F170198638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8FE7ECC5E22A563D43584B6760FB99A03117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10FF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BDCE939D40DBB93CA75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505233A9F1ACC4CB2234A222DA6A79E76FB X-C1DE0DAB: 0D63561A33F958A505E8968B77648F4EADBAD081013797329E0BBB0B7CA16522D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D344E332383F80D58BB53CA20FEE18C2B33DE1B1568A3B7F721DDA2E2CF5334556ECE560CE66A9189DC1D7E09C32AA3244CB4550D88A0C3F0E1BE5DC0DACF88E7E6A90944CA99CF22E3729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj2yA91e2A1g0UhvmmCHC1Wg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DADBBFD45DB20B87D0C7221983FA0A5103841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 08/13] sql: rework AVG() 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" Thanks for the patch! > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index 12a6a5a2c..9e0c09206 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -102,6 +102,44 @@ fin_total(struct sql_context *ctx) > mem_copy_as_ephemeral(ctx->pOut, ctx->pMem); > } > > +/** Implementation of the AVG() function. */ > +static void > +step_avg(struct sql_context *ctx, int argc, struct Mem **argv) > +{ > + assert(argc == 1); > + (void)argc; > + assert(ctx->pMem->type == MEM_TYPE_NULL || mem_is_bin(ctx->pMem)); > + if (argv[0]->type == MEM_TYPE_NULL) > + return; > + if (ctx->pMem->type == MEM_TYPE_NULL) { > + uint32_t size = 2 * sizeof(struct Mem); > + struct Mem *mems = sqlDbMallocRawNN(sql_get(), size); Previously only size of mem + uint32 was allocated, now it is 2 size of mem. Lets stick to the more compact version. For the division in the end you can create a mem on the stack, for instance.