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 82DE230BDB for ; Thu, 13 Jun 2019 18:24:48 -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 aWEYS9i312ZW for ; Thu, 13 Jun 2019 18:24:48 -0400 (EDT) Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 18A9A308B2 for ; Thu, 13 Jun 2019 18:24:48 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 06/28] sql: disable lookaside system References: <4ffbe58748e040ea77209cd882df5896571bcae9.1560174553.git.imeevma@gmail.com> From: Vladislav Shpilevoy Message-ID: Date: Fri, 14 Jun 2019 00:25:04 +0200 MIME-Version: 1.0 In-Reply-To: <4ffbe58748e040ea77209cd882df5896571bcae9.1560174553.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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, imeevma@tarantool.org Thanks for the patch! You removed it, not disabled. You have removed its core part, but left a pile of surroundings. Consider my review fixes below and on the branch in a separate commit. ====================================================== diff --git a/src/box/sql/global.c b/src/box/sql/global.c index e394db8d0..0bbd8c2fd 100644 --- a/src/box/sql/global.c +++ b/src/box/sql/global.c @@ -177,8 +177,6 @@ SQL_WSD struct sqlConfig sqlConfig = { SQL_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */ 0x7ffffffe, /* mxStrlen */ 0, /* neverCorrupt */ - 512, /* szLookaside */ - 125, /* nLookaside */ 0, /* nStmtSpill */ (void *)0, /* pHeap */ 0, /* nHeap */ diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c index a7549db48..3ccb36e5e 100644 --- a/src/box/sql/malloc.c +++ b/src/box/sql/malloc.c @@ -481,13 +481,6 @@ sqlMallocSize(void *p) return sql_sized_sizeof(p); } -int -sqlDbMallocSize(void *p) -{ - assert(p != 0); - return sql_sized_sizeof(p); -} - sql_uint64 sql_msize(void *p) { @@ -518,7 +511,7 @@ sql_free(void *p) static SQL_NOINLINE void measureAllocationSize(sql * db, void *p) { - *db->pnBytesFreed += sqlDbMallocSize(p); + *db->pnBytesFreed += sqlMallocSize(p); } /* @@ -632,24 +625,9 @@ sqlDbMallocZero(sql * db, u64 n) return p; } -/* Finish the work of sqlDbMallocRawNN for the unusual and - * slower case when the allocation cannot be fulfilled using lookaside. - */ -static SQL_NOINLINE void * -dbMallocRawFinish(sql * db, u64 n) -{ - void *p; - assert(db != 0); - p = sqlMalloc(n); - if (!p) - sqlOomFault(db); - return p; -} - /* - * Allocate memory, either lookaside (if possible) or heap. - * If the allocation fails, set the mallocFailed flag in - * the connection pointer. + * Allocate heap memory. If the allocation fails, set the + * mallocFailed flag in the connection pointer. * * If db!=0 and db->mallocFailed is true (indicating a prior malloc * failure on the same database connection) then always return 0. @@ -684,7 +662,10 @@ sqlDbMallocRawNN(sql * db, u64 n) assert(db != NULL && db->pnBytesFreed == NULL); if (db->mallocFailed) return NULL; - return dbMallocRawFinish(db, n); + void *p = sqlMalloc(n); + if (p == NULL) + sqlOomFault(db); + return p; } /* Forward declaration */ @@ -784,17 +765,13 @@ sqlSetString(char **pz, sql * db, const char *zNew) /* * Call this routine to record the fact that an OOM (out-of-memory) error - * has happened. This routine will set db->mallocFailed, and also - * temporarily disable the lookaside memory allocator and interrupt - * any running VDBEs. + * has happened. This routine will set db->mallocFailed. */ void sqlOomFault(sql * db) { - if (db->mallocFailed == 0 && db->bBenignMalloc == 0) { + if (db->mallocFailed == 0 && db->bBenignMalloc == 0) db->mallocFailed = 1; - db->lookaside.bDisable++; - } } /* @@ -807,11 +784,8 @@ sqlOomFault(sql * db) void sqlOomClear(sql * db) { - if (db->mallocFailed && db->nVdbeExec == 0) { + if (db->mallocFailed && db->nVdbeExec == 0) db->mallocFailed = 0; - assert(db->lookaside.bDisable > 0); - db->lookaside.bDisable--; - } } /* diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index bc577a580..3ccb4f8ea 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -106,15 +106,6 @@ struct LimitVal { */ struct TrigEvent { int a; IdList * b; }; -/* -** Disable lookaside memory allocation for objects that might be -** shared across database connections. -*/ -static void disableLookaside(Parse *pParse){ - pParse->disableLookaside++; - pParse->db->lookaside.bDisable++; -} - } // end %include // Input is a single SQL command @@ -178,11 +169,10 @@ cmd ::= ROLLBACK TO savepoint_opt nm(X). { ///////////////////// The CREATE TABLE statement //////////////////////////// // cmd ::= create_table create_table_args. -create_table ::= createkw TABLE ifnotexists(E) nm(Y). { +create_table ::= CREATE TABLE ifnotexists(E) nm(Y). { create_table_def_init(&pParse->create_table_def, &Y, E); pParse->create_table_def.new_space = sqlStartTable(pParse, &Y); } -createkw(A) ::= CREATE(A). {disableLookaside(pParse);} %type ifnotexists {int} ifnotexists(A) ::= . {A = 0;} @@ -408,7 +398,7 @@ ifexists(A) ::= . {A = 0;} ///////////////////// The CREATE VIEW statement ///////////////////////////// // -cmd ::= createkw(X) VIEW ifnotexists(E) nm(Y) eidlist_opt(C) +cmd ::= CREATE(X) VIEW ifnotexists(E) nm(Y) eidlist_opt(C) AS select(S). { if (!pParse->parse_only) { create_view_def_init(&pParse->create_view_def, &Y, &X, C, S, E); @@ -1409,7 +1399,7 @@ paren_exprlist(A) ::= LP exprlist(X) RP. {A = X;} ///////////////////////////// The CREATE INDEX command /////////////////////// // -cmd ::= createkw uniqueflag(U) INDEX ifnotexists(NE) nm(X) +cmd ::= CREATE uniqueflag(U) INDEX ifnotexists(NE) nm(X) ON nm(Y) LP sortlist(Z) RP. { struct SrcList *src_list = sql_src_list_append(pParse->db,0,&Y); if (src_list == NULL) { @@ -1512,7 +1502,7 @@ plus_num(A) ::= number(A). minus_num(A) ::= MINUS number(X). {A = X;} //////////////////////////// The CREATE TRIGGER command ///////////////////// -cmd ::= createkw trigger_decl(A) BEGIN trigger_cmd_list(S) END(Z). { +cmd ::= CREATE trigger_decl(A) BEGIN trigger_cmd_list(S) END(Z). { Token all; all.z = A.z; all.n = (int)(Z.z - A.z) + Z.n; diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c index 2b3ac29ae..4ac8698ec 100644 --- a/src/box/sql/prepare.c +++ b/src/box/sql/prepare.c @@ -295,12 +295,6 @@ sql_parser_destroy(Parse *parser) sqlDbFree(db, parser->aLabel); sql_expr_list_delete(db, parser->pConstExpr); create_table_def_destroy(&parser->create_table_def); - if (db != NULL) { - assert(db->lookaside.bDisable >= - parser->disableLookaside); - db->lookaside.bDisable -= parser->disableLookaside; - } - parser->disableLookaside = 0; switch (parser->parsed_ast_type) { case AST_TYPE_SELECT: sql_select_delete(db, parser->parsed_ast.select); diff --git a/src/box/sql/printf.c b/src/box/sql/printf.c index c364055c1..add0be474 100644 --- a/src/box/sql/printf.c +++ b/src/box/sql/printf.c @@ -874,7 +874,7 @@ sqlStrAccumEnlarge(StrAccum * p, int N) if (!isMalloced(p) && p->nChar > 0) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; - p->nAlloc = sqlDbMallocSize(zNew); + p->nAlloc = sqlMallocSize(zNew); p->printfFlags |= SQL_PRINTF_MALLOCED; } else { sqlStrAccumReset(p); @@ -999,9 +999,8 @@ sqlStrAccumReset(StrAccum * p) * Initialize a string accumulator. * * p: The accumulator to be initialized. - * db: Pointer to a database connection. May be NULL. Lookaside - * memory is used if not NULL. db->mallocFailed is set appropriately - * when not NULL. + * db: Pointer to a database connection. May be NULL. + * db->mallocFailed is set appropriately when not NULL. * zBase: An initial buffer. May be NULL in which case the initial buffer * is malloced. * n: Size of zBase in bytes. If total space requirements never exceed diff --git a/src/box/sql/select.c b/src/box/sql/select.c index b6752930b..d58ae8573 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -2003,10 +2003,6 @@ sqlResultSetOfSelect(Parse * pParse, Select * pSelect) struct space *space = sql_ephemeral_space_new(pParse, NULL); if (space == NULL) return NULL; - /* The sqlResultSetOfSelect() is only used in contexts where lookaside - * is disabled - */ - assert(db->lookaside.bDisable); sqlColumnsFromExprList(pParse, pSelect->pEList, space->def); sqlSelectAddColumnTypeAndCollation(pParse, space->def, pSelect); if (db->mallocFailed) diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 544b61aa8..54e9ae931 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -186,16 +186,13 @@ #endif #if defined(SQL_SYSTEM_MALLOC) \ - + defined(SQL_ZERO_MALLOC) \ - + defined(SQL_MEMDEBUG)>1 + + defined(SQL_ZERO_MALLOC) > 1 #error "Two or more of the following compile-time configuration options\ are defined but at most one is allowed:\ - SQL_SYSTEM_MALLOC, SQL_MEMDEBUG,\ - SQL_ZERO_MALLOC" + SQL_SYSTEM_MALLOC, SQL_ZERO_MALLOC" #endif #if defined(SQL_SYSTEM_MALLOC) \ - + defined(SQL_ZERO_MALLOC) \ - + defined(SQL_MEMDEBUG)==0 + + defined(SQL_ZERO_MALLOC) == 0 #define SQL_SYSTEM_MALLOC 1 #endif @@ -683,7 +680,6 @@ sql_os_end(void); #define SQL_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQL_CONFIG_MEMSTATUS 9 /* boolean */ -#define SQL_CONFIG_LOOKASIDE 13 /* int int */ #define SQL_CONFIG_LOG 16 /* xFunc, void* */ #define SQL_CONFIG_URI 17 /* int */ #define SQL_CONFIG_COVERING_INDEX_SCAN 20 /* int */ @@ -692,7 +688,6 @@ sql_os_end(void); #define SQL_CONFIG_PMASZ 24 /* unsigned int szPma */ #define SQL_CONFIG_STMTJRNL_SPILL 25 /* int nByte */ -#define SQL_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQL_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQL_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ #define SQL_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ @@ -841,20 +836,6 @@ sql_uri_parameter(const char *zFilename, #define SQL_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ #define SQL_ACCESS_READ 2 /* Unused */ -#define SQL_DBSTATUS_LOOKASIDE_USED 0 -#define SQL_DBSTATUS_CACHE_USED 1 -#define SQL_DBSTATUS_SCHEMA_USED 2 -#define SQL_DBSTATUS_STMT_USED 3 -#define SQL_DBSTATUS_LOOKASIDE_HIT 4 -#define SQL_DBSTATUS_LOOKASIDE_MISS_SIZE 5 -#define SQL_DBSTATUS_LOOKASIDE_MISS_FULL 6 -#define SQL_DBSTATUS_CACHE_HIT 7 -#define SQL_DBSTATUS_CACHE_MISS 8 -#define SQL_DBSTATUS_CACHE_WRITE 9 -#define SQL_DBSTATUS_DEFERRED_FKS 10 -#define SQL_DBSTATUS_CACHE_USED_SHARED 11 -#define SQL_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */ - const char * sql_sql(sql_stmt * pStmt); @@ -1334,8 +1315,6 @@ typedef struct FuncDef FuncDef; typedef struct FuncDefHash FuncDefHash; typedef struct IdList IdList; typedef struct KeyClass KeyClass; -typedef struct Lookaside Lookaside; -typedef struct LookasideSlot LookasideSlot; typedef struct NameContext NameContext; typedef struct Parse Parse; typedef struct PrintfArguments PrintfArguments; @@ -1378,41 +1357,6 @@ typedef int VList; */ #define SQL_N_LIMIT (SQL_LIMIT_WORKER_THREADS+1) -/* - * Lookaside malloc is a set of fixed-size buffers that can be used - * to satisfy small transient memory allocation requests for objects - * associated with a particular database connection. The use of - * lookaside malloc provides a significant performance enhancement - * (approx 10%) by avoiding numerous malloc/free requests while parsing - * SQL statements. - * - * The Lookaside structure holds configuration information about the - * lookaside malloc subsystem. Each available memory allocation in - * the lookaside subsystem is stored on a linked list of LookasideSlot - * objects. - * - * Lookaside allocations are only allowed for objects that are associated - * with a particular database connection. Hence, schema information cannot - * be stored in lookaside because in shared cache mode the schema information - * is shared by multiple database connections. Therefore, while parsing - * schema information, the Lookaside.bEnabled flag is cleared so that - * lookaside allocations are not used to construct the schema objects. - */ -struct Lookaside { - u32 bDisable; /* Only operate the lookaside when zero */ - u16 sz; /* Size of each buffer in bytes */ - u8 bMalloced; /* True if pStart obtained from sql_malloc() */ - int nOut; /* Number of buffers currently checked out */ - int mxOut; /* Highwater mark for nOut */ - int anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ - LookasideSlot *pFree; /* List of available buffers */ - void *pStart; /* First byte of available memory space */ - void *pEnd; /* First byte past end of available space */ -}; -struct LookasideSlot { - LookasideSlot *pNext; /* Next buffer in the list of free buffers */ -}; - /* * A hash table for built-in function definitions. (Application-defined * functions use a regular table table from hash.h.) @@ -1466,7 +1410,6 @@ struct sql { void *pUpdateArg; void (*xUpdateCallback) (void *, int, const char *, const char *, sql_int64); - Lookaside lookaside; /* Lookaside malloc configuration */ Hash aFunc; /* Hash table of connection functions */ int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ }; @@ -2572,7 +2515,6 @@ struct Parse { u8 isMultiWrite; /* True if statement may modify/insert multiple rows */ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ u8 okConstFactor; /* OK to factor out constants */ - u8 disableLookaside; /* Number of times lookaside has been disabled */ u8 nColCache; /* Number of entries in aColCache[] */ int nRangeReg; /* Size of the temporary register block */ int iRangeReg; /* First register in temporary register block */ @@ -2847,7 +2789,7 @@ struct TriggerStep { * do not necessarily know how big the string will be in the end. */ struct StrAccum { - sql *db; /* Optional database for lookaside. Can be NULL */ + sql *db; /* Database for temporary buffers. */ char *zBase; /* A base allocation. Not from malloc. */ char *zText; /* The string collected so far */ u32 nChar; /* Length of the string so far */ @@ -2875,8 +2817,6 @@ struct sqlConfig { int bUseCis; /* Use covering indices for full-scans */ int mxStrlen; /* Maximum string length */ int neverCorrupt; /* Database is always well-formed */ - int szLookaside; /* Default lookaside buffer size */ - int nLookaside; /* Default lookaside buffer count */ int nStmtSpill; /* Stmt-journal spill-to-disk threshold */ void *pHeap; /* Heap storage space */ int nHeap; /* Size of pHeap[] */ @@ -3020,7 +2960,6 @@ void *sqlDbReallocOrFree(sql *, void *, u64); void *sqlDbRealloc(sql *, void *, u64); void sqlDbFree(sql *, void *); int sqlMallocSize(void *); -int sqlDbMallocSize(void *); void *sqlScratchMalloc(int); void sqlScratchFree(void *); void *sqlPageMalloc(int); diff --git a/src/box/sql/status.c b/src/box/sql/status.c index bc170c8e5..950d5f409 100644 --- a/src/box/sql/status.c +++ b/src/box/sql/status.c @@ -158,140 +158,3 @@ sql_status(int op, int *pCurrent, int *pHighwater, int resetFlag) } return rc; } - -/* - * Query status information for a single database connection - */ -int -sql_db_status(sql * db, /* The database connection whose status is desired */ - int op, /* Status verb */ - int *pCurrent, /* Write current value here */ - int *pHighwater, /* Write high-water mark here */ - int resetFlag /* Reset high-water mark if true */ - ) -{ - int rc = SQL_OK; /* Return code */ - switch (op) { - case SQL_DBSTATUS_LOOKASIDE_USED:{ - *pCurrent = db->lookaside.nOut; - *pHighwater = db->lookaside.mxOut; - if (resetFlag) { - db->lookaside.mxOut = db->lookaside.nOut; - } - break; - } - - case SQL_DBSTATUS_LOOKASIDE_HIT: - case SQL_DBSTATUS_LOOKASIDE_MISS_SIZE: - case SQL_DBSTATUS_LOOKASIDE_MISS_FULL:{ - testcase(op == SQL_DBSTATUS_LOOKASIDE_HIT); - testcase(op == SQL_DBSTATUS_LOOKASIDE_MISS_SIZE); - testcase(op == SQL_DBSTATUS_LOOKASIDE_MISS_FULL); - assert((op - SQL_DBSTATUS_LOOKASIDE_HIT) >= 0); - assert((op - SQL_DBSTATUS_LOOKASIDE_HIT) < 3); - *pCurrent = 0; - *pHighwater = - db->lookaside.anStat[op - - SQL_DBSTATUS_LOOKASIDE_HIT]; - if (resetFlag) { - db->lookaside.anStat[op - - SQL_DBSTATUS_LOOKASIDE_HIT] - = 0; - } - break; - } - - /* - * Return an approximation for the amount of memory currently used - * by all pagers associated with the given database connection. The - * highwater mark is meaningless and is returned as zero. - */ - case SQL_DBSTATUS_CACHE_USED_SHARED: - case SQL_DBSTATUS_CACHE_USED:{ - int totalUsed = 0; - *pCurrent = totalUsed; - *pHighwater = 0; - break; - } - - /* - * *pCurrent gets an accurate estimate of the amount of memory used - * to store the schema for database. *pHighwater is set to zero. - */ - case SQL_DBSTATUS_SCHEMA_USED:{ - int nByte = 0; /* Used to accumulate return value */ - - *pHighwater = 0; - *pCurrent = nByte; - break; - } - - /* - * *pCurrent gets an accurate estimate of the amount of memory used - * to store all prepared statements. - * *pHighwater is set to zero. - */ - case SQL_DBSTATUS_STMT_USED:{ - struct Vdbe *pVdbe; /* Used to iterate through VMs */ - int nByte = 0; /* Used to accumulate return value */ - - db->pnBytesFreed = &nByte; - for (pVdbe = db->pVdbe; pVdbe; pVdbe = pVdbe->pNext) { - sqlVdbeClearObject(db, pVdbe); - sqlDbFree(db, pVdbe); - } - db->pnBytesFreed = 0; - - *pHighwater = 0; /* IMP: R-64479-57858 - */ - *pCurrent = nByte; - - break; - } - - /* - * Set *pCurrent to the total cache hits or misses encountered by all - * pagers the database handle is connected to. *pHighwater is always set - * to zero. - */ - case SQL_DBSTATUS_CACHE_HIT: - case SQL_DBSTATUS_CACHE_MISS: - case SQL_DBSTATUS_CACHE_WRITE:{ - int nRet = 0; - assert(SQL_DBSTATUS_CACHE_MISS == - SQL_DBSTATUS_CACHE_HIT + 1); - assert(SQL_DBSTATUS_CACHE_WRITE == - SQL_DBSTATUS_CACHE_HIT + 2); - - *pHighwater = 0; /* IMP: R-42420-56072 - */ - /* IMP: R-54100-20147 */ - /* IMP: R-29431-39229 */ - *pCurrent = nRet; - break; - } - - /* Set *pCurrent to non-zero if there are unresolved deferred foreign - * key constraints. Set *pCurrent to zero if all foreign key constraints - * have been satisfied. The *pHighwater is always set to zero. - */ - case SQL_DBSTATUS_DEFERRED_FKS:{ - *pHighwater = 0; /* IMP: R-11967-56545 - */ - const struct txn *ptxn = in_txn(); - - if (!ptxn || !ptxn->psql_txn) { - *pCurrent = 0; - break; - } - const struct sql_txn *psql_txn = ptxn->psql_txn; - *pCurrent = psql_txn->fk_deferred_count > 0; - break; - } - - default:{ - rc = SQL_ERROR; - } - } - return rc; -} diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index fbe5338f9..44a3812f0 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -192,7 +192,7 @@ growOpArray(Vdbe * v, int nOp) assert(nNew >= (p->nOpAlloc + nOp)); pNew = sqlDbRealloc(p->db, v->aOp, nNew * sizeof(Op)); if (pNew) { - p->szOpAlloc = sqlDbMallocSize(pNew); + p->szOpAlloc = sqlMallocSize(pNew); p->nOpAlloc = p->szOpAlloc / sizeof(Op); v->aOp = pNew; } diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index 2bb9bd3e4..366933695 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -70,7 +70,7 @@ sqlVdbeCheckMemInvariants(Mem * p) /* The szMalloc field holds the correct memory allocation size */ assert(p->szMalloc == 0 - || p->szMalloc == sqlDbMallocSize(p->zMalloc)); + || p->szMalloc == sqlMallocSize(p->zMalloc)); /* If p holds a string or blob, the Mem.z must point to exactly * one of the following: @@ -112,7 +112,7 @@ sqlVdbeMemGrow(Mem * pMem, int n, int bPreserve) testcase(bPreserve && pMem->z == 0); assert(pMem->szMalloc == 0 - || pMem->szMalloc == sqlDbMallocSize(pMem->zMalloc)); + || pMem->szMalloc == sqlMallocSize(pMem->zMalloc)); if (pMem->szMalloc < n) { if (n < 32) n = 32; @@ -131,8 +131,7 @@ sqlVdbeMemGrow(Mem * pMem, int n, int bPreserve) pMem->szMalloc = 0; return SQL_NOMEM; } else { - pMem->szMalloc = - sqlDbMallocSize(pMem->zMalloc); + pMem->szMalloc = sqlMallocSize(pMem->zMalloc); } } @@ -1006,7 +1005,7 @@ sqlVdbeMemSetStr(Mem * pMem, /* Memory cell to set to string value */ } else if (xDel == SQL_DYNAMIC) { sqlVdbeMemRelease(pMem); pMem->zMalloc = pMem->z = (char *)z; - pMem->szMalloc = sqlDbMallocSize(pMem->zMalloc); + pMem->szMalloc = sqlMallocSize(pMem->zMalloc); } else { sqlVdbeMemRelease(pMem); pMem->z = (char *)z; diff --git a/src/box/sql/whereexpr.c b/src/box/sql/whereexpr.c index a954b17f1..faff37bb9 100644 --- a/src/box/sql/whereexpr.c +++ b/src/box/sql/whereexpr.c @@ -107,7 +107,7 @@ whereClauseInsert(WhereClause * pWC, Expr * p, u16 wtFlags) if (pOld != pWC->aStatic) { sqlDbFree(db, pOld); } - pWC->nSlot = sqlDbMallocSize(pWC->a) / sizeof(pWC->a[0]); + pWC->nSlot = sqlMallocSize(pWC->a) / sizeof(pWC->a[0]); } pTerm = &pWC->a[idx = pWC->nTerm++]; if (p && ExprHasProperty(p, EP_Unlikely)) { diff --git a/test/sql-tap/join.test.lua b/test/sql-tap/join.test.lua index ef6060927..f0ab16ad2 100755 --- a/test/sql-tap/join.test.lua +++ b/test/sql-tap/join.test.lua @@ -1072,13 +1072,6 @@ jointest("join-12.6", 66, {1, 'The number of tables in a join 66 exceeds the lim jointest("join-12.7", 127, {1, 'The number of tables in a join 127 exceeds the limit (64)'}) jointest("join-12.8", 128, {1, 'The number of tables in a join 128 exceeds the limit (64)'}) jointest("join-12.9", 1000, {1, 'The number of tables in a join 1000 exceeds the limit (64)'}) --- If sql is built with sql_MEMDEBUG, then the huge number of realloc() --- calls made by the following test cases are too time consuming to run. --- Without sql_MEMDEBUG, realloc() is fast enough that these are not --- a problem. ---if X(0, "X!capable", [["pragma&&compileoption_diags"]]) then --- if X(703, "X!cmd", [=[["expr","[lsearch [db eval {PRAGMA compile_options}] MEMDEBUG]<0"]]=]) --- then jointest("join-12.10", 65534, {1, 'The number of tables in a join 65534 exceeds the limit (64)'}) jointest("join-12.11", 65535, {1, 'The number of tables in a join 65535 exceeds the limit (64)'}) jointest("join-12.12", 65536, {1, 'The number of tables in a join 65536 exceeds the limit (64)'}) diff --git a/test/sql-tap/triggerA.test.lua b/test/sql-tap/triggerA.test.lua index aa4771b31..fac51ca14 100755 --- a/test/sql-tap/triggerA.test.lua +++ b/test/sql-tap/triggerA.test.lua @@ -326,35 +326,4 @@ test:do_test( -- }) --- # Only run the reamining tests if memory debugging is turned on. --- # --- ifcapable !memdebug { --- puts "Skipping triggerA malloc tests: not compiled with -Dsql_MEMDEBUG..." --- finish_test --- return --- } --- source $testdir/malloc_common.tcl --- # Save a copy of the current database configuration. --- # --- db close --- forcedelete test.db-triggerA --- copy_file test.db test.db-triggerA --- sql db test.db --- # Run malloc tests on the INSTEAD OF trigger firing. --- # --- do_malloc_test triggerA-3 -tclprep { --- db close --- forcedelete test.db test.db-journal --- forcecopy test.db-triggerA test.db --- sql db test.db --- sql_extended_result_codes db 1 --- db eval {SELECT * FROM v5; -- warm up the cache} --- } -sqlbody { --- DELETE FROM v5 WHERE x=5; --- UPDATE v5 SET b=b+9900000 WHERE x BETWEEN 3 AND 5; --- } --- # Clean up the saved database copy. --- # --- forcedelete test.db-triggerA test:finish_test() -