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 747C16EC60; Tue, 30 Mar 2021 02:02:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 747C16EC60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617058959; bh=jsAY5n6PYQqxfB2PF13ATjlPYW284dm2if6Ahd6dgiQ=; 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=YSEf68FTVBcsV6xNJ4UQ6ALAeZVXydtn+EMhYBfYB43UI7m762FRj6/iCGchM+2F3 6q9FZhZQW1vAn+OuyJvJ9DTttun0SoYsmEXz2GrrVn5rA59OdyTMYuk+35xu0z+ANv YYMvqB25lquryifmrsbt8RlyEhOZUJc4bRSibe+Q= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 F18666C185 for ; Tue, 30 Mar 2021 02:01:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F18666C185 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lR0tG-00030Z-7w; Tue, 30 Mar 2021 02:01:46 +0300 To: imeevma@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <851163339776934088ab040a37043337497e65a9.1616491731.git.imeevma@gmail.com> Message-ID: <438f32c9-d7a0-06c4-92d0-91b470fd6ebe@tarantool.org> Date: Tue, 30 Mar 2021 01:01:45 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <851163339776934088ab040a37043337497e65a9.1616491731.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E329498ADEA61F680B110809A4DE3E6FC56EA182A05F53808504089A6FC78CC1A7367480465927FE0F137D1E95016829EA171FD251CEC8D4791AD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7484B509D84968742EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375CC217B55A7C05578638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CE99938B3FD79E1DFBE7A901C07D288F6C4B64AB26EEA3707A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE74A95F4E53E8DCE969FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C390D92131081DE748117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947C0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735C6EABA9B74D0DA47B5C8C57E37DE458BEDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831BA35FD678FCE4FDB03B6B7CA29D26CC3 X-C1DE0DAB: 0D63561A33F958A584403190E0213E51E9FC47839D988E1621254F6748DF9D9DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346EDE9E12965E8CD5ACAED99D2A7CC577964B22941C1EC7082C6AC3B3D8FC9F6E3005246E7E78B53B1D7E09C32AA3244CD63D5F6D78FED2517BCA80CED05041E3E8FBBEFAE1C4874CFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojljIiQOC84rQGdMnULWhfkA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822FD6A03157819B7AB7B20448EAA1358AA3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 13/53] sql: introduce mem_copy_as_ephemeral() 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! See 3 comments below. On 23.03.2021 10:35, Mergen Imeev via Tarantool-patches wrote: > This patch intoduces mem_copy_as_ephemeral(). This function copies value > from source MEM to destination MEM. In case value is of string or binary > type and its allocation type is not static, it copied as value with > ephemeral allocation type. > > Part of #5818 > --- > src/box/sql/mem.c | 58 ++++++++++++++++++++-------------------------- > src/box/sql/mem.h | 15 ++++++------ > src/box/sql/vdbe.c | 10 ++++---- > 3 files changed, 38 insertions(+), 45 deletions(-) > > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index f12441d7c..30c568970 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -289,6 +289,25 @@ mem_copy(struct Mem *to, const struct Mem *from) > return 0; > } > > +int > +mem_copy_as_ephemeral(struct Mem *to, const struct Mem *from) 1. Why didn't you keep its return type void? > +{ > + mem_clear(to); > + to->u = from->u; > + to->flags = from->flags; > + to->subtype = from->subtype; > + to->field_type = from->field_type; > + to->n = from->n; > + to->z = from->z; > + if ((to->flags & (MEM_Str | MEM_Blob)) == 0) > + return 0; > + if ((to->flags & (MEM_Static | MEM_Ephem)) != 0) > + return 0; > + to->flags &= (MEM_Str | MEM_Blob | MEM_Term | MEM_Zero | MEM_Subtype); > + to->flags |= MEM_Ephem; > + return 0; > +} > @@ -593,9 +598,12 @@ sqlVdbeMemAboutToChange(Vdbe * pVdbe, Mem * pMem) > int i; > Mem *pX; > for (i = 0, pX = pVdbe->aMem; i < pVdbe->nMem; i++, pX++) { > - if (pX->pScopyFrom == pMem) { > - pX->flags |= MEM_Undefined; > - pX->pScopyFrom = 0; > + if ((pX->flags & (MEM_Blob | MEM_Str)) != 0 && > + (pX->flags & (MEM_Ephem | MEM_Static)) == 0) { > + if (pX->pScopyFrom == pMem) { > + pX->flags |= MEM_Undefined; > + pX->pScopyFrom = 0; > + } 2. Why did you change that? > } > } > pMem->pScopyFrom = 0; > diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c > index 05e0f78c1..55083fb23 100644 > --- a/src/box/sql/vdbe.c > +++ b/src/box/sql/vdbe.c > @@ -979,7 +979,7 @@ case OP_Copy: { > pOut = &aMem[pOp->p2]; > assert(pOut!=pIn1); > while( 1) { > - sqlVdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); > + mem_copy_as_ephemeral(pOut, pIn1); > Deephemeralize(pOut); 3. You could turn mem_copy_as_ephemeral + Deephemeralize into mem_copy the previous commit where mem_copy was introduced.