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 6CDDB6EC40; Thu, 23 Sep 2021 01:47:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6CDDB6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632350826; bh=DF21/ajmKd84lMhoO2T40HUS3Mp1MSdHjOEkP8K/jz4=; 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=t78i5+kAVRHffI1j9lZFG6+X+qyiOKRWyKtZfmW1UB8bDa4n7YKp+dQNeiZjFYoMA sUkFyS+fIT+L6Im1tHM+QWKedINlMhZkwP+LxxcQcPHWi61aNvyELrzMNMtxJUpAzt ZLu6/kTHyEOdNq9cnGCxDVBf3VPyI1hZb5XSz380= 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 BA7D06EC40 for ; Thu, 23 Sep 2021 01:47:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BA7D06EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mTB15-0004Ie-0j; Thu, 23 Sep 2021 01:47:03 +0300 To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org References: <91914a74a5efe636fab891ceee5bf1fba5678948.1631289462.git.imeevma@gmail.com> <20210921104754.GB16139@tarantool.org> Message-ID: <19258650-a98e-a6e0-f1c8-b2f12a2a4ca3@tarantool.org> Date: Thu, 23 Sep 2021 00:47:02 +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: <20210921104754.GB16139@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2FBA0FFC16CEFBFC694531AE86BFF036DF00894C459B0CD1B9B484879C8D76B9D30D7823A704C48A98DC443D2BA0B873E5656845135F6258BD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72DF3470F92485B86EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379C6642364E0E74208638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D88481AB8855AE69502895F4B49AEA058C117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B60CDF180582EB8FBA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C565C1E6824D8037B43847C11F186F3C59DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505146249CD04DF8AE9197D096C02FE94D5 X-C1DE0DAB: 0D63561A33F958A5E7BCBBC1FFE311B2987D8F8F4655B0F2C1D4A65407C94FD5D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA759D2A03B9C34326B3410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D75CEA0D7A80616E19A75DB5E42523FA4301E3DD38057315A71BF2751C5FD33C0F8DBDC69EB114251D7E09C32AA3244C1922D549CFCE0848D200F9803C96448E1E098CBE561D6343729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojYVPXnTWjYf5hburJBtL5kQ== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DF703BDBF1FA1B2E53448024B8DE3DBD83841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 05/13] sql: remove sql_vdbemem_finalize() 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 fixes! >>> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c >>> index 12dc9126b..dfab86c50 100644 >>> --- a/src/box/sql/vdbe.c >>> +++ b/src/box/sql/vdbe.c >>> @@ -4204,16 +4204,32 @@ case OP_AggStep: { >>> * the step function was not previously called. >>> */ >>> case OP_AggFinal: { >>> - Mem *pMem; >>> assert(pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor)); >>> - pMem = &aMem[pOp->p1]; >>> - assert(mem_is_null(pMem) || mem_is_agg(pMem)); >>> - if (sql_vdbemem_finalize(pMem, pOp->p4.func) != 0) >>> + struct func_sql_builtin *func = (struct func_sql_builtin *)pOp->p4.func; >>> + struct Mem *pIn1 = &aMem[pOp->p1]; >>> + assert(mem_is_null(pIn1) || mem_is_agg(pIn1)); >>> + >>> + struct sql_context ctx; >>> + memset(&ctx, 0, sizeof(ctx)); >>> + struct Mem t; >> >> Please, use mem_create(). Also for the context I would propose to add >> sql_context_create(). So as not to touch internals of the struct here >> directly. >> > I suggest to leave it as it is for now, since I plan to completely drop > struct sql_context from finalize functions in a few patches in this patch-set. > What do you think? mem_create() would be just -3 and +1 line in the patch. I suggest to use it. Previously memset was tolerated because it was done in mem.c, where it is allowed to touch Mem internals directly. >>> + memset(&t, 0, sizeof(t)); >>> + t.type = MEM_TYPE_NULL; >>> + assert(t.flags == 0); >>> + t.db = pIn1->db; >>> + ctx.pOut = &t; >>> + ctx.pMem = pIn1; >>> + ctx.func = pOp->p4.func; >>> + func->finalize(&ctx); >>> + assert((pIn1->flags & MEM_Dyn) == 0); >>> + if (pIn1->szMalloc > 0) >>> + sqlDbFree(pIn1->db, pIn1->zMalloc); >>> + memcpy(pIn1, &t, sizeof(t)); >>> +