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 0D09F6EC5D; Fri, 9 Apr 2021 22:45:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0D09F6EC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617997538; bh=dMYklijn7g2mnWaE9p2iSeMhpxK5LwsbN0VTt7rG+ao=; 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=EBiuQPMeELyEeK+LOeAFxLm04dHKLin2r4hpSqDkEYZQcMfoCfBHjjWlVezEt2Rdg RmLhdfXinOWQtOefIm/r0MxBe08CESQ8H5ccrcJmLO2O294OvyvyN04AvfJICsWgE7 udJRcehM/5Pup8vGupo1m73Rd9BvCSeG2tA3pFL4= 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 7C2596EC5D for ; Fri, 9 Apr 2021 22:45:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7C2596EC5D Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lUx4R-0006cS-EG; Fri, 09 Apr 2021 22:45:35 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Fri, 9 Apr 2021 22:45:35 +0300 Message-Id: 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: 4F1203BC0FB41BD92FFCB8E6708E7480257C85EA0BB7A95D0F00AE41BB9A5343182A05F5380850402534FE91302666EB9BBBCE80D629F8197FD296C0BD8DD40CDFD091BBB5FA44AE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE782A779A89F7D69B2C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7D3E352D4AD7EBF54EA1F7E6F0F101C67CDEEF6D7F21E0D1D9295C2E9FA3191EE1B59CA4C82EFA65816869513F8129D144CFFF7F90416378FF6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249783E2B6F79C23BEDCC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0F3EFC8F08E14FF8A8941B15DA834481F9449624AB7ADAF372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B6D8C47C27EEC5E9FB5C8C57E37DE458BEDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831712C5303C9CF66A6EEF3C316914408DE X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CD0035DD76F8A8A4F67107B7E6FFB97584577858C12AB67139C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34C53D1911AD7E4199735A969E35CCD14877BF484EC80FDEBE8FAA8DE625933401F92B53CCB7DF759D1D7E09C32AA3244CA1EE7A4203A744DFC270DC155E38816430363D8B7DA7DD44FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyO2lHpuZu4QXW6Fo7Y2MLw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382216A57EAABC78550EA9E43CA4EE3056BD83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v5 26/52] sql: move mem_set_bool() and mem_set_double() 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. I squashed two patches here since they do the same thing - they move functions from one place to another. On 30.03.2021 02:04, Vladislav Shpilevoy wrote: > Thanks for the patch! > > See 2 comments below. > > On 23.03.2021 10:35, Mergen Imeev via Tarantool-patches wrote: >> This patch introduces mem_set_double(). Function mem_set_double() >> clears MEM and sets it to given unsigned value. > > 1. It is not about unsigned. > Fixed. >> Part of #5818 >> --- >> diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h >> index bf3690b7c..49b4e4b1a 100644 >> --- a/src/box/sql/mem.h >> +++ b/src/box/sql/mem.h >> @@ -419,10 +422,6 @@ int sqlVdbeMemClearAndResize(struct Mem * pMem, int n); >> void >> mem_set_ptr(struct Mem *mem, void *ptr); >> >> -/** Set double value and MEM_Real flag. */ >> -void >> -mem_set_double(struct Mem *mem, double value); > > 2. Why do you move these functions and their definitions? What was > wrong with keeping them in place? > I think it is better when all these mem_set_*() functions in one block. This is the only reason, I believe. >> - >> int >> sqlVdbeMemSetStr(struct Mem *, const char *, int, u8, void (*)(void *)); >> void >> New patch: commit fa3fc18275f01e824c6ca8f0bcbf27cb857fb3a8 Author: Mergen Imeev Date: Mon Mar 15 12:42:59 2021 +0300 sql: move mem_set_bool() and mem_set_double() This patch performs a small refactoring of mem_set_double() and moves this function and mem_set_bool() to another place so that they are part of the code block containing all mem_set_*() functions. Part of #5818 diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index d79d471bc..c16f3a28a 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -291,6 +291,26 @@ mem_set_uint(struct Mem *mem, uint64_t value) mem->field_type = FIELD_TYPE_UNSIGNED; } +void +mem_set_bool(struct Mem *mem, bool value) +{ + mem_clear(mem); + mem->u.b = value; + mem->flags = MEM_Bool; + mem->field_type = FIELD_TYPE_BOOLEAN; +} + +void +mem_set_double(struct Mem *mem, double value) +{ + mem_clear(mem); + mem->field_type = FIELD_TYPE_DOUBLE; + if (sqlIsNaN(value)) + return; + mem->u.r = value; + mem->flags = MEM_Real; +} + int mem_copy(struct Mem *to, const struct Mem *from) { @@ -1945,15 +1965,6 @@ sqlVdbeMemClearAndResize(Mem * pMem, int szNew) return 0; } -void -mem_set_bool(struct Mem *mem, bool value) -{ - mem_clear(mem); - mem->u.b = value; - mem->flags = MEM_Bool; - mem->field_type = FIELD_TYPE_BOOLEAN; -} - void mem_set_ptr(struct Mem *mem, void *ptr) { @@ -1962,17 +1973,6 @@ mem_set_ptr(struct Mem *mem, void *ptr) mem->u.p = ptr; } -void -mem_set_double(struct Mem *mem, double value) -{ - mem_clear(mem); - if (sqlIsNaN(value)) - return; - mem->u.r = value; - MemSetTypeFlag(mem, MEM_Real); - mem->field_type = FIELD_TYPE_DOUBLE; -} - /* * Change the value of a Mem to be a string or a BLOB. * diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index 8bc058d3b..8022f53d8 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -174,6 +174,14 @@ mem_set_int(struct Mem *mem, int64_t value, bool is_neg); void mem_set_uint(struct Mem *mem, uint64_t value); +/** Clear MEM and set it to BOOLEAN. */ +void +mem_set_bool(struct Mem *mem, bool value); + +/** Clear MEM and set it to DOUBLE. */ +void +mem_set_double(struct Mem *mem, double value); + /** * 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 @@ -444,9 +452,6 @@ mem_convert_to_numeric(struct Mem *mem, enum field_type type); int sqlVdbeMemGrow(struct Mem * pMem, int n, int preserve); int sqlVdbeMemClearAndResize(struct Mem * pMem, int n); -void -mem_set_bool(struct Mem *mem, bool value); - /** * Set VDBE memory register with given pointer as a data. * @param mem VDBE memory register to update. @@ -455,10 +460,6 @@ mem_set_bool(struct Mem *mem, bool value); void mem_set_ptr(struct Mem *mem, void *ptr); -/** Set double value and MEM_Real flag. */ -void -mem_set_double(struct Mem *mem, double value); - int sqlVdbeMemSetStr(struct Mem *, const char *, int, u8, void (*)(void *)); void