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 6004A6EC60; Fri, 9 Apr 2021 20:00:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6004A6EC60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617987619; bh=IdVyiYD66W7B4bpqY4/dY4il7bUd3BD2sp3KNKSQ7HU=; 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=nTCykHRqY+WLAsttBIXsrgI8Nv0HGtQYlF5njUoNdNEdcr8kME7eYcelzgs5sklhj 7RPdfA9uqfe/+Buy+sqXel/vSQrHiRTMsteW+2u1KIuLiAowJQfJ5EpXDCSkB7jcYU J2UuVBjnSu+LdNv6FObOjp0fLkZzu1jdpRPJtIOo= 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 902CF6EC60 for ; Fri, 9 Apr 2021 19:59:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 902CF6EC60 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lUuU1-0000Og-Pv; Fri, 09 Apr 2021 19:59:50 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Fri, 9 Apr 2021 19:59:49 +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: 4F1203BC0FB41BD92FFCB8E6708E7480BE79914FF86F9151AC38CC435EA4A654182A05F5380850400813E058A95B59C319B7D22DAFC4FD3F6EC4B74B55F3F483FC82B427C6F1A1D4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE771540F9ECFC94C4BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637CFA2FDEB3954FDBC8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B205FA913125501B5EE4192ADE3505526C8CCF7685675CC1A7D2E47CDBA5A96583C09775C1D3CA48CF27ED053E960B195E117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7E688A9D963DC14319FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA73A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735C6EABA9B74D0DA47B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C4C7A0BC55FA0FE5FC0D06ED59D0318C3526862B1F8960D42064270F9A8DA9F25CB1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB63AF70AF8205D7DCDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340E23B77EA180781722AB9DF399810424753545EC103472CD79908C9EE042FCB5ECF4A2607EF76E231D7E09C32AA3244C61B68AEBDD2054802F157689D23EC92260759606DA2E136AFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyO2lHpuZu4TMtBgbB7UpHg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382275552E8D87EE50A0773C804BA8083F4C83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v5 07/52] sql: remove unused MEM-related functions 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 answer and new patch below. On 30.03.2021 01:58, Vladislav Shpilevoy wrote: > Thanks for the patch! > > On 23.03.2021 10:35, Mergen Imeev via Tarantool-patches wrote: >> This patch removes remove unused MEM-related functions. > > You can simply omit commit message when it is the same as the > title. Fixed, removed the commit message. New patch: commit a3cd1dea89dae108586c1cf3cd0a3cbc9badfbc4 Author: Mergen Imeev Date: Tue Mar 2 10:58:15 2021 +0300 sql: remove unused MEM-related functions Part of #5818 diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index c1a42fc2f..dd8163f5e 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -474,10 +474,6 @@ sql_column_text(sql_stmt *, enum mp_type sql_column_type(sql_stmt *stmt, int field_no); -sql_value * -sql_column_value(sql_stmt *, - int iCol); - /* * Terminate the current execution of an SQL statement and reset * it back to its starting state so that it can be reused. diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 775bce96f..a4a8c45f2 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -181,14 +181,6 @@ vdbeTakeBranch(int iSrcLine, u8 I, u8 M) } #endif -/* - * Convert the given register into a string if it isn't one - * already. Return non-zero if a malloc() fails. - */ -#define Stringify(P) \ - if(((P)->flags&(MEM_Str|MEM_Blob))==0 && sqlVdbeMemStringify(P)) \ - { goto no_mem; } - /* * An ephemeral string value (signified by the MEM_Ephem flag) contains * a pointer to a dynamically allocated string where some other entity diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index b2d4f27c1..541b93d30 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -333,8 +333,6 @@ int sqlVdbeList(Vdbe *); int sqlVdbeHalt(Vdbe *); -int sqlVdbeMemFromBtree(BtCursor *, u32, u32, Mem *); - /** * In terms of VDBE memory cell type, _BIN, _ARRAY and _MAP * messagepacks are stored as binary string (i.e. featuring diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 24fa99f17..671338361 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -101,63 +101,12 @@ sql_stmt_reset(sql_stmt *pStmt) return rc; } -/* - * Set all the parameters in the compiled SQL statement to NULL. - */ -int -sql_clear_bindings(sql_stmt * pStmt) -{ - int i; - int rc = 0; - Vdbe *p = (Vdbe *) pStmt; - for (i = 0; i < p->nVar; i++) { - sqlVdbeMemRelease(&p->aVar[i]); - p->aVar[i].flags = MEM_Null; - } - return rc; -} - bool sql_metadata_is_full() { return current_session()->sql_flags & SQL_FullMetadata; } -/* Make a copy of an sql_value object - */ -sql_value * -sql_value_dup(const sql_value * pOrig) -{ - sql_value *pNew; - if (pOrig == 0) - return 0; - pNew = sql_malloc(sizeof(*pNew)); - if (pNew == 0) - return 0; - memset(pNew, 0, sizeof(*pNew)); - memcpy(pNew, pOrig, MEMCELLSIZE); - pNew->flags &= ~MEM_Dyn; - pNew->db = 0; - if (pNew->flags & (MEM_Str | MEM_Blob)) { - pNew->flags &= ~(MEM_Static | MEM_Dyn); - pNew->flags |= MEM_Ephem; - if (sqlVdbeMemMakeWriteable(pNew) != 0) { - sqlValueFree(pNew); - pNew = 0; - } - } - return pNew; -} - -/* Destroy an sql_value object previously obtained from - * sql_value_dup(). - */ -void -sql_value_free(sql_value * pOld) -{ - sqlValueFree(pOld); -} - /**************************** sql_result_ ****************************** * The following routines are used by user-defined functions to specify * the function result. @@ -566,17 +515,6 @@ sql_column_text(sql_stmt * pStmt, int i) return sql_value_text(columnMem(pStmt, i)); } -sql_value * -sql_column_value(sql_stmt * pStmt, int i) -{ - Mem *pOut = columnMem(pStmt, i); - if (pOut->flags & MEM_Static) { - pOut->flags &= ~MEM_Static; - pOut->flags |= MEM_Ephem; - } - return (sql_value *) pOut; -} - enum mp_type sql_column_type(sql_stmt * pStmt, int i) { diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index 092350caa..d977cbac8 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -67,71 +67,6 @@ sqlVdbeMemAboutToChange(Vdbe * pVdbe, Mem * pMem) pMem->pScopyFrom = 0; } #endif /* SQL_DEBUG */ -/* - * Move data out of a btree key or data field and into a Mem structure. - * The data is payload from the entry that pCur is currently pointing - * to. offset and amt determine what portion of the data or key to retrieve. - * The result is written into the pMem element. - * - * The pMem object must have been initialized. This routine will use - * pMem->zMalloc to hold the content from the btree, if possible. New - * pMem->zMalloc space will be allocated if necessary. The calling routine - * is responsible for making sure that the pMem object is eventually - * destroyed. - * - * If this routine fails for any reason (malloc returns NULL or unable - * to read from the disk) then the pMem is left in an inconsistent state. - */ -static SQL_NOINLINE int -vdbeMemFromBtreeResize(BtCursor * pCur, /* Cursor pointing at record to retrieve. */ - u32 offset, /* Offset from the start of data to return bytes from. */ - u32 amt, /* Number of bytes to return. */ - Mem * pMem /* OUT: Return data in this Mem structure. */ - ) -{ - int rc; - pMem->flags = MEM_Null; - if (0 == (rc = sqlVdbeMemClearAndResize(pMem, amt + 2))) { - sqlCursorPayload(pCur, offset, amt, pMem->z); - pMem->z[amt] = 0; - pMem->z[amt + 1] = 0; - pMem->flags = MEM_Blob | MEM_Term; - pMem->n = (int) amt; - } - return rc; -} - -int -sqlVdbeMemFromBtree(BtCursor * pCur, /* Cursor pointing at record to retrieve. */ - u32 offset, /* Offset from the start of data to return bytes from. */ - u32 amt, /* Number of bytes to return. */ - Mem * pMem /* OUT: Return data in this Mem structure. */ - ) -{ - char *zData; /* Data from the btree layer */ - u32 available = 0; /* Number of bytes available on the local btree page */ - int rc = 0; /* Return code */ - - assert(sqlCursorIsValid(pCur)); - assert(!VdbeMemDynamic(pMem)); - assert(pCur->curFlags & BTCF_TaCursor || - pCur->curFlags & BTCF_TEphemCursor); - - - zData = (char *)tarantoolsqlPayloadFetch(pCur, &available); - assert(zData != 0); - - if (offset + amt <= available) { - pMem->z = &zData[offset]; - pMem->flags = MEM_Blob | MEM_Ephem; - pMem->n = (int)amt; - } else { - rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem); - } - - return rc; -} - /* * Context object passed by sqlStat4ProbeSetValue() through to * valueNew(). See comments above valueNew() for details.