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 F1E616FC8F; Tue, 23 Mar 2021 12:50:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F1E616FC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616493049; bh=y17FA771pQkUsZ4Yh1W1tw+PYcrop2LA1lk5EbhfAoE=; 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=WABAG6nzlJtr/TE6kWdDqZoibW+QR883LloTplLhS44jXa0IKaI4CVqWmhAPamWmg HYwKDduMZziP+HQYGjaULyiHw9JHB4jdEmIbM2dIUCiy4DbFG1CjZFXRr5LDB2C18J AklTt6apBtDWaOqjNOgQ7ky26zsf5hxnZRC0kp0M= Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [94.100.177.90]) (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 43D9C68F55 for ; Tue, 23 Mar 2021 12:36:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 43D9C68F55 Received: by smtp30.i.mail.ru with esmtpa (envelope-from ) id 1lOdSG-00019l-I2; Tue, 23 Mar 2021 12:36:04 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Tue, 23 Mar 2021 12:36:04 +0300 Message-Id: <355efc84c597bfc6ce1fa13f9122f2670427b397.1616491731.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD95D6E7CC48CB1F5F111116110879554077ED795A4341E98F3182A05F538085040DC188BEC099D860F6D0F13F44FBA3BEF664C49811EA43B82E4F19DE49DDBD1D3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE779AAD18609327F83EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637051ADBC467AF48EA8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C686AF563A045C75ECB42E03A919D3FDDCD0E52DFBACF98DAA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE746CC513BB44FBA1D9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C309F854029C6BD0DA117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFE9B4B92903337A35BA3038C0950A5D36C8A9BA7A39EFB766EC990983EF5C0329BA3038C0950A5D36D5E8D9A59859A8B69E7299252A2A5EB676E601842F6C81A1F004C906525384307823802FF610243DF43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B3BBE47FD9DD3FB59A8DF7F3B2552694A57739F23D657EF2B13377AFFFEAFD26923F8577A6DFFEA7C2C2559B29ED8195093EC92FD9297F6715571747095F342E857739F23D657EF2BD5E8D9A59859A8B6D75B66E98413B381089D37D7C0E48F6C5571747095F342E857739F23D657EF2B6825BDBE14D8E7024847893F9AA87235E5BFE6E7EFDEDCD789D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24A6D60772A99906F8E1CD14B953EB46D99475722DBCA9A21355D89D7DBCDD132 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C686AF563A045C75ECB42E03A919D3FDDCD0E52DFBACF98DA9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340A59E724FC7897F72F98578D7E6C5285D92B8A43A00793CAB002CCAA1D4A547311C03801258DFAEF1D7E09C32AA3244C9A5EC89C4F6193A2E0328F41014E184097FE24653F78E668FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWJZv20R+6UjstERe9P404g== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306EDAD8205F36A347C026D0F13F44FBA3BEF41B07CD4FDF173FB5105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 32/53] sql: introduce mem_set_zerobinary() 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" This patch introduces mem_set_zerobinary() function. Function mem_set_zerobinary() clears MEM and sets it to binary value that consists of given number of zero bytes. Part of #5818 --- src/box/sql/mem.c | 29 +++++++++++++---------------- src/box/sql/mem.h | 5 +++-- src/box/sql/vdbeapi.c | 6 +++--- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index 99beec9ad..63a4d0d3c 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -479,6 +479,19 @@ mem_copy_binary(struct Mem *mem, const char *value, uint32_t size) return 0; } +void +mem_set_zerobinary(struct Mem *mem, int n) +{ + mem_destroy(mem); + if (n < 0) + n = 0; + mem->u.nZero = n; + mem->z = NULL; + mem->n = 0; + mem->flags = MEM_Blob | MEM_Zero; + mem->field_type = FIELD_TYPE_VARBINARY; +} + int mem_copy(struct Mem *to, const struct Mem *from) { @@ -2201,22 +2214,6 @@ sqlVdbeMemSetStr(Mem * pMem, /* Memory cell to set to string value */ return 0; } -/* - * Delete any previous value and set the value to be a BLOB of length - * n containing all zeros. - */ -void -sqlVdbeMemSetZeroBlob(Mem * pMem, int n) -{ - mem_destroy(pMem); - pMem->flags = MEM_Blob | MEM_Zero; - pMem->n = 0; - if (n < 0) - n = 0; - pMem->u.nZero = n; - pMem->z = 0; -} - /* * Free an sql_value object */ diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index f44bb9bcf..4b34bba6c 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -229,6 +229,9 @@ mem_set_dynamic_binary(struct Mem *mem, char *value, uint32_t size); void mem_set_allocated_binary(struct Mem *mem, char *value, uint32_t size); +void +mem_set_zerobinary(struct Mem *mem, int n); + int mem_copy_binary(struct Mem *mem, const char *value, uint32_t size); @@ -469,8 +472,6 @@ mem_set_ptr(struct Mem *mem, void *ptr); int sqlVdbeMemSetStr(struct Mem *, const char *, int, u8, void (*)(void *)); -void -sqlVdbeMemSetZeroBlob(struct Mem *, int); void sqlValueFree(struct Mem *); struct Mem *sqlValueNew(struct sql *); diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 299172554..d6d6e54f5 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -266,7 +266,7 @@ sql_result_value(sql_context * pCtx, sql_value * pValue) void sql_result_zeroblob(sql_context * pCtx, int n) { - sqlVdbeMemSetZeroBlob(pCtx->pOut, n); + mem_set_zerobinary(pCtx->pOut, n); } int @@ -278,7 +278,7 @@ sql_result_zeroblob64(sql_context * pCtx, u64 n) "is too big"); return -1; } - sqlVdbeMemSetZeroBlob(pCtx->pOut, (int)n); + mem_set_zerobinary(pCtx->pOut, (int)n); return 0; } @@ -956,7 +956,7 @@ sql_bind_zeroblob(sql_stmt * pStmt, int i, int n) Vdbe *p = (Vdbe *) pStmt; if (vdbeUnbind(p, i) != 0) return -1; - sqlVdbeMemSetZeroBlob(&p->aVar[i - 1], n); + mem_set_zerobinary(&p->aVar[i - 1], n); return 0; } -- 2.25.1