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 A49BD6EC5E; Fri, 9 Apr 2021 20:00:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A49BD6EC5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617987649; bh=77xG1tQPhRSPsxt98HSahaODPyImVr1lTP4U41VHCTo=; 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=jjAZaVN08dtzlaQ/KmVV6TB/ideyEwCrRA1jUw2FD3icIrac2c386rzWI5mhYdKnm 7MeU8dna06KDXPgMj4qG/vUQweaERdyUiZEoqCL8bDjmn419se2LFYrLm9uWaUAeqr d1JJTc9X8eSvLxDNzyZMaeWskafMx4umojzO4Mfc= 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 819AB6EC5E for ; Fri, 9 Apr 2021 19:59:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 819AB6EC5E Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lUuU3-0000PB-Ot; Fri, 09 Apr 2021 19:59:52 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Fri, 9 Apr 2021 19:59:51 +0300 Message-Id: <152edbab6445a2b77f06c2164310a00a335b6df4.1617984948.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: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480EBD5CA77A668ECB87DA2124B0A8E6609182A05F538085040DB76F66DB9471E39B8251B4CFEAAA93BD2F7257137FA225152CA2418CA97D64D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7DB7B102DCB413779EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637531CC3E3F637A59A8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B22044C7A3C13F21E0816DA1A60C9587D73C8827A907CBE77DD2E47CDBA5A96583C09775C1D3CA48CF17B107DEF921CE79117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE77FFCE1C639F4728C9FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA73A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735E4A630A5B664A4FFC4224003CC83647689D4C264860C145E X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CD0035DD76F8A8A4F60FD12B3D43EF8F19FEEFF31280392659C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EA882B598A209811A512C228436C9B35F1EBF5B12741D83871CD15891A7AB6AF7EA95ADF794DE3CC1D7E09C32AA3244CACFF5F2C998BAD17A61CACCD3628B948BBA718C7E6A9E042FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyO2lHpuZu4RHdCWbvK++Bw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638223B8E14374CBBBC542B0EF29DE9688A5483D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v5 08/52] sql: disable unused code in sql/vdbemem.c 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! > > I didn't even know we have vdbemem.c. It should be deleted someday > when we have mem.h/mem.c instead. > >> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h >> index dd8163f5e..b4293d961 100644 >> --- a/src/box/sql/sqlInt.h >> +++ b/src/box/sql/sqlInt.h >> @@ -4151,31 +4151,54 @@ sql_expr_new_column(struct sql *db, struct SrcList *src_list, int src_idx, >> >> int sqlExprCheckIN(Parse *, Expr *); >> >> -int sqlStat4ProbeSetValue(Parse *, struct index_def *, UnpackedRecord **, Expr *, int, >> - int, int *); >> -int sqlStat4ValueFromExpr(Parse *, Expr *, enum field_type type, >> - sql_value **); >> -void sqlStat4ProbeFree(UnpackedRecord *); >> +/* TODO: Enable this function when stat-tables will be revived. */ >> +static inline int >> +sqlStat4ProbeSetValue(struct Parse *parse, struct index_def *def, >> + struct UnpackedRecord **rec, struct Expr *expr, int n, >> + int i, int *out) > > You can also make it take '...' instead of all of these arguments individually. > The same for the other functions. > Thank you! Dixed. >> +{ >> + (void)parse; >> + (void)def; >> + (void)rec; >> + (void)expr; >> + (void)n; >> + (void)i; >> + (void)out; >> + unreachable(); >> + return 0; >> +} New patch: commit 152edbab6445a2b77f06c2164310a00a335b6df4 Author: Mergen Imeev Date: Thu Apr 1 15:09:15 2021 +0300 sql: disable unused code in sql/vdbemem.c This patch disables unused code in sql/vdbemem.c. It will simplify refactoring. Part of #5818 diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index dd8163f5e..e075224c6 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -4151,31 +4151,38 @@ sql_expr_new_column(struct sql *db, struct SrcList *src_list, int src_idx, int sqlExprCheckIN(Parse *, Expr *); -int sqlStat4ProbeSetValue(Parse *, struct index_def *, UnpackedRecord **, Expr *, int, - int, int *); -int sqlStat4ValueFromExpr(Parse *, Expr *, enum field_type type, - sql_value **); -void sqlStat4ProbeFree(UnpackedRecord *); +/* TODO: Enable this function when stat-tables will be revived. */ +static inline int +sqlStat4ProbeSetValue(struct Parse *parse, ...) +{ + (void)parse; + unreachable(); + return 0; +} -/** - * Extract the col_num-th column from the record. Write - * the column value into *res. If *res is initially NULL - * then a new sql_value object is allocated. - * - * If *res is initially NULL then the caller is responsible for - * ensuring that the value written into *res is eventually - * freed. - * - * @param db Database handle. - * @param record Pointer to buffer containing record. - * @param col_num Column to extract. - * @param[out] res Extracted value. - * - * @retval -1 on error or 0. - */ -int -sql_stat4_column(struct sql *db, const char *record, uint32_t col_num, - sql_value **res); +/* TODO: Enable this function when stat-tables will be revived. */ +static inline int +sqlStat4ValueFromExpr(struct Parse *parse, ...) +{ + (void)parse; + unreachable(); + return 0; +} + +/* TODO: Enable this function when stat-tables will be revived. */ +static inline void +sqlStat4ProbeFree(struct UnpackedRecord *rec) +{ + (void)rec; +} + +/* TODO: Enable this function when stat-tables will be revived. */ +static inline int +sql_stat4_column(struct sql *db, ...) +{ + (void)db; + return 0; +} /* * The interface to the LEMON-generated parser diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index a4a8c45f2..e269857ea 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -58,16 +58,30 @@ #include "box/sequence.h" #include "box/session_settings.h" +#ifdef SQL_DEBUG + /* - * Invoke this macro on memory cells just prior to changing the - * value of the cell. This macro verifies that shallow copies are - * not misused. A shallow copy of a string or blob just copies a - * pointer to the string or blob, not the content. If the original - * is changed while the copy is still in use, the string or blob might - * be changed out from under the copy. This macro verifies that nothing - * like that ever happens. + * This routine prepares a memory cell for modification by breaking + * its link to a shallow copy and by marking any current shallow + * copies of this cell as invalid. + * + * This is used for testing and debugging only - to make sure shallow + * copies are not misused. */ -#ifdef SQL_DEBUG +static void +sqlVdbeMemAboutToChange(Vdbe * pVdbe, Mem * pMem) +{ + int i; + Mem *pX; + for (i = 0, pX = pVdbe->aMem; i < pVdbe->nMem; i++, pX++) { + if (pX->pScopyFrom == pMem) { + pX->flags |= MEM_Undefined; + pX->pScopyFrom = 0; + } + } + pMem->pScopyFrom = 0; +} + # define memAboutToChange(P,M) sqlVdbeMemAboutToChange(P,M) #else # define memAboutToChange(P,M) diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 541b93d30..b48e45770 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -362,10 +362,6 @@ int sqlVdbeSorterRewind(const VdbeCursor *, int *); int sqlVdbeSorterWrite(const VdbeCursor *, Mem *); int sqlVdbeSorterCompare(const VdbeCursor *, Mem *, int, int *); -#ifdef SQL_DEBUG -void sqlVdbeMemAboutToChange(Vdbe *, Mem *); -#endif - int sqlVdbeCheckFk(Vdbe *, int); int sqlVdbeMemTranslate(Mem *, u8); diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index d977cbac8..263fe5b00 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -44,29 +44,8 @@ #include "box/tuple.h" #include "mpstream/mpstream.h" -#ifdef SQL_DEBUG -/* - * This routine prepares a memory cell for modification by breaking - * its link to a shallow copy and by marking any current shallow - * copies of this cell as invalid. - * - * This is used for testing and debugging only - to make sure shallow - * copies are not misused. - */ -void -sqlVdbeMemAboutToChange(Vdbe * pVdbe, Mem * pMem) -{ - int i; - Mem *pX; - for (i = 0, pX = pVdbe->aMem; i < pVdbe->nMem; i++, pX++) { - if (pX->pScopyFrom == pMem) { - pX->flags |= MEM_Undefined; - pX->pScopyFrom = 0; - } - } - pMem->pScopyFrom = 0; -} -#endif /* SQL_DEBUG */ +#if 0 + /* * Context object passed by sqlStat4ProbeSetValue() through to * valueNew(). See comments above valueNew() for details. @@ -546,6 +525,22 @@ sqlStat4ValueFromExpr(Parse * pParse, /* Parse context */ return stat4ValueFromExpr(pParse, pExpr, type, 0, ppVal); } +/** + * Extract the col_num-th column from the record. Write + * the column value into *res. If *res is initially NULL + * then a new sql_value object is allocated. + * + * If *res is initially NULL then the caller is responsible for + * ensuring that the value written into *res is eventually + * freed. + * + * @param db Database handle. + * @param record Pointer to buffer containing record. + * @param col_num Column to extract. + * @param[out] res Extracted value. + * + * @retval -1 on error or 0. + */ int sql_stat4_column(struct sql *db, const char *record, uint32_t col_num, sql_value **res) @@ -588,3 +583,5 @@ sqlStat4ProbeFree(UnpackedRecord * pRec) sqlDbFree(aMem[0].db, pRec); } } + +#endif