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 5878768F47; Tue, 23 Mar 2021 12:52:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5878768F47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616493169; bh=3i7cjjsNqbnTgRpablgqo8t3nxn9+4x15svpgK4CMxE=; 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=SiKAb1BM7hwa+QRU6tx+g/q9CaftLMf9qNWDADb1clL+XS3ocZgczGnMqOwdisrSm FPG9HjCd8Gm0jxwjdIqKINUJ6U/hIYPAL3M7PBsqkRcvK9cDu2zt7MZF7nmXuWxFKX kM4uCnbVMLosGuucKdefXNk4TNTvlXtoUg43zpog= Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 B2B3E68F59 for ; Tue, 23 Mar 2021 12:36:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B2B3E68F59 Received: by smtp60.i.mail.ru with esmtpa (envelope-from ) id 1lOdSN-0004WK-RO; Tue, 23 Mar 2021 12:36:12 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Tue, 23 Mar 2021 12:36:11 +0300 Message-Id: <51c8df44fb6a093d97d97a789b677e45596cc930.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: 4F1203BC0FB41BD95D6E7CC48CB1F5F1C82687294EF6886BAE1FA542CE3F1C38182A05F538085040169F8EDB508F048038D21E864299C4B1E4DA09646FD4EC61089605D3D3BD9FE3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE721B3E54BB37EA0B4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637911538129B0A8D078638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C686AF563A045C75E99EB910575DA82382BA896D5E6DBEF23A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE75A31C54DA8CF07A79FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3F035437B6AEB70F4117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF7F2E91924B32B594BA3038C0950A5D36C8A9BA7A39EFB766EC990983EF5C0329BA3038C0950A5D36D5E8D9A59859A8B6D331ECA594D2CE6B3AA81AA40904B5D9DBF02ECDB25306B2201CA6A4E26CD07C3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B091A620F70A64A45A99449624AB7ADAF3735872C767BF85DA29E625A9149C048EE0A3850AC1BE2E73557739F23D657EF2BC8A9BA7A39EFB7666BA297DBC24807EA089D37D7C0E48F6C8AA50765F7900637C3090DF2C0002BD1EFF80C71ABB335746BA297DBC24807EA27F269C8F02392CDC58410348177836E285124B2A10EEC6C00306258E7E6ABB4E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24A6D60772A99906F8E1CD14B953EB46D710D86FED6CCF6F3355D89D7DBCDD132 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C686AF563A045C75E99EB910575DA82382BA896D5E6DBEF239C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3472E5ECC12A9739C1AC281487CD3DE0BD572C97601406CD3B4C54706F3AD209ABDD61EE7476EAA49C1D7E09C32AA3244C75C644EC96336ACEDF5EE3CCF4E38C6164EE5813BBCA3A9DFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWJZv20R+6UjuFZtxWnIQOQ== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306ED57335D0A3228CA6638D21E864299C4B17958A49548C749F65105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 36/53] sql: introduce mem_set_pointer() 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_pointer() function. Function mem_set_pointer() sets a pointer to MEM. This pointer used for internal VDBE operations. Part of #5818 --- src/box/sql/mem.c | 17 +++++++++-------- src/box/sql/mem.h | 11 +++-------- src/box/sql/vdbe.c | 3 +-- src/box/sql/vdbeapi.c | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index fd2710478..3701741ef 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -595,6 +595,15 @@ mem_set_undefined(struct Mem *mem) mem->field_type = field_type_MAX; } +void +mem_set_pointer(struct Mem *mem, void *ptr) +{ + mem_clear(mem); + mem->flags = MEM_Ptr; + mem->u.p = ptr; + mem->field_type = field_type_MAX; +} + int mem_copy(struct Mem *to, const struct Mem *from) { @@ -2213,14 +2222,6 @@ sqlVdbeMemClearAndResize(Mem * pMem, int szNew) return 0; } -void -mem_set_ptr(struct Mem *mem, void *ptr) -{ - mem_destroy(mem); - mem->flags = MEM_Ptr; - mem->u.p = ptr; -} - /* * Free an sql_value object */ diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index 75486ba3a..9fec6ed8a 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -265,6 +265,9 @@ mem_set_allocated_array(struct Mem *mem, char *value, uint32_t size); void mem_set_undefined(struct Mem *mem); +void +mem_set_pointer(struct Mem *mem, void *ptr); + int mem_copy(struct Mem *to, const struct Mem *from); @@ -492,14 +495,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); -/** - * Set VDBE memory register with given pointer as a data. - * @param mem VDBE memory register to update. - * @param ptr Pointer to use. - */ -void -mem_set_ptr(struct Mem *mem, void *ptr); - void sqlValueFree(struct Mem *); struct Mem *sqlValueNew(struct sql *); diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index f899dfe7a..b9c2142e8 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -2394,8 +2394,7 @@ case OP_OpenTEphemeral: { if (space == NULL) goto abort_due_to_error; - aMem[pOp->p1].u.p = space; - aMem[pOp->p1].flags = MEM_Ptr; + mem_set_pointer(&aMem[pOp->p1], space); break; } diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index d6d6e54f5..3ad89b87c 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -930,7 +930,7 @@ sql_bind_ptr(struct sql_stmt *stmt, int i, void *ptr) int rc = vdbeUnbind(p, i); if (rc == 0) { rc = sql_bind_type(p, i, "varbinary"); - mem_set_ptr(&p->aVar[i - 1], ptr); + mem_set_pointer(&p->aVar[i - 1], ptr); } return rc; } -- 2.25.1