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 BC3746EC63; Fri, 9 Apr 2021 23:26:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BC3746EC63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617999984; bh=b1lr79cBywCwR7mEF2FYr/IgqI8Ki1qggL8KB+j+oxM=; 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=iZ93jkFBMmdwWt5YA0yWd+EM/kToXxGunFd4imsxEW9QFjg2SduIpyt5CgISFu/t/ zh7bMTAqCjILXpx3FtMALoSGZ0G5yM2FhVQyc3rAFoYE9fznGXGWk6QD+eN+5wXNAr BA4iyTppDKBGjuMSpXssRk9EShq2XtZUG7xQ9kZw= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [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 111716EC63 for ; Fri, 9 Apr 2021 23:25:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 111716EC63 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lUxhS-0004qz-4e; Fri, 09 Apr 2021 23:25:54 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Fri, 9 Apr 2021 23:25:53 +0300 Message-Id: <05413fe121d62c5163593436df9fc8f1a7d2c295.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: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480B1C8842CE613979723F2FB4628545A35182A05F53808504083ED506E7565204E78C5420366EABD4B4BDF41356FE97B725F3EE3012E9D3F3C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78E88BD1CA827EF00C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE72407438AC6002944EA1F7E6F0F101C67CDEEF6D7F21E0D1D9295C2E9FA3191EE1B59CA4C82EFA6586D95095CB0BA6BC984DE8A5BAF58E749F6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249A70DDFFB3186CBC5CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C015BBC38BE64FE4678941B15DA834481F9449624AB7ADAF372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B6D8C47C27EEC5E9FB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CD0035DD76F8A8A4F6085A9F1B3607A4716539B129E36CAA29C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348BE83DFD8AFB1CACC5F555339FB81323F9D17ED1E2911EF298537C4D9499D2C2CDABAB1A38CA8A5B1D7E09C32AA3244C24419DDF69AF88130CB44DCBF53D7B54A995755A1445935EFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyO2lHpuZu4SCfoir1cf2Vg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382211295F7A453DA822961F3676C10AAB3C83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v5 37/52] sql: introduce mem_set_null_clear() 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 answers and new patch below. On 30.03.2021 02:07, Vladislav Shpilevoy wrote: > Thanks for the patch! > > I propose to rename that to mem_set_null_clear(). Because > it is a NULL, but with special semantics. Done. New patch: commit 05413fe121d62c5163593436df9fc8f1a7d2c295 Author: Mergen Imeev Date: Tue Mar 16 15:14:32 2021 +0300 sql: introduce mem_set_null_clear() This patch introduces mem_set_null_clear() function. This function sets "cleared" NULL to MEM. This NULL is used only in internal VDBE operations. Part of #5818 diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index af11ae1d5..2e147291f 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -629,6 +629,13 @@ mem_set_agg(struct Mem *mem, struct func *func, int size) return 0; } +void +mem_set_null_clear(struct Mem *mem) +{ + mem_clear(mem); + mem->flags = MEM_Null | MEM_Cleared; +} + 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 cf0db62f9..f17c4bb78 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -371,6 +371,10 @@ mem_set_frame(struct Mem *mem, struct VdbeFrame *frame); int mem_set_agg(struct Mem *mem, struct func *func, int size); +/** Clear MEM and set it to special, "cleared", NULL. */ +void +mem_set_null_clear(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 7f1e0bcbe..4566606d7 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -855,7 +855,7 @@ case OP_String: { /* out2 */ * is less than P2 (typically P3 is zero) then only register P2 is * set to NULL. * - * If the P1 value is non-zero, then also set the MEM_Cleared flag so that + * If the P1 value is non-zero, then also set the Cleared flag so that * NULL values will not compare equal even if SQL_NULLEQ is set on * OP_Ne or OP_Eq. */ @@ -865,13 +865,14 @@ case OP_Null: { /* out2 */ cnt = pOp->p3-pOp->p2; assert(pOp->p3<=(p->nMem+1 - p->nCursor)); if (pOp->p1 != 0) - pOut->flags = MEM_Null | MEM_Cleared; + mem_set_null_clear(pOut); while( cnt>0) { pOut++; memAboutToChange(p, pOut); - mem_set_null(pOut); if (pOp->p1 != 0) - pOut->flags = MEM_Null | MEM_Cleared; + mem_set_null_clear(pOut); + else + mem_set_null(pOut); cnt--; } break;