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 4308A6EC63; Fri, 9 Apr 2021 23:06:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4308A6EC63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617998791; bh=zC+GiK1WRzzxUElPy4P7As+06U+OZkfDPjClUJkE2eo=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=WlgwrAjYXkNXVeCQC5Sss9eI/0+TcaWnQBmCl3898EF5zKUUXgegWZdJDUDHxuSzz FZIlpgzDlNi0EZOxlQP23wsiI0NlvUgNWtfpXZFekR1I1cTMtP5Rx9tkty+GL5ygwq Nff2hWx94O5fqk2H8C6qMwb9v6uh7HmuUtY5QmgM= 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 53DB06C7D1 for ; Fri, 9 Apr 2021 23:05:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 53DB06C7D1 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lUxNj-0005rV-KV; Fri, 09 Apr 2021 23:05:32 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Fri, 9 Apr 2021 23:05:31 +0300 Message-Id: <07b94caea28f23d61ba6f8a31d0ce70c7829dde6.1617984948.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480B1C8842CE613979772AC4B34408C6525182A05F5380850400E8BCFF48637773472894C5BA48CBD4F957229D26FEF6632EC93BB827EF75FEE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C4A7E4C0BFE8628DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637575FD8E213AF258FEA1F7E6F0F101C67CDEEF6D7F21E0D1D9295C2E9FA3191EE1B59CA4C82EFA658F20E6B9F009EA876D0937156BB348D79F6B57BC7E64490618DEB871D839B73339E8FC8737B5C22495FF0BFC5AEE34BE6CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C02F11D39E7306DD338941B15DA834481F9449624AB7ADAF372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B6D8C47C27EEC5E9FB5C8C57E37DE458BEDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978310CCB944C547E9CAF2240D5316989BD39 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CD0035DD76F8A8A4F44A747E3D9CB28755085298090D7764D9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A5112A9AECFE11B1E43D076916E614A031E29CB0E474EDD1971B53453D086EBF1C824426599D37611D7E09C32AA3244C27B332E2C2A5B6AA6E3C85DFAD4E750AF2F5F14F68F1805BFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyO2lHpuZu4RclSRWHTYklw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638228BF55C1E5AAE5F934F04134211C6C50D83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v5 33/52] sql: introduce mem_set_invalid() 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: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thank you for the review! My answer and new patch below. On 30.03.2021 02:06, Vladislav Shpilevoy wrote: > Thanks for the patch! > > On 23.03.2021 10:36, Mergen Imeev via Tarantool-patches wrote: >> This patch introduces mem_set_undefined() function. Function >> mem_set_undefined() invalidates MEM. It does not clears MEM prior to >> invalidating it. > > Why does not it clear it? Usually MEM_Undefined is just set to MEM without any other changes. I cannot say for sure that all MEMs that have this flag set did not have MEM_Dyn, MEM_Frame or MEM_Agg set previously. I added clear() to the function. New patch: commit 07b94caea28f23d61ba6f8a31d0ce70c7829dde6 Author: Mergen Imeev Date: Tue Mar 16 14:26:55 2021 +0300 sql: introduce mem_set_invalid() This patch introduces mem_set_invalid() function. This function clears MEM and invalidates it. Part of #5818 diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index 61849cde7..b97904f22 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -589,6 +589,13 @@ mem_set_array_allocated(struct Mem *mem, char *value, uint32_t size) set_msgpack_value(mem, value, size, 0, FIELD_TYPE_ARRAY); } +void +mem_set_invalid(struct Mem *mem) +{ + mem_clear(mem); + mem->flags = MEM_Undefined; +} + int mem_copy(struct Mem *to, const struct Mem *from) { diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index b3a602f6e..fe3d8d98f 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -352,6 +352,10 @@ mem_set_array_dynamic(struct Mem *mem, char *value, uint32_t size); void mem_set_array_allocated(struct Mem *mem, char *value, uint32_t size); +/** Clear MEM and set it to invalid state. */ +void +mem_set_invalid(struct Mem *mem); + /** * Copy content of MEM from one MEM to another. In case source MEM contains * string or binary and allocation type is not STATIC, this value is copied to diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 9434a4d06..0031d2248 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -77,7 +77,7 @@ sqlVdbeMemAboutToChange(Vdbe * pVdbe, Mem * pMem) if (mem_is_bytes(pX) && !mem_is_ephemeral(pX) && !mem_is_static(pX)) { if (pX->pScopyFrom == pMem) { - pX->flags |= MEM_Undefined; + mem_set_invalid(pX); pX->pScopyFrom = 0; } } @@ -629,7 +629,7 @@ case OP_Return: { /* in1 */ pIn1 = &aMem[pOp->p1]; assert(mem_is_uint(pIn1)); pOp = &aOp[pIn1->u.u]; - pIn1->flags = MEM_Undefined; + mem_set_invalid(pIn1); break; } @@ -672,7 +672,7 @@ case OP_EndCoroutine: { /* in1 */ assert(pCaller->opcode==OP_Yield); assert(pCaller->p2>=0 && pCaller->p2nOp); pOp = &aOp[pCaller->p2 - 1]; - pIn1->flags = MEM_Undefined; + mem_set_invalid(pIn1); break; } @@ -4181,8 +4181,8 @@ case OP_Program: { /* jump */ pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem]; for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++) { - pMem->flags = MEM_Undefined; - pMem->db = db; + mem_create(pMem); + mem_set_invalid(pMem); } } else { pFrame = pRt->u.pFrame; diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index c294a0286..a5e78be06 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -1592,7 +1592,7 @@ sqlVdbeMakeReady(Vdbe * p, /* The VDBE */ p->nMem = nMem; for (int i = 0; i < nMem; ++i) { mem_create(&p->aMem[i]); - p->aMem[i].flags = MEM_Undefined; + mem_set_invalid(&p->aMem[i]); } memset(p->apCsr, 0, nCursor * sizeof(VdbeCursor *)); }