From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 197702DCD8 for ; Mon, 29 Apr 2019 13:26:21 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eyW_blXCpG7d for ; Mon, 29 Apr 2019 13:26:20 -0400 (EDT) Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [94.100.177.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 8BB1E2DCAE for ; Mon, 29 Apr 2019 13:26:20 -0400 (EDT) From: Stanislav Zudin Subject: [tarantool-patches] [PATCH 2/8] Removes unused functions and commented many years ago code. Date: Mon, 29 Apr 2019 20:26:05 +0300 Message-Id: <9b24ed8ad3f80fe66e765b69871ac10ea2b8715d.1556553117.git.szudin@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org, korablev@tarantool.org Cc: Stanislav Zudin Part of #3978 --- src/box/sql/expr.c | 62 --------------------------- src/box/sql/malloc.c | 100 ------------------------------------------- src/box/sql/random.c | 24 ----------- src/box/sql/sqlInt.h | 12 ------ src/box/sql/util.c | 14 ------ 5 files changed, 212 deletions(-) diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index 00992388c..ab6f9f068 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -3062,18 +3062,6 @@ sqlExprCodeIN(Parse * pParse, /* Parsing and code generating context */ assert(pParse->is_aborted || nVector == 1 || eType == IN_INDEX_EPH || eType == IN_INDEX_INDEX_ASC || eType == IN_INDEX_INDEX_DESC); -#ifdef SQL_DEBUG - /* Confirm that aiMap[] contains nVector integer values between 0 and - * nVector-1. - */ - /* - for(i=0; i from " IN (...)". If the LHS is a * vector, then it is stored in an array of nVector registers starting @@ -3088,17 +3076,6 @@ sqlExprCodeIN(Parse * pParse, /* Parsing and code generating context */ rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy); /* Tarantoool: Order is always preserved. */ rLhs = rLhsOrig; - /* for(i=0; idb; - pExpr = sqlExprDup(db, pExpr, 0); - if (!db->mallocFailed) - sqlExprCode(pParse, pExpr, target); - sql_expr_delete(db, pExpr, false); -} - /* * Generate code that will evaluate expression pExpr and store the * results in register target. The results are guaranteed to appear @@ -5623,27 +5585,3 @@ sqlClearTempRegCache(Parse * pParse) pParse->nRangeReg = 0; } -/* - * Validate that no temporary register falls within the range of - * iFirst..iLast, inclusive. This routine is only call from within assert() - * statements. - */ -#ifdef SQL_DEBUG -int -sqlNoTempsInRange(Parse * pParse, int iFirst, int iLast) -{ - int i; - if (pParse->nRangeReg > 0 - && pParse->iRangeReg + pParse->nRangeReg < iLast - && pParse->iRangeReg >= iFirst) { - return 0; - } - for (i = 0; i < pParse->nTempReg; i++) { - if (pParse->aTempReg[i] >= iFirst - && pParse->aTempReg[i] <= iLast) { - return 0; - } - } - return 1; -} -#endif /* SQL_DEBUG */ diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c index d6f99b46e..ef10d64ae 100644 --- a/src/box/sql/malloc.c +++ b/src/box/sql/malloc.c @@ -376,106 +376,6 @@ sql_malloc64(sql_uint64 n) return sqlMalloc(n); } -/* - * Each thread may only have a single outstanding allocation from - * xScratchMalloc(). We verify this constraint in the single-threaded - * case by setting scratchAllocOut to 1 when an allocation - * is outstanding clearing it when the allocation is freed. - */ -#if !defined(NDEBUG) -static int scratchAllocOut = 0; -#endif - -/* - * Allocate memory that is to be used and released right away. - * This routine is similar to alloca() in that it is not intended - * for situations where the memory might be held long-term. This - * routine is intended to get memory to old large transient data - * structures that would not normally fit on the stack of an - * embedded processor. - */ -void * -sqlScratchMalloc(int n) -{ - void *p; - assert(n > 0); - - sqlStatusHighwater(SQL_STATUS_SCRATCH_SIZE, n); - if (mem0.nScratchFree && sqlGlobalConfig.szScratch >= n) { - p = mem0.pScratchFree; - mem0.pScratchFree = mem0.pScratchFree->pNext; - mem0.nScratchFree--; - sqlStatusUp(SQL_STATUS_SCRATCH_USED, 1); - } else { - p = sqlMalloc(n); - if (sqlGlobalConfig.bMemstat && p) { - sqlStatusUp(SQL_STATUS_SCRATCH_OVERFLOW, - sqlMallocSize(p)); - } - sqlMemdebugSetType(p, MEMTYPE_SCRATCH); - } - -#if !defined(NDEBUG) - /* EVIDENCE-OF: R-12970-05880 sql will not use more than one scratch - * buffers per thread. - * - * This can only be checked in single-threaded mode. - */ - assert(scratchAllocOut == 0); - if (p) - scratchAllocOut++; -#endif - - return p; -} - -void -sqlScratchFree(void *p) -{ - if (p) { - -#if !defined(NDEBUG) - /* Verify that no more than two scratch allocation per thread - * is outstanding at one time. (This is only checked in the - * single-threaded case since checking in the multi-threaded case - * would be much more complicated.) - */ - assert(scratchAllocOut >= 1 && scratchAllocOut <= 2); - scratchAllocOut--; -#endif - - if (SQL_WITHIN - (p, sqlGlobalConfig.pScratch, mem0.pScratchEnd)) { - /* Release memory from the SQL_CONFIG_SCRATCH allocation */ - ScratchFreeslot *pSlot; - pSlot = (ScratchFreeslot *) p; - pSlot->pNext = mem0.pScratchFree; - mem0.pScratchFree = pSlot; - mem0.nScratchFree++; - assert(mem0.nScratchFree <= - (u32) sqlGlobalConfig.nScratch); - sqlStatusDown(SQL_STATUS_SCRATCH_USED, 1); - } else { - /* Release memory back to the heap */ - assert(sqlMemdebugHasType(p, MEMTYPE_SCRATCH)); - assert(sqlMemdebugNoType - (p, (u8) ~ MEMTYPE_SCRATCH)); - sqlMemdebugSetType(p, MEMTYPE_HEAP); - if (sqlGlobalConfig.bMemstat) { - int iSize = sqlMallocSize(p); - sqlStatusDown - (SQL_STATUS_SCRATCH_OVERFLOW, iSize); - sqlStatusDown(SQL_STATUS_MEMORY_USED, - iSize); - sqlStatusDown(SQL_STATUS_MALLOC_COUNT, - 1); - sql_sized_free(p); - } else - sql_sized_free(p); - } - } -} - /* * TRUE if p is a lookaside memory allocation from db */ diff --git a/src/box/sql/random.c b/src/box/sql/random.c index 618cb96d6..78dc27293 100644 --- a/src/box/sql/random.c +++ b/src/box/sql/random.c @@ -107,27 +107,3 @@ sql_randomness(int N, void *pBuf) *(zBuf++) = wsdPrng.s[t]; } while (--N); } - -/* - * For testing purposes, we sometimes want to preserve the state of - * PRNG and restore the PRNG to its saved state at a later time, or - * to reset the PRNG to its initial state. These routines accomplish - * those tasks. - */ -static SQL_WSD struct sqlPrngType sqlSavedPrng; -void -sqlPrngSaveState(void) -{ - memcpy(&GLOBAL(struct sqlPrngType, sqlSavedPrng), - &GLOBAL(struct sqlPrngType, sqlPrng), sizeof(sqlPrng) - ); -} - -void -sqlPrngRestoreState(void) -{ - memcpy(&GLOBAL(struct sqlPrngType, sqlPrng), - &GLOBAL(struct sqlPrngType, sqlSavedPrng), - sizeof(sqlPrng) - ); -} diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 1691d89ca..3f3658421 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -2978,11 +2978,6 @@ void *sqlDbRealloc(sql *, void *, u64); void sqlDbFree(sql *, void *); int sqlMallocSize(void *); int sqlDbMallocSize(sql *, void *); -void *sqlScratchMalloc(int); -void sqlScratchFree(void *); -void *sqlPageMalloc(int); -void sqlPageFree(void *); -void sqlMemSetDefault(void); void sqlBenignMallocHooks(void (*)(void), void (*)(void)); int sqlHeapNearlyFull(void); @@ -3111,9 +3106,6 @@ void sqlReleaseTempReg(Parse *, int); int sqlGetTempRange(Parse *, int); void sqlReleaseTempRange(Parse *, int, int); void sqlClearTempRegCache(Parse *); -#ifdef SQL_DEBUG -int sqlNoTempsInRange(Parse *, int, int); -#endif /** * Construct a new expression. Memory for this node and for the @@ -3577,7 +3569,6 @@ void sqlExprCacheRemove(Parse *, int, int); void sqlExprCacheClear(Parse *); void sql_expr_type_cache_change(Parse *, int, int); void sqlExprCode(Parse *, Expr *, int); -void sqlExprCodeCopy(Parse *, Expr *, int); void sqlExprCodeFactorable(Parse *, Expr *, int); void sqlExprCodeAtInit(Parse *, Expr *, int, u8); int sqlExprCodeTemp(Parse *, Expr *, int *); @@ -3622,8 +3613,6 @@ void sqlExprAnalyzeAggregates(NameContext *, Expr *); void sqlExprAnalyzeAggList(NameContext *, ExprList *); int sqlFunctionUsesThisSrc(Expr *, SrcList *); Vdbe *sqlGetVdbe(Parse *); -void sqlPrngSaveState(void); -void sqlPrngRestoreState(void); void sqlRollbackAll(Vdbe *); /** @@ -4423,7 +4412,6 @@ void sqlVdbeSetChanges(sql *, int); int sqlAddInt64(i64 *, i64); int sqlSubInt64(i64 *, i64); int sqlMulInt64(i64 *, i64); -int sqlAbsInt32(int); u8 sqlGetBoolean(const char *z, u8); const void *sqlValueText(sql_value *); diff --git a/src/box/sql/util.c b/src/box/sql/util.c index 4a93ddf09..687a0f30f 100644 --- a/src/box/sql/util.c +++ b/src/box/sql/util.c @@ -1257,20 +1257,6 @@ sqlMulInt64(i64 * pA, i64 iB) return 0; } -/* - * Compute the absolute value of a 32-bit signed integer, of possible. Or - * if the integer has a value of -2147483648, return +2147483647 - */ -int -sqlAbsInt32(int x) -{ - if (x >= 0) - return x; - if (x == (int)0x80000000) - return 0x7fffffff; - return -x; -} - /* * Find (an approximate) sum of two LogEst values. This computation is * not a simple "+" operator because LogEst is stored as a logarithmic -- 2.17.1