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 8C5B870358; Wed, 15 Sep 2021 00:23:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8C5B870358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1631654597; bh=iNDs4wKeLSVodM2Ue4mZZv5cimyQ70VCslOXn8CIl9g=; 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=s3nvCUAWAodoSXhnc2Xj3DzrnBQsuM5zQymZy/ub1+17Td9Vo9HKA4ayPXTP7i6G2 TNaO4Ou5I4Yt5mPti8zXLdEJtPouv5AmlzpJaHw2IK4+CIbYmfFkHaXtVAw1lpNgBk I4O9b2xMGBZnTGWa4muj8U9DUTr7zqs+nEf9AHlk= 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 8EF8670358 for ; Wed, 15 Sep 2021 00:23:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8EF8670358 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mQFtb-00078C-U4; Wed, 15 Sep 2021 00:23:16 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <91914a74a5efe636fab891ceee5bf1fba5678948.1631289462.git.imeevma@gmail.com> Message-ID: Date: Tue, 14 Sep 2021 23:23:15 +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: <91914a74a5efe636fab891ceee5bf1fba5678948.1631289462.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2FAC52BB37A480E789638BB4D06A25224200894C459B0CD1B962294BBC60BFC78AD42ACCCD736009CC4C7EFB8636A5956629C25ED172725C63 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77E9806EB691FCCC6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378D70459434292EC88638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A6A4F7458D0D779F3B134A9C4316DCD8117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520B1593CA6EC85F86D618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505233A9F1ACC4CB2233209A442F726EAAC X-C1DE0DAB: 0D63561A33F958A5198A512345752F65F6438253E9F8DFC632C609EE34C47333D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A541DB4061E93832BC892D4F621EC8A00FFE309F1366FECB8131756EAF3D4544254E22DBD4CA04EE1D7E09C32AA3244CF60A9D1CFF56C3B227E9A967A9B778637101BF96129E4011729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj2yA91e2A1g3NAeTdFyPM1A== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D056DD54CC0584BBA8B86B31D41AC6E483841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B 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" Good job on the patch! > 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. > + 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)); > +