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 7005530C43 for ; Thu, 13 Jun 2019 18:24:32 -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 1lhPBtlFgPMZ for ; Thu, 13 Jun 2019 18:24:32 -0400 (EDT) Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 0404A308B2 for ; Thu, 13 Jun 2019 18:24:31 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 07/28] sql: remove SQL_OK error/status code References: <5380a39d23531fd8eaea59feff42afb792bc5df6.1560174553.git.imeevma@gmail.com> From: Vladislav Shpilevoy Message-ID: <0704f003-a3fd-74f5-5b42-3366d8dd7331@tarantool.org> Date: Fri, 14 Jun 2019 00:24:47 +0200 MIME-Version: 1.0 In-Reply-To: <5380a39d23531fd8eaea59feff42afb792bc5df6.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! Consider my review fixes below and on the branch in a separate commit. ====================================================== diff --git a/src/box/ck_constraint.c b/src/box/ck_constraint.c index c54c87069..1cde27022 100644 --- a/src/box/ck_constraint.c +++ b/src/box/ck_constraint.c @@ -172,9 +172,7 @@ ck_constraint_program_run(struct ck_constraint *ck_constraint, * Get VDBE execution state and reset VM to run it * next time. */ - if (sql_reset(ck_constraint->stmt) != 0) - return -1; - return 0; + return sql_reset(ck_constraint->stmt); } void diff --git a/src/box/sql/cursor.c b/src/box/sql/cursor.c index f4b19db96..bb2dae898 100644 --- a/src/box/sql/cursor.c +++ b/src/box/sql/cursor.c @@ -93,12 +93,8 @@ sqlCursorIsValidNN(BtCursor *pCur) * * For sqlCursorPayload(), the caller must ensure that pCur is pointing * to a valid row in the table. - * - * Return 0 on success or an error code if anything goes - * wrong. An error is returned if "offset+amt" is larger than - * the available payload. */ -int +void sqlCursorPayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf) { assert(pCur->eState == CURSOR_VALID); @@ -110,7 +106,6 @@ sqlCursorPayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf) pPayload = tarantoolsqlPayloadFetch(pCur, &sz); assert((uptr) (offset + amt) <= sz); memcpy(pBuf, pPayload + offset, amt); - return 0; } /* Move the cursor so that it points to an entry near the key diff --git a/src/box/sql/cursor.h b/src/box/sql/cursor.h index 237411613..2628f86a3 100644 --- a/src/box/sql/cursor.h +++ b/src/box/sql/cursor.h @@ -64,7 +64,8 @@ int sqlCursorMovetoUnpacked(BtCursor *, UnpackedRecord * pUnKey, int *pRes); int sqlCursorNext(BtCursor *, int *pRes); int sqlCursorPrevious(BtCursor *, int *pRes); -int sqlCursorPayload(BtCursor *, u32 offset, u32 amt, void *); +void +sqlCursorPayload(BtCursor *, u32 offset, u32 amt, void *); /** * Release tuple, free iterator, invalidate cursor's state. diff --git a/src/box/sql/legacy.c b/src/box/sql/legacy.c index f7e069ad9..42fd3d1a4 100644 --- a/src/box/sql/legacy.c +++ b/src/box/sql/legacy.c @@ -68,16 +68,15 @@ sql_exec(sql * db, /* The database on which the SQL executes */ if (zSql == 0) zSql = ""; - while (rc == 0 && zSql[0]) { + while (rc == 0 && zSql[0] != 0) { int nCol; char **azVals = 0; pStmt = 0; rc = sql_prepare_v2(db, zSql, -1, &pStmt, &zLeftover); - assert(rc == 0 || pStmt == 0); - if (rc != 0) { + assert(rc == 0 || pStmt == NULL); + if (rc != 0) continue; - } if (!pStmt) { /* this happens for a comment or white-space */ zSql = zLeftover; diff --git a/src/box/sql/main.c b/src/box/sql/main.c index 65d8de529..c97c25ada 100644 --- a/src/box/sql/main.c +++ b/src/box/sql/main.c @@ -144,12 +144,8 @@ sql_initialize(void) memset(&sqlBuiltinFunctions, 0, sizeof(sqlBuiltinFunctions)); sqlRegisterBuiltinFunctions(); - if (rc == 0) { - rc = sqlOsInit(); - } - if (rc == 0) { - sqlGlobalConfig.isInit = 1; - } + sql_os_init(); + sqlGlobalConfig.isInit = 1; sqlGlobalConfig.inProgress = 0; } @@ -160,17 +156,14 @@ sql_initialize(void) */ #ifndef NDEBUG /* This section of code's only "output" is via assert() statements. */ - if (rc == 0) { - u64 x = (((u64) 1) << 63) - 1; - double y; - assert(sizeof(x) == 8); - assert(sizeof(x) == sizeof(y)); - memcpy(&y, &x, 8); - assert(sqlIsNaN(y)); - } + u64 x = (((u64) 1) << 63) - 1; + double y; + assert(sizeof(x) == 8); + assert(sizeof(x) == sizeof(y)); + memcpy(&y, &x, 8); + assert(sqlIsNaN(y)); #endif - - return rc; + return 0; } void @@ -348,27 +341,6 @@ sql_create_function_v2(sql * db, return rc; } -#ifndef SQL_OMIT_TRACE -/* Register a trace callback using the version-2 interface. - */ -int -sql_trace_v2(sql * db, /* Trace this connection */ - unsigned mTrace, /* Mask of events to be traced */ - int (*xTrace) (unsigned, void *, void *, void *), /* Callback to invoke */ - void *pArg) /* Context */ -{ - if (mTrace == 0) - xTrace = 0; - if (xTrace == 0) - mTrace = 0; - db->mTrace = mTrace; - db->xTrace = xTrace; - db->pTraceArg = pArg; - return 0; -} - -#endif /* SQL_OMIT_TRACE */ - /* * This function returns true if main-memory should be used instead of * a temporary file for transient pager files and statement journals. diff --git a/src/box/sql/os.c b/src/box/sql/os.c index 5804e9aa4..10b68c8d9 100644 --- a/src/box/sql/os.c +++ b/src/box/sql/os.c @@ -177,22 +177,6 @@ sqlOsCloseFree(sql_file * pFile) sql_free(pFile); } -/* - * This function is a wrapper around the OS specific implementation of - * sql_os_init(). The purpose of the wrapper is to provide the - * ability to simulate a malloc failure, so that the handling of an - * error in sql_os_init() by the upper layers can be tested. - */ -int -sqlOsInit(void) -{ - void *p = sql_malloc(10); - if (p == 0) - return SQL_NOMEM; - sql_free(p); - return sql_os_init(); -} - /* * The list of all registered VFS implementations. */ diff --git a/src/box/sql/os.h b/src/box/sql/os.h index 9122e9cb7..3c891f3ee 100644 --- a/src/box/sql/os.h +++ b/src/box/sql/os.h @@ -126,11 +126,6 @@ #define SHARED_FIRST (PENDING_BYTE+2) #define SHARED_SIZE 510 -/* - * Wrapper around OS specific sql_os_init() function. - */ -int sqlOsInit(void); - /* * Functions for accessing sql_file methods */ diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c index 41098df17..bf3ba0eb1 100644 --- a/src/box/sql/os_unix.c +++ b/src/box/sql/os_unix.c @@ -1827,9 +1827,8 @@ unixOpen(sql_vfs * pVfs, /* The VFS for which this is the xOpen method */ /* If zName is NULL, the upper layer is requesting a temp file. */ assert(isDelete); rc = unixGetTempname(pVfs->mxPathname, zTmpname); - if (rc != 0) { + if (rc != 0) return rc; - } zName = zTmpname; /* Generated temporary filenames are always double-zero terminated @@ -1911,9 +1910,8 @@ unixOpen(sql_vfs * pVfs, /* The VFS for which this is the xOpen method */ rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags); open_finished: - if (rc != 0) { + if (rc != 0) sql_free(p->pUnused); - } return rc; } @@ -1993,15 +1991,13 @@ int sql_current_time = 0; * epoch of noon in Greenwich on November 24, 4714 B.C according to the * proleptic Gregorian calendar. * - * On success, return 0. Return SQL_ERROR if the time and date - * cannot be found. + * Always returns 0. */ static int unixCurrentTimeInt64(sql_vfs * NotUsed, sql_int64 * piNow) { static const sql_int64 unixEpoch = 24405875 * (sql_int64) 8640000; - int rc = 0; struct timeval sNow; (void)gettimeofday(&sNow, 0); /* Cannot fail given valid arguments */ *piNow = @@ -2015,7 +2011,7 @@ unixCurrentTimeInt64(sql_vfs * NotUsed, sql_int64 * piNow) } #endif UNUSED_PARAMETER(NotUsed); - return rc; + return 0; } /* @@ -2049,16 +2045,15 @@ unixCurrentTimeInt64(sql_vfs * NotUsed, sql_int64 * piNow) * Initialize the operating system interface. * * This routine registers all VFS implementations for unix-like operating - * systems. This routine, and the sql_os_end() routine that follows, - * should be the only routines in this file that are visible from other - * files. + * systems. This routine should be the only one in this file that + * are visible from other files. * * This routine is called once during sql initialization and by a * single thread. The memory allocation subsystem have not * necessarily been initialized when this routine \is called, and so they * should not be used. */ -int +void sql_os_init(void) { /* @@ -2076,18 +2071,4 @@ sql_os_init(void) /* Register all VFSes defined in the aVfs[] array. */ for (unsigned int i = 0; i < (sizeof(aVfs) / sizeof(sql_vfs)); i++) sql_vfs_register(&aVfs[i], i == 0); - return 0; -} - -/* - * Shutdown the operating system interface. - * - * Some operating systems might need to do some cleanup in this routine, - * to release dynamically allocated objects. But not on unix. - * This routine is a no-op for unix. - */ -int -sql_os_end(void) -{ - return 0; } diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c index 5b0be3e37..7a8a2d810 100644 --- a/src/box/sql/prepare.c +++ b/src/box/sql/prepare.c @@ -107,7 +107,7 @@ sqlPrepare(sql * db, /* Database handle. */ if (sParse.is_aborted) rc = SQL_TARANTOOL_ERROR; - if (rc == 0 && sParse.pVdbe && sParse.explain) { + if (rc == 0 && sParse.pVdbe != NULL && sParse.explain) { static const char *const azColName[] = { /* 0 */ "addr", /* 1 */ "INTEGER", @@ -159,7 +159,7 @@ sqlPrepare(sql * db, /* Database handle. */ sqlVdbeSetSql(pVdbe, zSql, (int)(sParse.zTail - zSql), saveSqlFlag); } - if (sParse.pVdbe && (rc != 0 || db->mallocFailed)) { + if (sParse.pVdbe != NULL && (rc != 0 || db->mallocFailed)) { sqlVdbeFinalize(sParse.pVdbe); assert(!(*ppStmt)); } else { @@ -201,7 +201,7 @@ sqlLockAndPrepare(sql * db, /* Database handle. */ rc = sqlPrepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail); } - assert(rc == 0 || *ppStmt == 0); + assert(rc == 0 || *ppStmt == NULL); return rc; } @@ -258,7 +258,7 @@ sql_prepare(sql * db, /* Database handle. */ { int rc; rc = sqlLockAndPrepare(db, zSql, nBytes, 0, 0, ppStmt, pzTail); - assert(rc == 0 || ppStmt == 0 || *ppStmt == 0); /* VERIFY: F13021 */ + assert(rc == 0 || ppStmt == NULL || *ppStmt == NULL); /* VERIFY: F13021 */ return rc; } @@ -272,7 +272,7 @@ sql_prepare_v2(sql * db, /* Database handle. */ { int rc; rc = sqlLockAndPrepare(db, zSql, nBytes, 1, 0, ppStmt, pzTail); - assert(rc == 0 || ppStmt == 0 || *ppStmt == 0); /* VERIFY: F13021 */ + assert(rc == 0 || ppStmt == NULL || *ppStmt == NULL); /* VERIFY: F13021 */ return rc; } diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 316810a11..42a29ad4f 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -673,9 +673,6 @@ sql_column_datatype(sql_stmt *, int N); int sql_initialize(void); -int -sql_os_end(void); - #define SQL_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQL_CONFIG_MEMSTATUS 9 /* boolean */ #define SQL_CONFIG_LOG 16 /* xFunc, void* */ @@ -810,7 +807,7 @@ struct sql_io_methods { #define SQL_FCNTL_HAS_MOVED 18 #define SQL_FCNTL_SYNC 19 -int +void sql_os_init(void); sql_int64 diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 77c6fa5b8..e11d29203 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -247,7 +247,7 @@ allocateCursor( sqlVdbeFreeCursor(p, p->apCsr[iCur]); p->apCsr[iCur] = 0; } - if (0==sqlVdbeMemClearAndResize(pMem, nByte)) { + if (sqlVdbeMemClearAndResize(pMem, nByte) == 0) { p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z; memset(pCx, 0, offsetof(VdbeCursor,uc)); pCx->eCurType = eCurType; @@ -372,7 +372,7 @@ static u16 SQL_NOINLINE computeNumericType(Mem *pMem) assert((pMem->flags & (MEM_Str|MEM_Blob))!=0); if (sqlAtoF(pMem->z, &pMem->u.r, pMem->n)==0) return 0; - if (sql_atoi64(pMem->z, (int64_t *)&pMem->u.i, pMem->n)==0) + if (sql_atoi64(pMem->z, &pMem->u.i, pMem->n) == 0) return MEM_Int; return MEM_Real; } @@ -752,7 +752,7 @@ int sqlVdbeExec(Vdbe *p) */ goto no_mem; } - assert(p->rc==0 || (p->rc&0xff)==SQL_BUSY); + assert(p->rc == 0 || (p->rc & 0xff) == SQL_BUSY); p->rc = 0; p->iCurrentTime = 0; assert(p->explain==0); @@ -789,7 +789,7 @@ int sqlVdbeExec(Vdbe *p) /* Errors are detected by individual opcodes, with an immediate * jumps to abort_due_to_error. */ - assert(rc==0); + assert(rc == 0); assert(pOp>=aOp && pOp<&aOp[p->nOp]); #ifdef VDBE_PROFILE @@ -1036,7 +1036,7 @@ case OP_Halt: { int pcx; pcx = (int)(pOp - aOp); - if (pOp->p1==0 && p->pFrame) { + if (pOp->p1 == 0 && p->pFrame != NULL) { /* Halt the sub-program. Return control to the parent frame. */ pFrame = p->pFrame; p->pFrame = pFrame->pParent; @@ -1068,11 +1068,11 @@ case OP_Halt: { assert(! diag_is_empty(diag_get())); } rc = sqlVdbeHalt(p); - assert(rc==SQL_BUSY || rc==0 || rc==SQL_ERROR); + assert(rc == SQL_BUSY || rc == 0 || rc == SQL_ERROR); if (rc==SQL_BUSY) { p->rc = SQL_BUSY; } else { - assert(rc==0 || (p->rc&0xff)==SQL_CONSTRAINT); + assert(rc == 0 || (p->rc & 0xff) == SQL_CONSTRAINT); rc = p->rc ? SQL_TARANTOOL_ERROR : SQL_DONE; } goto vdbe_return; @@ -1145,7 +1145,7 @@ case OP_String8: { /* same as TK_STRING, out2 */ if (pOp->p1>db->aLimit[SQL_LIMIT_LENGTH]) { goto too_big; } - assert(rc==0); + assert(rc == 0); /* Fall through to the next case, OP_String */ FALLTHROUGH; } @@ -2883,9 +2883,8 @@ case OP_Savepoint: { */ int isTransaction = pSavepoint->pNext == 0; if (isTransaction && p1==SAVEPOINT_RELEASE) { - if ((rc = sqlVdbeCheckFk(p, 1))!=0) { + if ((rc = sqlVdbeCheckFk(p, 1)) != 0) goto vdbe_return; - } if (sqlVdbeHalt(p)==SQL_BUSY) { p->pc = (int)(pOp - aOp); p->rc = rc = SQL_BUSY; @@ -3933,9 +3932,9 @@ case OP_RowData: { testcase( n==0); sqlVdbeMemRelease(pOut); - if (sql_vdbe_mem_alloc_region(pOut, n) != 0 || - sqlCursorPayload(pCrsr, 0, n, pOut->z) != 0) + if (sql_vdbe_mem_alloc_region(pOut, n) != 0) goto abort_due_to_error; + sqlCursorPayload(pCrsr, 0, n, pOut->z); UPDATE_MAX_BLOBSIZE(pOut); REGISTER_TRACE(p, pOp->p2, pOut); break; @@ -5291,7 +5290,7 @@ abort_due_to_error: vdbe_return: testcase( nVmStep>0); p->aCounter[SQL_STMTSTATUS_VM_STEP] += (int)nVmStep; - assert(rc!=0 || nExtraDelete==0 + assert(rc != 0 || nExtraDelete == 0 || sql_strlike_ci("DELETE%", p->zSql, 0) != 0 ); assert(rc == 0 || rc == SQL_BUSY || rc == SQL_TARANTOOL_ERROR || diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index 483fced50..bda7a8af8 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -195,8 +195,9 @@ growOpArray(Vdbe * v, int nOp) p->szOpAlloc = sqlMallocSize(pNew); p->nOpAlloc = p->szOpAlloc / sizeof(Op); v->aOp = pNew; + return 0; } - return (pNew ? 0 : SQL_NOMEM); + return SQL_NOMEM; } #ifdef SQL_DEBUG @@ -1514,11 +1515,9 @@ sqlVdbeList(Vdbe * p) if (apSub[j] == pOp->p4.pProgram) break; } - if (j == nSub - && 0 == sqlVdbeMemGrow(pSub, - nByte, - nSub != - 0)) { + if (j == nSub && + sqlVdbeMemGrow(pSub, nByte, + nSub != 0) == 0) { apSub = (SubProgram **) pSub->z; apSub[nSub++] = pOp->p4.pProgram; pSub->flags |= MEM_Blob; @@ -2234,9 +2233,8 @@ sqlVdbeHalt(Vdbe * p) } /* Check for immediate foreign key violations. */ - if (p->rc == 0) { + if (p->rc == 0) sqlVdbeCheckFk(p, 0); - } /* If the auto-commit flag is set and this is the only active writer * VM, then we do either a commit or rollback of the current transaction. @@ -2350,7 +2348,7 @@ sqlVdbeHalt(Vdbe * p) assert(db->nVdbeActive > 0 || box_txn() || p->anonymous_savepoint == NULL); - return (p->rc == SQL_BUSY ? SQL_BUSY : 0); + return p->rc == SQL_BUSY ? SQL_BUSY : 0; } /* diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index df8206eb4..3052bece1 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -1048,15 +1048,11 @@ vdbeMemFromBtreeResize(BtCursor * pCur, /* Cursor pointing at record to retrieve int rc; pMem->flags = MEM_Null; if (0 == (rc = sqlVdbeMemClearAndResize(pMem, amt + 2))) { - rc = sqlCursorPayload(pCur, offset, amt, pMem->z); - if (rc == 0) { - pMem->z[amt] = 0; - pMem->z[amt + 1] = 0; - pMem->flags = MEM_Blob | MEM_Term; - pMem->n = (int)amt; - } else { - sqlVdbeMemRelease(pMem); - } + sqlCursorPayload(pCur, offset, amt, pMem->z); + pMem->z[amt] = 0; + pMem->z[amt + 1] = 0; + pMem->flags = MEM_Blob | MEM_Term; + pMem->n = (int) amt; } return rc; } @@ -1295,9 +1291,8 @@ valueFromFunction(sql * db, /* The database connection */ assert(rc == 0); value_from_function_out: - if (rc != 0) { + if (rc != 0) pVal = 0; - } if (apVal) { for (i = 0; i < nVal; i++) { sqlValueFree(apVal[i]); @@ -1568,9 +1563,8 @@ stat4ValueFromExpr(Parse * pParse, /* Parse context */ if (pVal) { rc = sqlVdbeMemCopy((Mem *) pVal, &v->aVar[iBindVar - 1]); - if (rc == 0) { + if (rc == 0) sql_value_apply_type(pVal, type); - } pVal->db = pParse->db; } } diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c index f7fc8e1cc..646f8fe33 100644 --- a/src/box/sql/vdbesort.c +++ b/src/box/sql/vdbesort.c @@ -688,7 +688,7 @@ vdbePmaReaderSeek(SortSubtask * pTask, /* Task context */ pReadr->pFd = pFile->pFd; rc = vdbeSorterMapFile(pTask, pFile, &pReadr->aMap); - if (rc == 0 && pReadr->aMap == 0) { + if (rc == 0 && pReadr->aMap == NULL) { int pgsz = pTask->pSorter->pgsz; int iBuf = pReadr->iReadOff % pgsz; if (pReadr->aBuffer == 0) { @@ -697,7 +697,7 @@ vdbePmaReaderSeek(SortSubtask * pTask, /* Task context */ rc = SQL_NOMEM; pReadr->nBuffer = pgsz; } - if (rc == 0 && iBuf) { + if (rc == 0 && iBuf != 0) { int nRead = pgsz - iBuf; if ((pReadr->iReadOff + nRead) > pReadr->iEof) { nRead = (int)(pReadr->iEof - pReadr->iReadOff); @@ -742,9 +742,8 @@ vdbePmaReaderNext(PmaReader * pReadr) } } - if (rc == 0) { + if (rc == 0) rc = vdbePmaReadVarint(pReadr, &nRec); - } if (rc == 0) { pReadr->nKey = (int)nRec; rc = vdbePmaReadBlob(pReadr, (int)nRec, &pReadr->aKey); @@ -786,9 +785,8 @@ vdbePmaReaderInit(SortSubtask * pTask, /* Task context */ *pnByte += nByte; } - if (rc == 0) { + if (rc == 0) rc = vdbePmaReaderNext(pReadr); - } return rc; } @@ -1532,9 +1530,8 @@ vdbeSorterListToPMA(SortSubtask * pTask, SorterList * pList) } /* Sort the list */ - if (rc == 0) { + if (rc == 0) rc = vdbeSorterSort(pTask, pList); - } if (rc == 0) { SorterRecord *p; @@ -1556,7 +1553,7 @@ vdbeSorterListToPMA(SortSubtask * pTask, SorterList * pList) } vdbeSorterWorkDebug(pTask, "exit"); - assert(rc != 0 || pList->pList == 0); + assert(rc != 0 || pList->pList == NULL); assert(rc != 0 || pTask->file.iEof == iSz); return rc; } @@ -1642,7 +1639,7 @@ vdbeMergeEngineStep(MergeEngine * pMerger, /* The merge engine to advance to the *pbEof = (pMerger->aReadr[pMerger->aTree[1]].pFd == 0); } - return (rc == 0 ? pTask->pUnpacked->errCode : rc); + return rc == 0 ? pTask->pUnpacked->errCode : rc; } #if SQL_MAX_WORKER_THREADS>0 @@ -1697,7 +1694,7 @@ vdbeSorterFlushPMA(VdbeSorter * pSorter) if (pTask->bDone) { rc = vdbeSorterJoinThread(pTask); } - if (rc != 0 || pTask->pThread == 0) + if (rc != 0 || pTask->pThread == NULL) break; } @@ -1801,7 +1798,7 @@ sqlVdbeSorterWrite(const VdbeCursor * pCsr, /* Sorter cursor */ rc = vdbeSorterFlushPMA(pSorter); pSorter->list.szPMA = 0; pSorter->iMemory = 0; - assert(rc != 0 || pSorter->list.pList == 0); + assert(rc != 0 || pSorter->list.pList == NULL); } } @@ -2627,9 +2624,8 @@ vdbeSorterSetupMerge(VdbeSorter * pSorter) } } - if (rc != 0) { + if (rc != 0) vdbeMergeEngineFree(pMain); - } return rc; } diff --git a/src/box/sql/where.c b/src/box/sql/where.c index 4d1759e53..c3a2cc623 100644 --- a/src/box/sql/where.c +++ b/src/box/sql/where.c @@ -1206,7 +1206,7 @@ whereRangeSkipScanEst(Parse * pParse, /* Parsing & code generating context */ type, &p1); nLower = 0; } - if (pUpper && rc == 0) { + if (pUpper != NULL && rc == 0) { rc = sqlStat4ValueFromExpr(pParse, pUpper->pExpr->pRight, type, &p2); nUpper = p2 ? 0 : index->def->opts.stat->sample_count; @@ -1220,12 +1220,12 @@ whereRangeSkipScanEst(Parse * pParse, /* Parsing & code generating context */ for (i = 0; rc == 0 && i < (int) sample_count; i++) { rc = sql_stat4_column(db, samples[i].sample_key, nEq, &pVal); - if (rc == 0 && p1) { + if (rc == 0 && p1 != NULL) { int res = sqlMemCompare(p1, pVal, coll); if (res >= 0) nLower++; } - if (rc == 0 && p2) { + if (rc == 0 && p2 != NULL) { int res = sqlMemCompare(p2, pVal, coll); if (res >= 0) nUpper++; @@ -1399,7 +1399,7 @@ whereRangeScanEst(Parse * pParse, /* Parsing & code generating context */ rc = sqlStat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n); - if (rc == 0 && n) { + if (rc == 0 && n != 0) { tRowcnt iNew; u16 mask = WO_GT | WO_LE; if (sqlExprVectorSize(pExpr) > n) @@ -1425,7 +1425,7 @@ whereRangeScanEst(Parse * pParse, /* Parsing & code generating context */ rc = sqlStat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n); - if (rc == 0 && n) { + if (rc == 0 && n != 0) { tRowcnt iNew; u16 mask = WO_GT | WO_LE; if (sqlExprVectorSize(pExpr) > n) @@ -2370,7 +2370,7 @@ whereLoopAddBtreeIndex(WhereLoopBuilder * pBuilder, /* The WhereLoop factory */ pNew->rSetup = 0; rSize = index_field_tuple_est(probe, 0); rLogSize = estLog(rSize); - for (; rc == 0 && pTerm != 0; pTerm = whereScanNext(&scan)) { + for (; rc == 0 && pTerm != NULL; pTerm = whereScanNext(&scan)) { u16 eOp = pTerm->eOperator; /* Shorthand for pTerm->eOperator */ LogEst rCostIdx; LogEst nOutUnadjusted; /* nOut before IN() and WHERE adjustments */ @@ -3115,9 +3115,8 @@ whereLoopAddAll(WhereLoopBuilder * pBuilder) { rc = whereLoopAddBtree(pBuilder, mPrereq); } - if (rc == 0) { + if (rc == 0) rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable); - } mPrior |= pNew->maskSelf; if (rc || db->mallocFailed) break;