From: imeevma@tarantool.org To: korablev@tarantool.org Cc: tarantool-patches@freelists.org, kostja@tarantool.org Subject: [tarantool-patches] [PATCH v1 1/1] sql: remove SQL_*_BKPT macros Date: Tue, 26 Feb 2019 17:52:23 +0300 [thread overview] Message-ID: <efdf9612620d7f1741bbe0a5c3ff585dbcb269dc.1551192665.git.imeevma@gmail.com> (raw) Macros SQL_*_BKPT were used in debug mode to log errors that occurred during the execution of VDBE. They are not used now. This patch removes them. Part of #3965 --- https://github.com/tarantool/tarantool/issues/3965 https://github.com/tarantool/tarantool/tree/imeevma/gh-3965-rework-errors-in-vdbe src/box/sql/func.c | 2 +- src/box/sql/legacy.c | 4 +-- src/box/sql/main.c | 95 ++++++++++++-------------------------------------- src/box/sql/malloc.c | 2 +- src/box/sql/os.c | 6 ++-- src/box/sql/os_unix.c | 8 ++--- src/box/sql/prepare.c | 6 ++-- src/box/sql/printf.c | 4 +-- src/box/sql/select.c | 8 ++--- src/box/sql/sqlInt.h | 21 ----------- src/box/sql/status.c | 8 ++--- src/box/sql/table.c | 8 ++--- src/box/sql/tokenize.c | 4 +-- src/box/sql/vdbe.c | 6 ++-- src/box/sql/vdbeapi.c | 26 +++++++------- src/box/sql/vdbeaux.c | 10 +++--- src/box/sql/vdbemem.c | 18 +++++----- src/box/sql/vdbesort.c | 36 +++++++++---------- src/box/sql/where.c | 10 +++--- 19 files changed, 106 insertions(+), 176 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 79e2c0e..69571e9 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -1614,7 +1614,7 @@ sql_overload_function(sql * db, const char *zName, #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db) || zName == 0 || nArg < -2) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } #endif if (sqlFindFunction(db, zName, nArg, 0) == 0) { diff --git a/src/box/sql/legacy.c b/src/box/sql/legacy.c index 1670c57..599fba0 100644 --- a/src/box/sql/legacy.c +++ b/src/box/sql/legacy.c @@ -65,7 +65,7 @@ sql_exec(sql * db, /* The database on which the SQL executes */ struct session *user_session = current_session(); if (!sqlSafetyCheckOk(db)) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; if (zSql == 0) zSql = ""; @@ -175,7 +175,7 @@ sql_exec(sql * db, /* The database on which the SQL executes */ if (*pzErrMsg) { memcpy(*pzErrMsg, sql_errmsg(db), nErrMsg); } else { - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; sqlError(db, SQL_NOMEM); } } else if (pzErrMsg) { diff --git a/src/box/sql/main.c b/src/box/sql/main.c index fc2ef17..e8322a1 100644 --- a/src/box/sql/main.c +++ b/src/box/sql/main.c @@ -288,7 +288,7 @@ sql_config(int op, ...) * the sql library is in use. */ if (sqlGlobalConfig.isInit) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; va_start(ap, op); switch (op) { @@ -541,7 +541,7 @@ sqlClose(sql * db, int forceZombie) { assert(db); if (!sqlSafetyCheckSickOrOk(db)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } if (db->mTrace & SQL_TRACE_CLOSE) { db->xTrace(SQL_TRACE_CLOSE, db->pTraceArg, db, 0); @@ -652,7 +652,7 @@ sql_progress_handler(sql * db, { #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return; } #endif @@ -677,7 +677,7 @@ sql_interrupt(sql * db) #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db) && (db == 0 || db->magic != SQL_MAGIC_ZOMBIE)) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return; } #endif @@ -711,7 +711,7 @@ sqlCreateFunc(sql * db, (!xSFunc && (!xFinal && xStep)) || (nArg < -1 || nArg > SQL_MAX_FUNCTION_ARG) || (255 < (sqlStrlen30(zFunctionName)))) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } assert(SQL_FUNC_CONSTANT == SQL_DETERMINISTIC); @@ -738,7 +738,7 @@ sqlCreateFunc(sql * db, p = sqlFindFunction(db, zFunctionName, nArg, 1); assert(p || db->mallocFailed); if (!p) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } /* If an older version of the function with a configured destructor is @@ -779,7 +779,7 @@ sql_create_function_v2(sql * db, #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } #endif if (xDestroy) { @@ -818,7 +818,7 @@ sql_trace_v2(sql * db, /* Trace this connection */ { #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } #endif if (mTrace == 0) @@ -847,7 +847,7 @@ sql_commit_hook(sql * db, /* Attach the hook to this database */ #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return 0; } #endif @@ -871,7 +871,7 @@ sql_update_hook(sql * db, /* Attach the hook to this database */ #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return 0; } #endif @@ -894,7 +894,7 @@ sql_rollback_hook(sql * db, /* Attach the hook to this database */ #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return 0; } #endif @@ -970,13 +970,13 @@ sql_errmsg(sql * db) { const char *z; if (!db) { - return sqlErrStr(SQL_NOMEM_BKPT); + return sqlErrStr(SQL_NOMEM); } if (!sqlSafetyCheckSickOrOk(db)) { - return sqlErrStr(SQL_MISUSE_BKPT); + return sqlErrStr(SQL_MISUSE); } if (db->mallocFailed) { - z = sqlErrStr(SQL_NOMEM_BKPT); + z = sqlErrStr(SQL_NOMEM); } else { testcase(db->pErr == 0); assert(!db->mallocFailed); @@ -1000,10 +1000,10 @@ int sql_errcode(sql * db) { if (db && !sqlSafetyCheckSickOrOk(db)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } if (!db || db->mallocFailed) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } return db->errCode & db->errMask; } @@ -1012,10 +1012,10 @@ int sql_extended_errcode(sql * db) { if (db && !sqlSafetyCheckSickOrOk(db)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } if (!db || db->mallocFailed) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } return db->errCode; } @@ -1110,7 +1110,7 @@ sql_limit(sql * db, int limitId, int newLimit) #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return -1; } #endif @@ -1211,7 +1211,7 @@ sqlParseUri(const char *zDefaultVfs, /* VFS to use if no "vfs=xxx" query option nByte += (zUri[iIn] == '&'); zFile = sql_malloc64(nByte); if (!zFile) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; iIn = 5; #ifdef SQL_ALLOW_URI_AUTHORITY @@ -1418,7 +1418,7 @@ sqlParseUri(const char *zDefaultVfs, /* VFS to use if no "vfs=xxx" query option } else { zFile = sql_malloc64(nUri + 2); if (!zFile) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; if (nUri) { memcpy(zFile, zUri, nUri); } @@ -1457,7 +1457,7 @@ sql_init_db(sql **out_db) #ifdef SQL_ENABLE_API_ARMOR if (ppDb == 0) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif #ifndef SQL_OMIT_AUTOINIT rc = sql_initialize(); @@ -1571,55 +1571,6 @@ opendb_out: } /* - * The following routines are substitutes for constants - * SQL_MISUSE, SQL_CANTOPEN, SQL_NOMEM and possibly other error - * constants. They serve two purposes: - * - * 1. Serve as a convenient place to set a breakpoint in a debugger - * to detect when version error conditions occurs. - * - * 2. Invoke sql_log() to provide the source code location where - * a low-level error is first detected. - */ -static int -reportError(int iErr, int lineno, const char *zType) -{ - sql_log(iErr, "%s at line %d of [%.10s]", - zType, lineno, 20 + tarantool_version()); - return iErr; -} - -int -sqlMisuseError(int lineno) -{ - testcase(sqlGlobalConfig.xLog != 0); - return reportError(SQL_MISUSE, lineno, "misuse"); -} - -int -sqlCantopenError(int lineno) -{ - testcase(sqlGlobalConfig.xLog != 0); - return reportError(SQL_CANTOPEN, lineno, "cannot open file"); -} - -#ifdef SQL_DEBUG -int -sqlNomemError(int lineno) -{ - testcase(sqlGlobalConfig.xLog != 0); - return reportError(SQL_NOMEM, lineno, "OOM"); -} - -int -sqlIoerrnomemError(int lineno) -{ - testcase(sqlGlobalConfig.xLog != 0); - return reportError(SQL_IOERR_NOMEM, lineno, "I/O OOM error"); -} -#endif - -/* * Enable or disable the extended result codes. */ int @@ -1627,7 +1578,7 @@ sql_extended_result_codes(sql * db, int onoff) { #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db)) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif db->errMask = onoff ? 0xffffffff : 0xff; return SQL_OK; diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c index d01510e..e0d2ec8 100644 --- a/src/box/sql/malloc.c +++ b/src/box/sql/malloc.c @@ -955,7 +955,7 @@ apiOomError(sql * db) { sqlOomClear(db); sqlError(db, SQL_NOMEM); - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } /* diff --git a/src/box/sql/os.c b/src/box/sql/os.c index 2edfd6f..76a15ed 100644 --- a/src/box/sql/os.c +++ b/src/box/sql/os.c @@ -170,7 +170,7 @@ sqlOsOpenMalloc(sql_vfs * pVfs, *ppFile = pFile; } } else { - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } return rc; } @@ -194,7 +194,7 @@ sqlOsInit(void) { void *p = sql_malloc(10); if (p == 0) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; sql_free(p); return sql_os_init(); } @@ -263,7 +263,7 @@ sql_vfs_register(sql_vfs * pVfs, int makeDflt) #endif #ifdef SQL_ENABLE_API_ARMOR if (pVfs == 0) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif vfsUnlink(pVfs); diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c index d9a89df..b659985 100644 --- a/src/box/sql/os_unix.c +++ b/src/box/sql/os_unix.c @@ -472,7 +472,7 @@ findInodeInfo(unixFile * pFile, /* Unix file with file desc used in the key */ if (pInode == 0) { pInode = sql_malloc64(sizeof(*pInode)); if (pInode == 0) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } memset(pInode, 0, sizeof(*pInode)); memcpy(&pInode->fileId, &fileId, sizeof(fileId)); @@ -1033,7 +1033,7 @@ openDirectory(const char *zFilename, int *pFd) *pFd = fd; if (fd >= 0) return SQL_OK; - return unixLogError(SQL_CANTOPEN_BKPT, "openDirectory", zDirname); + return unixLogError(SQL_CANTOPEN, "openDirectory", zDirname); } /* @@ -1816,7 +1816,7 @@ unixOpen(sql_vfs * pVfs, /* The VFS for which this is the xOpen method */ } else { pUnused = sql_malloc64(sizeof(*pUnused)); if (!pUnused) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } } p->pUnused = pUnused; @@ -1882,7 +1882,7 @@ unixOpen(sql_vfs * pVfs, /* The VFS for which this is the xOpen method */ fd = robust_open(zName, openFlags, openMode); } if (fd < 0) { - rc = unixLogError(SQL_CANTOPEN_BKPT, "open", zName); + rc = unixLogError(SQL_CANTOPEN, "open", zName); goto open_finished; } diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c index d4ba55b..5ed7a36 100644 --- a/src/box/sql/prepare.c +++ b/src/box/sql/prepare.c @@ -104,7 +104,7 @@ sqlPrepare(sql * db, /* Database handle. */ if (sParse.rc == SQL_DONE) sParse.rc = SQL_OK; if (db->mallocFailed) { - sParse.rc = SQL_NOMEM_BKPT; + sParse.rc = SQL_NOMEM; } if (pzTail) { *pzTail = sParse.zTail; @@ -180,11 +180,11 @@ sqlLockAndPrepare(sql * db, /* Database handle. */ #ifdef SQL_ENABLE_API_ARMOR if (ppStmt == 0) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif *ppStmt = 0; if (!sqlSafetyCheckOk(db) || zSql == 0) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } rc = sqlPrepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail); diff --git a/src/box/sql/printf.c b/src/box/sql/printf.c index aeb1fc2..79b44c2 100644 --- a/src/box/sql/printf.c +++ b/src/box/sql/printf.c @@ -1085,7 +1085,7 @@ sql_vmprintf(const char *zFormat, va_list ap) #ifdef SQL_ENABLE_API_ARMOR if (zFormat == 0) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return 0; } #endif @@ -1139,7 +1139,7 @@ sql_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap) return zBuf; #ifdef SQL_ENABLE_API_ARMOR if (zBuf == 0 || zFormat == 0) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; if (zBuf) zBuf[0] = 0; return zBuf; diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 6a465a6..075b43a 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -1931,7 +1931,7 @@ sqlColumnsFromExprList(Parse * parse, ExprList * expr_list, } cleanup: sqlHashClear(&ht); - int rc = db->mallocFailed ? SQL_NOMEM_BKPT : SQL_OK; + int rc = db->mallocFailed ? SQL_NOMEM : SQL_OK; if (rc != SQL_OK) { /* * pTable->def could be not temporal in @@ -1939,7 +1939,7 @@ cleanup: */ space_def->fields = NULL; space_def->field_count = 0; - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } return rc; @@ -3330,7 +3330,7 @@ multiSelectOrderBy(Parse * pParse, /* Parsing context */ if (j == nOrderBy) { Expr *pNew = sqlExpr(db, TK_INTEGER, 0); if (pNew == 0) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; pNew->flags |= EP_IntValue; pNew->u.iValue = i; pOrderBy = sql_expr_list_append(pParse->db, @@ -4640,7 +4640,7 @@ withExpand(Walker * pWalker, struct SrcList_item *pFrom) return WRC_Abort; pFrom->pSelect = sqlSelectDup(db, pCte->pSelect, 0); if (db->mallocFailed) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; assert(pFrom->pSelect); /* Check if this is a recursive CTE. */ diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index dbfdbc6..06b66c5 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -3082,27 +3082,6 @@ struct TreeView { } /* - * The sql_*_BKPT macros are substitutes for the error codes with - * the same name but without the _BKPT suffix. These macros invoke - * routines that report the line-number on which the error originated - * using sql_log(). The routines also provide a convenient place - * to set a debugger breakpoint. - */ -int sqlMisuseError(int); -int sqlCantopenError(int); -#define SQL_MISUSE_BKPT sqlMisuseError(__LINE__) -#define SQL_CANTOPEN_BKPT sqlCantopenError(__LINE__) -#ifdef SQL_DEBUG -int sqlNomemError(int); -int sqlIoerrnomemError(int); -#define SQL_NOMEM_BKPT sqlNomemError(__LINE__) -#define SQL_IOERR_NOMEM_BKPT sqlIoerrnomemError(__LINE__) -#else -#define SQL_NOMEM_BKPT SQL_NOMEM -#define SQL_IOERR_NOMEM_BKPT SQL_IOERR_NOMEM -#endif - -/* * FTS4 is really an extension for FTS3. It is enabled using the * sql_ENABLE_FTS3 macro. But to avoid confusion we also call * the sql_ENABLE_FTS4 macro to serve as an alias for sql_ENABLE_FTS3. diff --git a/src/box/sql/status.c b/src/box/sql/status.c index c86cdd9..2abf7a5 100644 --- a/src/box/sql/status.c +++ b/src/box/sql/status.c @@ -142,11 +142,11 @@ sql_status64(int op, { wsdStatInit; if (op < 0 || op >= ArraySize(wsdStat.nowValue)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } #ifdef SQL_ENABLE_API_ARMOR if (pCurrent == 0 || pHighwater == 0) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif *pCurrent = wsdStat.nowValue[op]; *pHighwater = wsdStat.mxValue[op]; @@ -163,7 +163,7 @@ sql_status(int op, int *pCurrent, int *pHighwater, int resetFlag) int rc; #ifdef SQL_ENABLE_API_ARMOR if (pCurrent == 0 || pHighwater == 0) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif rc = sql_status64(op, &iCur, &iHwtr, resetFlag); if (rc == 0) { @@ -187,7 +187,7 @@ sql_db_status(sql * db, /* The database connection whose status is desired */ int rc = SQL_OK; /* Return code */ #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db) || pCurrent == 0 || pHighwater == 0) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } #endif switch (op) { diff --git a/src/box/sql/table.c b/src/box/sql/table.c index 18ab5d8..ff97d43 100644 --- a/src/box/sql/table.c +++ b/src/box/sql/table.c @@ -128,7 +128,7 @@ sql_get_table_cb(void *pArg, int nCol, char **argv, char **colv) return 0; malloc_failed: - p->rc = SQL_NOMEM_BKPT; + p->rc = SQL_NOMEM; return 1; } @@ -155,7 +155,7 @@ sql_get_table(sql * db, /* The database on which the SQL executes */ #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(db) || pazResult == 0) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif *pazResult = 0; if (pnColumn) @@ -173,7 +173,7 @@ sql_get_table(sql * db, /* The database on which the SQL executes */ res.azResult = sql_malloc64(sizeof(char *) * res.nAlloc); if (res.azResult == 0) { db->errCode = SQL_NOMEM; - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } res.azResult[0] = 0; rc = sql_exec(db, zSql, sql_get_table_cb, &res, pzErrMsg); @@ -204,7 +204,7 @@ sql_get_table(sql * db, /* The database on which the SQL executes */ if (azNew == 0) { sql_free_table(&res.azResult[1]); db->errCode = SQL_NOMEM; - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } res.azResult = azNew; } diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c index 0de0406..abf837d 100644 --- a/src/box/sql/tokenize.c +++ b/src/box/sql/tokenize.c @@ -468,7 +468,7 @@ sqlRunParser(Parse * pParse, const char *zSql, char **pzErrMsg) pEngine = sqlParserAlloc(sqlMalloc); if (pEngine == 0) { sqlOomFault(db); - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } assert(pParse->new_space == NULL); assert(pParse->parsed_ast.trigger == NULL); @@ -528,7 +528,7 @@ sqlRunParser(Parse * pParse, const char *zSql, char **pzErrMsg) #endif /* YYDEBUG */ sqlParserFree(pEngine, sql_free); if (db->mallocFailed) { - pParse->rc = SQL_NOMEM_BKPT; + pParse->rc = SQL_NOMEM; } if (pParse->rc != SQL_OK && pParse->rc != SQL_DONE && pParse->zErrMsg == 0) { diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 24d9ea4..d2d8e91 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -5520,7 +5520,7 @@ default: { /* This is really OP_Noop and OP_Explain */ * an error of some kind. */ abort_due_to_error: - if (db->mallocFailed) rc = SQL_NOMEM_BKPT; + if (db->mallocFailed) rc = SQL_NOMEM; assert(rc); if (p->zErrMsg==0 && rc!=SQL_IOERR_NOMEM) { const char *msg; @@ -5565,7 +5565,7 @@ too_big: no_mem: sqlOomFault(db); sqlVdbeError(p, "out of memory"); - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; goto abort_due_to_error; /* Jump to here if the sql_interrupt() API sets the interrupt @@ -5573,7 +5573,7 @@ no_mem: */ abort_due_to_interrupt: assert(db->u1.isInterrupted); - rc = db->mallocFailed ? SQL_NOMEM_BKPT : SQL_INTERRUPT; + rc = db->mallocFailed ? SQL_NOMEM : SQL_INTERRUPT; p->rc = rc; sqlVdbeError(p, "%s", sqlErrStr(rc)); goto abort_due_to_error; diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 250afc2..9f0638a 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -124,7 +124,7 @@ sql_finalize(sql_stmt * pStmt) Vdbe *v = (Vdbe *) pStmt; sql *db = v->db; if (vdbeSafety(v)) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; checkProfileCallback(db, v); rc = sqlVdbeFinalize(v); rc = sqlApiExit(db, rc); @@ -487,7 +487,7 @@ void sql_result_error_nomem(sql_context * pCtx) { sqlVdbeMemSetNull(pCtx->pOut); - pCtx->isError = SQL_NOMEM_BKPT; + pCtx->isError = SQL_NOMEM; pCtx->fErrorOrAux = 1; sqlOomFault(pCtx->pOut->db); } @@ -529,7 +529,7 @@ sqlStep(Vdbe * p) if ((rc = p->rc & 0xff) == SQL_BUSY || rc == SQL_LOCKED) { sql_reset((sql_stmt *) p); } else { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } #else sql_reset((sql_stmt *) p); @@ -540,7 +540,7 @@ sqlStep(Vdbe * p) db = p->db; if (db->mallocFailed) { p->rc = SQL_NOMEM; - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } if (p->pc <= 0 && p->expired) { @@ -585,7 +585,7 @@ sqlStep(Vdbe * p) db->errCode = rc; if (SQL_NOMEM == sqlApiExit(p->db, p->rc)) { - p->rc = SQL_NOMEM_BKPT; + p->rc = SQL_NOMEM; } end_of_step: /* At this point local variable rc holds the value that should be @@ -622,7 +622,7 @@ sql_step(sql_stmt * pStmt) sql *db; /* The database connection */ if (vdbeSafetyNotNull(v)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } db = v->db; v->doingRerun = 0; @@ -653,7 +653,7 @@ sql_step(sql_stmt * pStmt) v->rc = rc2; } else { v->zErrMsg = 0; - v->rc = rc = SQL_NOMEM_BKPT; + v->rc = rc = SQL_NOMEM; } } rc = sqlApiExit(db, rc); @@ -1076,7 +1076,7 @@ columnName(sql_stmt * pStmt, sql *db; #ifdef SQL_ENABLE_API_ARMOR if (pStmt == 0) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return 0; } #endif @@ -1195,13 +1195,13 @@ vdbeUnbind(Vdbe * p, int i) { Mem *pVar; if (vdbeSafetyNotNull(p)) { - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } if (p->magic != VDBE_MAGIC_RUN || p->pc >= 0) { sqlError(p->db, SQL_MISUSE); sql_log(SQL_MISUSE, "bind on a busy prepared statement: [%s]", p->zSql); - return SQL_MISUSE_BKPT; + return SQL_MISUSE; } if (i < 1 || i > p->nVar) { sqlError(p->db, SQL_RANGE); @@ -1316,7 +1316,7 @@ sql_bind_blob(sql_stmt * pStmt, { #ifdef SQL_ENABLE_API_ARMOR if (nData < 0) - return SQL_MISUSE_BKPT; + return SQL_MISUSE; #endif return bindText(pStmt, i, zData, nData, xDel); } @@ -1570,7 +1570,7 @@ sql_next_stmt(sql * pDb, sql_stmt * pStmt) sql_stmt *pNext; #ifdef SQL_ENABLE_API_ARMOR if (!sqlSafetyCheckOk(pDb)) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return 0; } #endif @@ -1592,7 +1592,7 @@ sql_stmt_status(sql_stmt * pStmt, int op, int resetFlag) u32 v; #ifdef SQL_ENABLE_API_ARMOR if (!pStmt) { - (void)SQL_MISUSE_BKPT; + (void)SQL_MISUSE; return 0; } #endif diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index e0f66ea..071609d 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -208,7 +208,7 @@ growOpArray(Vdbe * v, int nOp) p->nOpAlloc = p->szOpAlloc / sizeof(Op); v->aOp = pNew; } - return (pNew ? SQL_OK : SQL_NOMEM_BKPT); + return (pNew ? SQL_OK : SQL_NOMEM); } #ifdef SQL_DEBUG @@ -1570,7 +1570,7 @@ sqlVdbeList(Vdbe * p) releaseMemArray(pMem, 8); p->pResultSet = 0; - if (p->rc == SQL_NOMEM_BKPT) { + if (p->rc == SQL_NOMEM) { /* This happens if a malloc() inside a call to sql_column_text() or * sql_column_text16() failed. */ @@ -2175,7 +2175,7 @@ sqlVdbeSetColName(Vdbe * p, /* Vdbe being configured */ assert(var < COLNAME_N); if (p->db->mallocFailed) { assert(!zName || xDel != SQL_DYNAMIC); - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } assert(p->aColName != 0); assert(var == COLNAME_NAME || var == COLNAME_DECLTYPE); @@ -2342,7 +2342,7 @@ sqlVdbeHalt(Vdbe * p) */ if (db->mallocFailed) { - p->rc = SQL_NOMEM_BKPT; + p->rc = SQL_NOMEM; } closeTopFrameCursors(p); if (p->magic != VDBE_MAGIC_RUN) { @@ -2506,7 +2506,7 @@ sqlVdbeHalt(Vdbe * p) p->magic = VDBE_MAGIC_HALT; checkActiveVdbeCnt(db); if (db->mallocFailed) { - p->rc = SQL_NOMEM_BKPT; + p->rc = SQL_NOMEM; } assert(db->nVdbeActive > 0 || box_txn() || diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index 19802f7..f67c32e 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -130,7 +130,7 @@ sqlVdbeMemGrow(Mem * pMem, int n, int bPreserve) sqlVdbeMemSetNull(pMem); pMem->z = 0; pMem->szMalloc = 0; - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } else { pMem->szMalloc = sqlDbMallocSize(pMem->db, pMem->zMalloc); @@ -191,7 +191,7 @@ sqlVdbeMemMakeWriteable(Mem * pMem) return SQL_NOMEM; if (pMem->szMalloc == 0 || pMem->z != pMem->zMalloc) { if (sqlVdbeMemGrow(pMem, pMem->n + 2, 1)) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } pMem->z[pMem->n] = 0; pMem->z[pMem->n + 1] = 0; @@ -224,7 +224,7 @@ sqlVdbeMemExpandBlob(Mem * pMem) nByte = 1; } if (sqlVdbeMemGrow(pMem, nByte, 1)) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } memset(&pMem->z[pMem->n], 0, pMem->u.nZero); @@ -242,7 +242,7 @@ static SQL_NOINLINE int vdbeMemAddTerminator(Mem * pMem) { if (sqlVdbeMemGrow(pMem, pMem->n + 2, 1)) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } pMem->z[pMem->n] = 0; pMem->z[pMem->n + 1] = 0; @@ -293,7 +293,7 @@ sqlVdbeMemStringify(Mem * pMem, u8 bForce) assert(EIGHT_BYTE_ALIGNMENT(pMem)); if (sqlVdbeMemClearAndResize(pMem, nByte)) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } if (fg & MEM_Int) { sql_snprintf(nByte, pMem->z, "%lld", pMem->u.i); @@ -929,7 +929,7 @@ sqlVdbeMemSetStr(Mem * pMem, /* Memory cell to set to string value */ testcase(nAlloc == 31); testcase(nAlloc == 32); if (sqlVdbeMemClearAndResize(pMem, MAX(nAlloc, 32))) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } memcpy(pMem->z, z, nAlloc); } else if (xDel == SQL_DYNAMIC) { @@ -1198,7 +1198,7 @@ valueFromFunction(sql * db, /* The database connection */ sizeof(apVal[0]) * nVal); if (apVal == 0) { - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; goto value_from_function_out; } for (i = 0; i < nVal; i++) { @@ -1211,7 +1211,7 @@ valueFromFunction(sql * db, /* The database connection */ pVal = valueNew(db, pCtx); if (pVal == 0) { - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; goto value_from_function_out; } @@ -1380,7 +1380,7 @@ valueFromExpr(sql * db, /* The database connection */ if (pCtx == 0) sqlValueFree(pVal); - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } /* diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c index 9cffa11..779e832 100644 --- a/src/box/sql/vdbesort.c +++ b/src/box/sql/vdbesort.c @@ -570,7 +570,7 @@ vdbePmaReadBlob(PmaReader * p, /* PmaReader from which to take the blob */ nNew = nNew * 2; aNew = sqlRealloc(p->aAlloc, nNew); if (!aNew) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; p->nAlloc = nNew; p->aAlloc = aNew; } @@ -696,7 +696,7 @@ vdbePmaReaderSeek(SortSubtask * pTask, /* Task context */ if (pReadr->aBuffer == 0) { pReadr->aBuffer = (u8 *) sqlMalloc(pgsz); if (pReadr->aBuffer == 0) - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; pReadr->nBuffer = pgsz; } if (rc == SQL_OK && iBuf) { @@ -881,7 +881,7 @@ sqlVdbeSorterInit(sql * db, /* Database connection (for malloc()) */ pSorter = (VdbeSorter *) sqlDbMallocZero(db, sizeof(VdbeSorter)); pCsr->uc.pSorter = pSorter; if (pSorter == 0) { - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } else { pSorter->key_def = pCsr->key_def; pSorter->pgsz = pgsz = 1024; @@ -915,7 +915,7 @@ sqlVdbeSorterInit(sql * db, /* Database connection (for malloc()) */ pSorter->list.aMemory = (u8 *) sqlMalloc(pgsz); if (!pSorter->list.aMemory) - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } } @@ -1273,7 +1273,7 @@ vdbeSortAllocUnpacked(SortSubtask * pTask) sqlVdbeAllocUnpackedRecord(pTask->pSorter->db, pTask->pSorter->key_def); if (pTask->pUnpacked == 0) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; pTask->pUnpacked->nField = pTask->pSorter->key_def->part_count; pTask->pUnpacked->errCode = 0; } @@ -1356,7 +1356,7 @@ vdbeSorterSort(SortSubtask * pTask, SorterList * pList) aSlot = (SorterRecord **) sqlMallocZero(64 * sizeof(SorterRecord *)); if (!aSlot) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } while (p) { @@ -1411,7 +1411,7 @@ vdbePmaWriterInit(sql_file * pFd, /* File handle to write to */ memset(p, 0, sizeof(PmaWriter)); p->aBuffer = (u8 *) sqlMalloc(nBuf); if (!p->aBuffer) { - p->eFWErr = SQL_NOMEM_BKPT; + p->eFWErr = SQL_NOMEM; } else { p->iBufEnd = p->iBufStart = (iStart % nBuf); p->iWriteOff = iStart - p->iBufStart; @@ -1732,7 +1732,7 @@ vdbeSorterFlushPMA(VdbeSorter * pSorter) pSorter->list.aMemory = sqlMalloc(pSorter->nMemory); if (!pSorter->list.aMemory) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } rc = vdbeSorterCreateThread(pTask, @@ -1832,7 +1832,7 @@ sqlVdbeSorterWrite(const VdbeCursor * pCsr, /* Sorter cursor */ aNew = sqlRealloc(pSorter->list.aMemory, nNew); if (!aNew) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; pSorter->list.pList = (SorterRecord *) & aNew[iListOff]; pSorter->list.aMemory = aNew; pSorter->nMemory = nNew; @@ -1849,7 +1849,7 @@ sqlVdbeSorterWrite(const VdbeCursor * pCsr, /* Sorter cursor */ } else { pNew = (SorterRecord *) sqlMalloc(nReq); if (pNew == 0) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } pNew->u.pNext = pSorter->list.pList; } @@ -2012,7 +2012,7 @@ vdbeIncrMergerNew(SortSubtask * pTask, /* The thread that will be using the new pTask->file2.iEof += pIncr->mxSz; } else { vdbeMergeEngineFree(pMerger); - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } return rc; } @@ -2337,7 +2337,7 @@ vdbeMergeEngineLevel0(SortSubtask * pTask, /* Sorter task to read from */ *ppOut = pNew = vdbeMergeEngineNew(nPMA); if (pNew == 0) - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; for (i = 0; i < nPMA && rc == SQL_OK; i++) { i64 nDummy = 0; @@ -2413,7 +2413,7 @@ vdbeSorterAddToTree(SortSubtask * pTask, /* Task context */ MergeEngine *pNew = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT); if (pNew == 0) { - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } else { rc = vdbeIncrMergerNew(pTask, pNew, &pReadr->pIncr); @@ -2462,7 +2462,7 @@ vdbeSorterMergeTreeBuild(VdbeSorter * pSorter, /* The VDBE cursor that implement if (pSorter->nTask > 1) { pMain = vdbeMergeEngineNew(pSorter->nTask); if (pMain == 0) - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } #endif @@ -2483,7 +2483,7 @@ vdbeSorterMergeTreeBuild(VdbeSorter * pSorter, /* The VDBE cursor that implement pRoot = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT); if (pRoot == 0) - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; for (i = 0; i < pTask->nPMA && rc == SQL_OK; i += SORTER_MAX_MERGE_COUNT) { MergeEngine *pMerger = 0; /* New level-0 PMA merger */ @@ -2574,7 +2574,7 @@ vdbeSorterSetupMerge(VdbeSorter * pSorter) (PmaReader)); pSorter->pReader = pReadr; if (pReadr == 0) - rc = SQL_NOMEM_BKPT; + rc = SQL_NOMEM; } if (rc == SQL_OK) { rc = vdbeIncrMergerNew(pLast, pMain, @@ -2778,7 +2778,7 @@ sqlVdbeSorterRowkey(const VdbeCursor * pCsr, Mem * pOut) pSorter = pCsr->uc.pSorter; pKey = vdbeSorterRowkey(pSorter, &nKey); if (sqlVdbeMemClearAndResize(pOut, nKey)) { - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } pOut->n = nKey; MemSetTypeFlag(pOut, MEM_Blob); @@ -2823,7 +2823,7 @@ sqlVdbeSorterCompare(const VdbeCursor * pCsr, /* Sorter cursor */ r2 = pSorter->pUnpacked = sqlVdbeAllocUnpackedRecord(pSorter->db, pCsr->key_def); if (r2 == 0) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; r2->nField = nKeyCol; } assert(r2->nField == nKeyCol); diff --git a/src/box/sql/where.c b/src/box/sql/where.c index 1bba9d6..a4da5dc 100644 --- a/src/box/sql/where.c +++ b/src/box/sql/where.c @@ -1766,7 +1766,7 @@ whereLoopResize(sql * db, WhereLoop * p, int n) n = (n + 7) & ~7; paNew = sqlDbMallocRawNN(db, sizeof(p->aLTerm[0]) * n); if (paNew == 0) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; memcpy(paNew, p->aLTerm, sizeof(p->aLTerm[0]) * p->nLSlot); if (p->aLTerm != p->aLTermSpace) sqlDbFree(db, p->aLTerm); @@ -1787,7 +1787,7 @@ whereLoopXfer(sql * db, WhereLoop * pTo, WhereLoop * pFrom) pTo->nBtm = 0; pTo->nTop = 0; pTo->index_def = NULL; - return SQL_NOMEM_BKPT; + return SQL_NOMEM; } memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ); memcpy(pTo->aLTerm, pFrom->aLTerm, @@ -2104,7 +2104,7 @@ whereLoopInsert(WhereLoopBuilder * pBuilder, WhereLoop * pTemplate) /* Allocate a new WhereLoop to add to the end of the list */ *ppPrev = p = sqlDbMallocRawNN(db, sizeof(WhereLoop)); if (p == 0) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; whereLoopInit(p); p->pNextLoop = 0; } else { @@ -2333,7 +2333,7 @@ whereLoopAddBtreeIndex(WhereLoopBuilder * pBuilder, /* The WhereLoop factory */ pNew = pBuilder->pNew; if (db->mallocFailed) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; WHERETRACE(0x800, ("BEGIN addBtreeIdx(%s), nEq=%d\n", probe->name, pNew->nEq)); @@ -3629,7 +3629,7 @@ wherePathSolver(WhereInfo * pWInfo, LogEst nRowEst) nSpace += sizeof(LogEst) * nOrderBy; pSpace = sqlDbMallocRawNN(db, nSpace); if (pSpace == 0) - return SQL_NOMEM_BKPT; + return SQL_NOMEM; aTo = (WherePath *) pSpace; aFrom = aTo + mxChoice; memset(aFrom, 0, sizeof(aFrom[0])); -- 2.7.4
next reply other threads:[~2019-02-26 14:52 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-26 14:52 imeevma [this message] 2019-02-26 18:12 ` [tarantool-patches] " n.pettik 2019-02-27 11:17 ` Kirill Yukhin
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=efdf9612620d7f1741bbe0a5c3ff585dbcb269dc.1551192665.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=korablev@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/1] sql: remove SQL_*_BKPT macros' \ /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