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 DD3BF6EC40; Tue, 21 Sep 2021 13:47:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DD3BF6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632221279; bh=48e0LIJmv3iP0mqQdvp8jJj166PhdcVi0IBnrcFvxmo=; 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=fyjk0Ddyr6YXGdlRxq6J8BP2rNB1M1/H3UnKUWH5zI+oXgP0liyUXJRmlDNgXaDet 8K2fxKL+JdUYrReupO+VlzFPujf1SUIoryocXJ1/+dOCM7D4g2quXlWl5+s3DwY+8K yNDleVdwCC4GX6B88zqPBxksArEoLSonnBmquKVU= 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 E4B666EC40 for ; Tue, 21 Sep 2021 13:47:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E4B666EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mSdJc-0005GV-5a; Tue, 21 Sep 2021 13:47:56 +0300 Date: Tue, 21 Sep 2021 13:47:54 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20210921104754.GB16139@tarantool.org> References: <91914a74a5efe636fab891ceee5bf1fba5678948.1631289462.git.imeevma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2F5A5BD9D2085A59586CBBC9313A5A610100894C459B0CD1B95934F1402548253BB1C640F3A26A9C69994D8960CDEEF0A8872416D062D2E1BD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE720D3C300AFAD2243C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE76DA79C5AFF329FDBEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2603CBE0B6D80B0F74015DAA2338CADD0CC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637F3E38EE449E3E2AE389733CBF5DBD5E9B5C8C57E37DE458B9E9CE733340B9D5F3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E7354E672349037D5FA5C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A536753BC6EB4EEE67737D2ED1290027D5FA687722D79ACF35D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75DD5744CF7ED0C6846D6546786ADF492D5A0AA20F8A0307212E763F503762DF50C50CB974A6A31CF68E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3472E5ECC12A9739C172A39FD19EB7542BA9B3007D96DB57C0B04C5E53E833CFC9D6195081EDFD5E521D7E09C32AA3244CFD1EF5BE1A21EFC76614FF3F8A7412BBE3D93501275E802F729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnvI84oHUDXALTKuDWzre9Q== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D3ACAA1D2AF43A5A1263C83BE7A9252ED83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B 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: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thank you for the review! My answer below. On Tue, Sep 14, 2021 at 11:23:15PM +0200, Vladislav Shpilevoy wrote: > 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. > 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? > > + 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)); > > +