From: Stanislav Zudin <szudin@tarantool.org>
To: tarantool-patches@freelists.org, korablev@tarantool.org
Cc: Stanislav Zudin <szudin@tarantool.org>
Subject: [tarantool-patches] [PATCH 2/8] Removes unused functions and commented many years ago code.
Date: Mon, 29 Apr 2019 20:26:05 +0300 [thread overview]
Message-ID: <9b24ed8ad3f80fe66e765b69871ac10ea2b8715d.1556553117.git.szudin@tarantool.org> (raw)
In-Reply-To: <cover.1556553117.git.szudin@tarantool.org>
In-Reply-To: <cover.1556553117.git.szudin@tarantool.org>
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<nVector; i++){
- int j, cnt;
- for(cnt=j=0; j<nVector; j++) if( aiMap[j]==i ) cnt++;
- assert( cnt==1 );
- }
- */
-#endif
/* Code the LHS, the <expr> from "<expr> 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; i<nVector && aiMap[i]==i; i++){} /\* Are LHS fields reordered? *\/ */
- /* if( i==nVector ){ */
- /* /\* LHS fields are not reordered *\/ */
- /* rLhs = rLhsOrig; */
- /* }else{ */
- /* /\* Need to reorder the LHS fields according to aiMap *\/ */
- /* rLhs = sqlGetTempRange(pParse, nVector); */
- /* for(i=0; i<nVector; i++){ */
- /* sqlVdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0); */
- /* } */
- /* } */
/* If sqlFindInIndex() did not find or create an index that is
* suitable for evaluating the IN operator, then evaluate using a
@@ -4495,21 +4472,6 @@ sqlExprCode(Parse * pParse, Expr * pExpr, int target)
}
}
-/*
- * Make a transient copy of expression pExpr and then code it using
- * sqlExprCode(). This routine works just like sqlExprCode()
- * except that the input expression is guaranteed to be unchanged.
- */
-void
-sqlExprCodeCopy(Parse * pParse, Expr * pExpr, int target)
-{
- sql *db = pParse->db;
- 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
next prev parent reply other threads:[~2019-04-29 17:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 1/8] " Stanislav Zudin
2019-04-29 17:26 ` Stanislav Zudin [this message]
2019-05-19 15:15 ` [tarantool-patches] Re: [PATCH 2/8] Removes unused functions and commented many years ago code n.pettik
2019-05-29 8:21 ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 3/8] Removes unused functions Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 4/8] Removes unused functions and macros Stanislav Zudin
2019-05-19 15:16 ` [tarantool-patches] " n.pettik
2019-05-29 14:01 ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 5/8] Removes the following unused macros: SQL_ENABLE_MEMORY_MANAGEMENT SQL_ENABLE_UNKNOWN_SQL_FUNCTION SQL_SUBSTR_COMPATIBILITY SQL_ENABLE_STMT_SCANSTATUS Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 6/8] Removes the following unused macros: SQL_EXPLAIN_ESTIMATED_ROWS SQL_ENABLE_COLUMN_USED_MASK SQL_DISABLE_DIRSYNC SQL_OMIT_AUTOMATIC_INDEX SQL_DEBUG_SORTER_THREADS SQL_DEFAULT_WORKER_THREADS SQL_LIMIT_WORKER_THREADS SQL_MAX_WORKER_THREADS Stanislav Zudin
2019-05-19 15:16 ` [tarantool-patches] " n.pettik
2019-05-29 14:02 ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 7/8] Removes unused constants Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 8/8] Removes the following unused macros: SQL_PRINTF_PRECISION_LIMIT SQL_OMIT_COMPOUND_SELECT SQL_POWERSAFE_OVERWRITE SQL_OMIT_PROGRESS_CALLBACK SQL_OMIT_AUTORESET SQL_OMIT_DECLTYPE SQL_ENABLE_COLUMN_METADATA SQL_TRACE_SIZE_LIMIT SQL_OMIT_LIKE_OPTIMIZATION SQL_OMIT_OR_OPTIMIZATION SQL_OMIT_BETWEEN_OPTIMIZATION Stanislav Zudin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b24ed8ad3f80fe66e765b69871ac10ea2b8715d.1556553117.git.szudin@tarantool.org \
--to=szudin@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH 2/8] Removes unused functions and commented many years ago code.' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox