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 46F406BD28; Tue, 13 Apr 2021 02:36:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 46F406BD28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618270577; bh=9kKSFNRg+20ogDG5T/tF/L7eu714Kcp2S6+D6oHZdtA=; 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=zk3g0PMrlJlSnynRZnjxuN2KGmL8Hy8OPFXL+JUS5FlMpzZujnMQiHTpgZEOS4GbV inl6VY4W7B1eO53lX0cxOjnlBJ/oCKMD5ZHBf30qaxY0HVTC3AqGoF8v8A8+HN8xY7 1PBsWHygfl62lvb99nWjWaUatTXsU6m/6OQFIIG0= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 DC4566BD23 for ; Tue, 13 Apr 2021 02:36:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DC4566BD23 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lW66K-0004jN-2b; Tue, 13 Apr 2021 02:36:16 +0300 To: imeevma@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <70953d26-6661-8f6f-9172-c1f4430999d5@tarantool.org> Date: Tue, 13 Apr 2021 01:36:15 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E74807BAE725B9AE625DE765B0E193B5B7687182A05F538085040C414752752038FB376F94D81B3BA5D5F3F4ABEF177675130C64AA74AA423F5C3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE752E71F0C64B7C834EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063729381D024F10DD158638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2CA917B8A9B0D07C9FA694DFA170F9D30A2BB4B7391E66DBBD2E47CDBA5A96583C09775C1D3CA48CF27ED053E960B195E117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE73AFA331E307B52169FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA73A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735D05AD665AB97B35DC4224003CC83647689D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831A13B1FDF0624C3107D884B766E578A04 X-C1DE0DAB: 0D63561A33F958A5A4D2CB3459C19B99946E0BA131F4F7F62492A669239841FFD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F3735C80F9F4B96D0B02B75A49FA010D98EC147C8E1433F2030B8FA5198E6EB60EB5E69AC54099471D7E09C32AA3244C9DABD095CDBDBAF173ADCEEECC20DBDF5A1673A01BA68E40FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojq8JA+pXcDul/QSvje4lKmg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822E2A0328B4CE26B0DD4FB0F2B9BC15CF83841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v5 30/52] sql: introduce mem_copy_bin() 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" I appreciate the work you did here! See 2 comments below. > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 2622cdd82..e30795de5 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -40,6 +40,19 @@ > #include "lua/utils.h" > #include "lua/msgpack.h" > > +/* > + * Make sure pMem->z points to a writable allocation of at least > + * min(n,32) bytes. > + * > + * If the bPreserve argument is true, then copy of the content of > + * pMem->z into the new allocation. pMem must be either a string or > + * blob if bPreserve is true. If bPreserve is false, any prior content > + * in pMem->z is discarded. > + */ > +static int > +sqlVdbeMemGrow(struct Mem *pMem, int n, int preserve); > + > + 1. Double empty line. > bool > mem_is_null(const struct Mem *mem) > { > @@ -477,6 +490,23 @@ mem_set_bin_allocated(struct Mem *mem, char *value, uint32_t size) > set_bin_dynamic(mem, value, size, 0); > } > > +int > +mem_copy_bin(struct Mem *mem, const char *value, uint32_t size) > +{ > + if ((mem->flags & (MEM_Agg | MEM_Frame)) != 0) > + mem_clear(mem); 2. The same comment as for copy_str. > + bool is_own_value = (mem->flags & (MEM_Str | MEM_Blob)) != 0 && > + mem->z == value; > + if (sqlVdbeMemGrow(mem, size, is_own_value) != 0) > + return -1; > + if (!is_own_value) > + memcpy(mem->z, value, size); > + mem->n = size; > + mem->flags = MEM_Blob; > + mem->field_type = FIELD_TYPE_VARBINARY; > + return 0; > +}