Lines Matching refs:rc
17991 int rc; /* Return code from execution */ member
18300 int rc; /* Result code stored here */ member
20322 int rc; /* Value to return */ member
20695 int rc; in sqlite3_status() local
20699 rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag); in sqlite3_status()
20700 if( rc==0 ){ in sqlite3_status()
20704 return rc; in sqlite3_status()
20739 int rc = SQLITE_OK; /* Return code */ in sqlite3_db_status() local
20909 rc = SQLITE_ERROR; in sqlite3_db_status()
20913 return rc; in sqlite3_db_status()
21431 int rc; in osLocaltime() local
21444 rc = pX==0; in osLocaltime()
21450 rc = localtime_r(t, pTm)==0; in osLocaltime()
21452 rc = localtime_s(pTm, t); in osLocaltime()
21455 return rc; in osLocaltime()
21579 int rc = 1; in parseModifier() local
21591 p->iJD += localtimeOffset(p, pCtx, &rc); in parseModifier()
21611 rc = 0; in parseModifier()
21619 c1 = localtimeOffset(p, pCtx, &rc); in parseModifier()
21620 if( rc==SQLITE_OK ){ in parseModifier()
21623 p->iJD += c1 - localtimeOffset(p, pCtx, &rc); in parseModifier()
21627 rc = SQLITE_OK; in parseModifier()
21653 rc = 0; in parseModifier()
21676 rc = 0; in parseModifier()
21680 rc = 0; in parseModifier()
21682 rc = 0; in parseModifier()
21702 rc = 1; in parseModifier()
21725 rc = 0; in parseModifier()
21737 rc = 1; in parseModifier()
21767 rc = 0; in parseModifier()
21778 return rc; in parseModifier()
22381 int rc; in sqlite3OsOpen() local
22387 rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); in sqlite3OsOpen()
22388 assert( rc==SQLITE_OK || pFile->pMethods==0 ); in sqlite3OsOpen()
22389 return rc; in sqlite3OsOpen()
22439 int rc; in sqlite3OsCurrentTimeInt64() local
22447 rc = pVfs->xCurrentTimeInt64(pVfs, pTimeOut); in sqlite3OsCurrentTimeInt64()
22450 rc = pVfs->xCurrentTime(pVfs, &r); in sqlite3OsCurrentTimeInt64()
22453 return rc; in sqlite3OsCurrentTimeInt64()
22463 int rc; in sqlite3OsOpenMalloc() local
22467 rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags); in sqlite3OsOpenMalloc()
22468 if( rc!=SQLITE_OK ){ in sqlite3OsOpenMalloc()
22474 rc = SQLITE_NOMEM_BKPT; in sqlite3OsOpenMalloc()
22476 return rc; in sqlite3OsOpenMalloc()
22513 int rc = sqlite3_initialize(); in sqlite3_vfs_find() local
22514 if( rc ) return 0; in sqlite3_vfs_find()
22556 int rc = sqlite3_initialize(); in sqlite3_vfs_register()
22557 if( rc ) return rc; in sqlite3_vfs_register()
22584 int rc = sqlite3_initialize(); in sqlite3_vfs_unregister()
22585 if( rc ) return rc; in sqlite3_vfs_unregister()
23441 int rc = 1; in sqlite3MemdebugHasType() local
23447 rc = 0; in sqlite3MemdebugHasType()
23450 return rc; in sqlite3MemdebugHasType()
23463 int rc = 1; in sqlite3MemdebugNoType() local
23469 rc = 0; in sqlite3MemdebugNoType()
23472 return rc; in sqlite3MemdebugNoType()
25061 int rc = SQLITE_OK; in sqlite3MutexInit() local
25092 rc = sqlite3GlobalConfig.mutex.xMutexInit(); in sqlite3MutexInit()
25098 return rc; in sqlite3MutexInit()
25106 int rc = SQLITE_OK; in sqlite3MutexEnd() local
25108 rc = sqlite3GlobalConfig.mutex.xMutexEnd(); in sqlite3MutexEnd()
25115 return rc; in sqlite3MutexEnd()
25165 int rc = SQLITE_OK; in sqlite3_mutex_try() local
25170 return rc; in sqlite3_mutex_try()
25716 int rc; in pthreadMutexTry() local
25734 rc = SQLITE_OK; in pthreadMutexTry()
25739 rc = SQLITE_OK; in pthreadMutexTry()
25741 rc = SQLITE_BUSY; in pthreadMutexTry()
25752 rc = SQLITE_OK; in pthreadMutexTry()
25754 rc = SQLITE_BUSY; in pthreadMutexTry()
25759 if( rc==SQLITE_OK && p->trace ){ in pthreadMutexTry()
25763 return rc; in pthreadMutexTry()
26420 int rc = SQLITE_BUSY;
26446 rc = SQLITE_OK;
26454 tid, p->id, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));
26457 return rc;
26596 int rc = sqlite3_initialize();
26597 if( rc ) return -1;
26622 int rc;
26633 rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
26634 if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
26635 return rc;
27176 db->pParse->rc = SQLITE_NOMEM_BKPT;
27218 SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){
27225 if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){
27228 return rc & db->errMask;
29440 int rc;
29458 rc = 1;
29460 rc = pthread_create(&p->tid, 0, xTask, pIn);
29462 if( rc ){
29472 int rc;
29478 rc = SQLITE_OK;
29480 rc = pthread_join(p->tid, ppOut) ? SQLITE_ERROR : SQLITE_OK;
29483 return rc;
29568 DWORD rc;
29575 rc = WAIT_OBJECT_0;
29579 rc = sqlite3Win32Wait((HANDLE)p->tid);
29580 assert( rc!=WAIT_IO_COMPLETION );
29584 if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;
29586 return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
29890 int rc;
29891 rc = sqlite3VdbeMemMakeWriteable(pMem);
29892 if( rc!=SQLITE_OK ){
29893 assert( rc==SQLITE_NOMEM );
30008 int rc = SQLITE_OK;
30024 rc = sqlite3VdbeMemMakeWriteable(pMem);
30025 if( rc==SQLITE_OK ){
30034 return rc;
30263 int rc; /* The value return */
30293 rc = (y!=z);
30295 rc = isnan(x);
30297 testcase( rc );
30298 return rc;
30352 SQLITE_PRIVATE void sqlite3SystemError(sqlite3 *db, int rc){
30353 if( rc==SQLITE_IOERR_NOMEM ) return;
30354 rc &= 0xff;
30355 if( rc==SQLITE_CANTOPEN || rc==SQLITE_IOERR ){
30427 pParse->rc = SQLITE_ERROR;
30439 pParse->rc = errCode;
30834 int rc; /* Baseline return code */
30876 rc = 0;
30880 rc = 1;
30885 rc = 1; /* Extra non-space text after the integer */
30894 return rc;
30901 return rc;
30911 return neg ? rc : 3;
33070 int rc = SQLITE_NOTFOUND;
33077 rc = SQLITE_OK;
33092 rc = SQLITE_OK;
33099 return rc;
33331 int rc;
33338 rc = SQLITE_OK;
33341 do{ rc = osFtruncate(h,sz); }while( rc<0 && errno==EINTR );
33342 return rc;
33857 int rc; /* System call return code */
33869 rc = osFstat(fd, &statbuf);
33870 if( rc!=0 ){
33890 do{ rc = osWrite(fd, "S", 1); }while( rc<0 && errno==EINTR );
33891 if( rc!=1 ){
33895 rc = osFstat(fd, &statbuf);
33896 if( rc!=0 ){
33968 int rc;
33973 rc = osFstat(pFile->h, &buf);
33974 if( rc!=0 ){
34000 int rc = SQLITE_OK;
34025 rc = SQLITE_IOERR_CHECKRESERVEDLOCK;
34034 OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved));
34037 return rc;
34061 int rc = osFcntl(h,F_SETLK,pLock);
34062 while( rc<0 && pFile->iBusyTimeout>0 ){
34069 rc = osFcntl(h,F_SETLK,pLock);
34072 return rc;
34097 int rc;
34109 rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile);
34110 if( rc<0 ) return rc;
34114 rc = 0;
34117 rc = osSetPosixAdvisoryLock(pFile->h, pLock, pFile);
34119 return rc;
34186 int rc = SQLITE_OK;
34228 rc = SQLITE_BUSY;
34261 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
34262 if( rc!=SQLITE_BUSY ){
34276 assert( rc==SQLITE_OK );
34283 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
34290 if( unixFileLock(pFile, &lock) && rc==SQLITE_OK ){
34293 rc = SQLITE_IOERR_UNLOCK;
34296 if( rc ){
34297 if( rc!=SQLITE_BUSY ){
34309 rc = SQLITE_BUSY;
34329 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
34330 if( rc!=SQLITE_BUSY ){
34343 if( rc==SQLITE_OK
34354 if( rc==SQLITE_OK ){
34365 rc==SQLITE_OK ? "ok" : "failed"));
34366 return rc;
34400 int rc = SQLITE_OK;
34454 rc = SQLITE_IOERR_UNLOCK;
34464 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_RDLOCK);
34465 if( IS_LOCK_ERROR(rc) ){
34476 rc = SQLITE_IOERR_UNLOCK;
34494 rc = SQLITE_IOERR_RDLOCK;
34507 rc = SQLITE_IOERR_UNLOCK;
34525 rc = SQLITE_IOERR_UNLOCK;
34543 if( rc==SQLITE_OK ){
34546 return rc;
34614 int rc = SQLITE_OK;
34639 rc = closeUnixFile(id);
34641 return rc;
34727 int rc = SQLITE_OK;
34735 OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved));
34737 return rc;
34770 int rc = SQLITE_OK;
34788 rc = osMkdir(zLockFile, 0777);
34789 if( rc<0 ){
34793 rc = SQLITE_BUSY;
34795 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
34796 if( rc!=SQLITE_BUSY ){
34800 return rc;
34805 return rc;
34820 int rc;
34842 rc = osRmdir(zLockFile);
34843 if( rc<0 ){
34846 rc = SQLITE_OK;
34848 rc = SQLITE_IOERR_UNLOCK;
34851 return rc;
34891 int rc;
34892 do{ rc = flock(fd,op); }while( rc<0 && errno==EINTR );
34893 return rc;
34907 int rc = SQLITE_OK;
34932 rc = lrc;
34941 rc = lrc;
34945 OSTRACE(("TEST WR-LOCK %d %d %d (flock)\n", pFile->h, rc, reserved));
34948 if( (rc & 0xff) == SQLITE_IOERR ){
34949 rc = SQLITE_OK;
34954 return rc;
34987 int rc = SQLITE_OK;
35004 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
35005 if( IS_LOCK_ERROR(rc) ){
35013 rc==SQLITE_OK ? "ok" : "failed"));
35015 if( (rc & 0xff) == SQLITE_IOERR ){
35016 rc = SQLITE_BUSY;
35019 return rc;
35094 int rc = SQLITE_OK;
35114 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);
35125 OSTRACE(("TEST WR-LOCK %d %d %d (sem)\n", pFile->h, rc, reserved));
35128 return rc;
35163 int rc = SQLITE_OK;
35169 rc = SQLITE_OK;
35175 rc = SQLITE_BUSY;
35183 return rc;
35216 int rc, tErrno = errno;
35217 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
35218 if( IS_LOCK_ERROR(rc) ){
35221 return rc;
35311 int rc;
35316 rc = SQLITE_BUSY;
35318 rc = sqliteErrorFromPosixError(tErrno,
35321 if( IS_LOCK_ERROR(rc) ){
35324 return rc;
35337 int rc = SQLITE_OK;
35370 rc=lrc;
35375 OSTRACE(("TEST WR-LOCK %d %d %d (afp)\n", pFile->h, rc, reserved));
35378 return rc;
35406 int rc = SQLITE_OK;
35446 rc = SQLITE_BUSY;
35475 rc = failed;
35505 rc = lrc1;
35508 rc = lrc2;
35511 rc = lrc1;
35520 rc = SQLITE_BUSY;
35552 rc = ((failed & 0xff) == SQLITE_IOERR) ? failed2 :
35557 rc = failed;
35561 rc = failed;
35565 if( rc==SQLITE_OK ){
35576 rc==SQLITE_OK ? "ok" : "failed"));
35577 return rc;
35588 int rc = SQLITE_OK;
35631 rc = afpSetLock(context->dbPath, pFile, SHARED_FIRST, SHARED_SIZE, 0);
35632 if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1) ){
35635 rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 1);
35640 if( rc==SQLITE_OK && pFile->eFileLock>=PENDING_LOCK ){
35641 rc = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);
35643 if( rc==SQLITE_OK && pFile->eFileLock>=RESERVED_LOCK && context->reserved ){
35644 rc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);
35645 if( !rc ){
35649 if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1)){
35653 if( rc==SQLITE_OK && eFileLock==NO_LOCK ){
35666 rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0);
35668 if( !rc ){
35673 if( rc==SQLITE_OK ){
35681 if( rc==SQLITE_OK ){
35684 return rc;
35691 int rc = SQLITE_OK;
35712 rc = closeUnixFile(id);
35714 return rc;
35889 int rc = 0; /* Value returned by system call */
35898 do{ rc = (int)osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );
35900 do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
35906 rc = -1;
35909 rc = osWrite(fd, pBuf, nBuf);
35910 }while( rc<0 && errno==EINTR );
35914 OSTRACE(("WRITE %-3d %5d %7lld %llu\n", fd, rc, iOff, TIMER_ELAPSED));
35916 if( rc<0 ) *piErrno = errno;
35917 return rc;
35967 int rc;
35970 rc = seekAndRead(pFile, 24, oldCntr, 4);
35972 if( rc!=4 || memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){
36073 int rc;
36107 rc = osFstat(fd, &buf);
36111 rc = osFcntl(fd, F_FULLFSYNC, 0);
36113 rc = 1;
36123 if( rc ) rc = fsync(fd);
36129 rc = fsync(fd);
36131 rc = fdatasync(fd);
36133 if( rc==-1 && errno==ENOTSUP ){
36134 rc = fsync(fd);
36139 if( OS_VXWORKS && rc!= -1 ){
36140 rc = 0;
36142 return rc;
36206 int rc;
36224 rc = full_fsync(pFile->h, isFullsync, isDataOnly);
36225 SimulateIOError( rc=1 );
36226 if( rc ){
36239 rc = osOpenDirectory(pFile->zPath, &dirfd);
36240 if( rc==SQLITE_OK ){
36244 assert( rc==SQLITE_CANTOPEN );
36245 rc = SQLITE_OK;
36249 return rc;
36257 int rc;
36270 rc = robust_ftruncate(pFile->h, nByte);
36271 if( rc ){
36306 int rc;
36309 rc = osFstat(((unixFile*)id)->h, &buf);
36310 SimulateIOError( rc=1 );
36311 if( rc!=0 ){
36390 int rc;
36398 rc = unixMapfile(pFile, nByte);
36399 return rc;
36433 int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE);
36434 return rc ? SQLITE_IOERR_BEGIN_ATOMIC : SQLITE_OK;
36437 int rc = osIoctl(pFile->h, F2FS_IOC_COMMIT_ATOMIC_WRITE);
36438 return rc ? SQLITE_IOERR_COMMIT_ATOMIC : SQLITE_OK;
36441 int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE);
36442 return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK;
36459 int rc;
36461 rc = fcntlSizeHint(pFile, *(i64 *)pArg);
36463 return rc;
36498 int rc = SQLITE_OK;
36515 rc = unixMapfile(pFile, -1);
36518 return rc;
36796 int rc = SQLITE_OK; /* Result code form fcntl() */
36815 rc = osSetPosixAdvisoryLock(pShmNode->hShm, &f, pFile);
36816 rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
36824 if( rc==SQLITE_OK ){
36854 return rc;
36916 int rc = SQLITE_OK;
36941 rc = SQLITE_IOERR_LOCK;
36945 rc = SQLITE_READONLY_CANTINIT;
36947 rc = unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1);
36953 if( rc==SQLITE_OK && robust_ftruncate(pShmNode->hShm, 3) ){
36954 rc = unixLogError(SQLITE_IOERR_SHMOPEN,"ftruncate",pShmNode->zFilename);
36958 rc = SQLITE_BUSY;
36961 if( rc==SQLITE_OK ){
36963 rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);
36965 return rc;
37006 int rc = SQLITE_OK; /* Result code */
37035 rc = SQLITE_IOERR_FSTAT;
37046 rc = SQLITE_NOMEM_BKPT;
37065 rc = SQLITE_NOMEM_BKPT;
37077 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm);
37089 rc = unixLockSharedMemory(pDbFd, pShmNode);
37090 if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;
37114 return rc;
37121 return rc;
37153 int rc = SQLITE_OK;
37159 rc = unixOpenSharedMemory(pDbFd);
37160 if( rc!=SQLITE_OK ) return rc;
37167 rc = unixLockSharedMemory(pDbFd, pShmNode);
37168 if( rc!=SQLITE_OK ) goto shmpage_out;
37192 rc = SQLITE_IOERR_SHMSIZE;
37221 rc = unixLogError(SQLITE_IOERR_SHMSIZE, "write", zFile);
37234 rc = SQLITE_IOERR_NOMEM_BKPT;
37248 rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
37254 rc = SQLITE_NOMEM_BKPT;
37273 if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;
37275 return rc;
37296 int rc = SQLITE_OK; /* Result code */
37326 rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);
37328 rc = SQLITE_OK;
37332 if( rc==SQLITE_OK ){
37345 rc = SQLITE_BUSY;
37352 if( rc==SQLITE_OK ){
37354 rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);
37356 rc = SQLITE_OK;
37361 if( rc==SQLITE_OK ){
37370 rc = SQLITE_BUSY;
37378 if( rc==SQLITE_OK ){
37379 rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);
37380 if( rc==SQLITE_OK ){
37389 return rc;
37637 int rc = unixMapfile(pFd, -1);
37638 if( rc!=SQLITE_OK ) return rc;
37998 int rc = SQLITE_OK;
38025 rc = SQLITE_NOMEM_BKPT;
38047 rc = findInodeInfo(pNew, &pNew->pInode);
38048 if( rc!=SQLITE_OK ){
38081 rc = SQLITE_NOMEM_BKPT;
38090 rc = findInodeInfo(pNew, &pNew->pInode);
38091 if( rc!=SQLITE_OK ){
38111 rc = SQLITE_NOMEM_BKPT;
38124 rc = findInodeInfo(pNew, &pNew->pInode);
38125 if( (rc==SQLITE_OK) && (pNew->pInode->pSem==NULL) ){
38134 rc = SQLITE_NOMEM_BKPT;
38144 if( rc!=SQLITE_OK ){
38151 if( rc!=SQLITE_OK ){
38158 return rc;
38305 int rc = SQLITE_OK;
38311 rc = SQLITE_IOERR_FSTAT;
38313 return rc;
38344 int rc = SQLITE_OK; /* Return Code */
38376 rc = getFileMode(zDb, pMode, pUid, pGid);
38386 rc = getFileMode(z, pMode, pUid, pGid);
38389 return rc;
38426 int rc = SQLITE_OK; /* Function Return Code */
38515 rc = unixGetTempname(pVfs->mxPathname, zTmpname);
38516 if( rc!=SQLITE_OK ){
38517 return rc;
38540 rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid);
38541 if( rc!=SQLITE_OK ){
38544 return rc;
38553 rc = SQLITE_READONLY_DIRECTORY;
38566 if( rc==SQLITE_OK ) rc = rc2;
38645 rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
38646 if( rc==SQLITE_OK ){
38647 rc = proxyTransformUnixFile((unixFile*)pFile, ":auto:");
38648 if( rc!=SQLITE_OK ){
38654 return rc;
38665 rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
38668 if( rc!=SQLITE_OK ){
38671 return rc;
38684 int rc = SQLITE_OK;
38693 rc = SQLITE_IOERR_DELETE_NOENT;
38695 rc = unixLogError(SQLITE_IOERR_DELETE, "unlink", zPath);
38697 return rc;
38702 rc = osOpenDirectory(zPath, &fd);
38703 if( rc==SQLITE_OK ){
38705 rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, "fsync", zPath);
38709 assert( rc==SQLITE_CANTOPEN );
38710 rc = SQLITE_OK;
38714 return rc;
38795 int rc = SQLITE_OK;
38819 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "lstat", zIn);
38828 if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;
38830 rc = SQLITE_CANTOPEN_BKPT;
38833 if( rc==SQLITE_OK ){
38836 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "readlink", zIn);
38842 rc = SQLITE_CANTOPEN_BKPT;
38856 assert( rc!=SQLITE_OK || zIn!=zOut || zIn[0]=='/' );
38857 if( rc==SQLITE_OK && zIn!=zOut ){
38858 rc = mkFullPathname(zIn, zOut, nOut);
38862 }while( rc==SQLITE_OK );
38865 return rc;
39024 int rc = SQLITE_OK;
39045 return rc;
39056 int rc;
39058 rc = unixCurrentTimeInt64(0, &i);
39060 return rc;
39349 int rc = SQLITE_OK;
39400 rc = SQLITE_NOMEM_BKPT;
39412 rc = fillInUnixFile(&dummyVfs, fd, (sqlite3_file*)pNew, path, 0);
39413 if( rc==SQLITE_OK ){
39421 return rc;
39489 int rc = -1;
39519 rc = 0;
39526 if( rc ){
39533 return rc;
39542 int rc = SQLITE_OK;
39548 rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);
39550 if( rc==SQLITE_BUSY ){
39597 rc = SQLITE_OK;
39599 rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);
39601 if( !rc ){
39602 rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);
39606 } while( rc==SQLITE_BUSY && nTries<3 );
39608 return rc;
39629 int rc = SQLITE_OK;
39640 rc = proxyGetHostID(myHostID, &pError);
39641 if( (rc&0xff)==SQLITE_IOERR ){
39645 rc = proxyConchLock(pFile, myHostID, SHARED_LOCK);
39646 if( rc!=SQLITE_OK ){
39654 rc = SQLITE_IOERR_READ;
39701 rc = SQLITE_BUSY;
39721 rc = SQLITE_BUSY;
39723 rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);
39726 rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);
39728 if( rc==SQLITE_OK ){
39742 rc = unixWrite((sqlite3_file *)conchFile, writeBuffer, writeSize, 0);
39747 if( rc==SQLITE_OK && createConch ){
39758 rc = osFchmod(conchFile->h, cmode);
39759 }while( rc==(-1) && errno==EINTR );
39760 if( rc!=0 ){
39779 if( rc==SQLITE_OK && pFile->openFlags ){
39790 rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called
39794 if( rc==SQLITE_OK && !pCtx->lockProxy ){
39796 rc = proxyCreateUnixFile(path, &pCtx->lockProxy, 1);
39797 if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM && tryOldLockPath ){
39806 if( rc==SQLITE_OK ){
39813 rc = SQLITE_NOMEM_BKPT;
39817 if( rc==SQLITE_OK ){
39829 rc==SQLITE_OK?"ok":"failed"));
39830 return rc;
39840 int rc = SQLITE_OK; /* Subroutine return code */
39850 rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
39854 (rc==SQLITE_OK ? "ok" : "failed")));
39855 return rc;
39909 int rc = SQLITE_OK;
39924 rc=lockProxy->pMethod->xClose((sqlite3_file *)lockProxy);
39925 if( rc ) return rc;
39932 return rc;
39977 int rc = SQLITE_OK;
39998 rc = proxyCreateConchPathname(dbPath, &pCtx->conchFilePath);
39999 if( rc==SQLITE_OK ){
40000 rc = proxyCreateUnixFile(pCtx->conchFilePath, &pCtx->conchFile, 0);
40001 if( rc==SQLITE_CANTOPEN && ((pFile->openFlags&O_RDWR) == 0) ){
40019 rc = SQLITE_OK;
40023 if( rc==SQLITE_OK && lockPath ){
40027 if( rc==SQLITE_OK ){
40030 rc = SQLITE_NOMEM_BKPT;
40033 if( rc==SQLITE_OK ){
40051 (rc==SQLITE_OK ? "ok" : "failed")));
40052 return rc;
40079 int rc = SQLITE_OK;
40087 rc = SQLITE_ERROR /*SQLITE_PROTOCOL? SQLITE_MISUSE?*/;
40090 rc = SQLITE_OK;
40101 rc = SQLITE_OK;
40103 rc = switchLockProxyPath(pFile, proxyPath);
40107 rc = proxyTransformUnixFile(pFile, proxyPath);
40110 return rc;
40135 int rc = proxyTakeConch(pFile);
40136 if( rc==SQLITE_OK ){
40145 return rc;
40174 int rc = proxyTakeConch(pFile);
40175 if( rc==SQLITE_OK ){
40179 rc = proxy->pMethod->xLock((sqlite3_file*)proxy, eFileLock);
40185 return rc;
40198 int rc = proxyTakeConch(pFile);
40199 if( rc==SQLITE_OK ){
40203 rc = proxy->pMethod->xUnlock((sqlite3_file*)proxy, eFileLock);
40209 return rc;
40221 int rc = SQLITE_OK;
40224 rc = lockProxy->pMethod->xUnlock((sqlite3_file*)lockProxy, NO_LOCK);
40225 if( rc ) return rc;
40226 rc = lockProxy->pMethod->xClose((sqlite3_file*)lockProxy);
40227 if( rc ) return rc;
40233 rc = proxyReleaseConch(pFile);
40234 if( rc ) return rc;
40236 rc = conchFile->pMethod->xClose((sqlite3_file*)conchFile);
40237 if( rc ) return rc;
41755 int rc = SQLITE_NOTFOUND;
41762 rc = SQLITE_OK;
41777 rc = SQLITE_OK;
41784 return rc;
41835 int rc = SQLITE_OK;
41852 rc = SQLITE_NOMEM_BKPT;
41856 rc = SQLITE_ERROR;
41862 rc = SQLITE_NOTFOUND;
41865 return rc;
41875 int rc;
41898 rc = winMemInit(winMemGetDataPtr());
41899 assert( rc!=SQLITE_OK || winMemGetHeap()!=NULL );
41900 assert( rc!=SQLITE_OK || winMemGetOwned() );
41901 assert( rc!=SQLITE_OK || sqlite3_memory_used()==0 );
41906 rc = SQLITE_BUSY;
41910 return rc;
41981 DWORD rc;
41982 while( (rc = osWaitForSingleObjectEx(hObject, INFINITE,
41984 return rc;
42505 int rc = sqlite3_initialize();
42506 if( rc ) return rc;
42540 int rc;
42546 rc = sqlite3_win32_set_directory8(type, zUtf8);
42548 return rc;
43241 int rc, cnt = 0;
43257 rc = osCloseHandle(pFile->h);
43259 }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );
43280 if( rc ){
43285 osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
43286 return rc ? SQLITE_OK
43382 int rc = 0; /* True if error has occurred, else false */
43415 rc = winSeekFile(pFile, offset);
43416 if( rc==0 ){
43458 rc = 1;
43462 if( rc ){
43487 int rc = SQLITE_OK; /* Return code for this function */
43538 rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
43543 rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
43548 if( rc==SQLITE_OK && oldMmapSize>0 ){
43558 osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
43559 return rc;
43579 BOOL rc;
43640 rc = osFlushFileBuffers(pFile->h);
43641 SimulateIOError( rc=FALSE );
43642 if( rc ){
43661 int rc = SQLITE_OK;
43676 rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
43691 rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
43697 pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
43698 return rc;
43820 int rc = SQLITE_OK; /* Return code from subroutines */
43874 rc = SQLITE_IOERR_LOCK;
43876 pFile->h, cnt, sqlite3ErrName(rc)));
43877 return rc;
43944 rc = SQLITE_OK;
43947 rc = SQLITE_BUSY;
43953 pFile->h, pFile->locktype, sqlite3ErrName(rc)));
43954 return rc;
44001 int rc = SQLITE_OK;
44012 rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),
44027 pFile->h, pFile->locktype, sqlite3ErrName(rc)));
44028 return rc;
44115 int rc = winFileSize(id, &oldSz);
44116 if( rc==SQLITE_OK ){
44120 rc = winTruncate(id, newSz);
44124 OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
44125 return rc;
44179 int rc = winGetTempname(pFile->pVfs, &zTFile);
44180 if( rc==SQLITE_OK ){
44183 OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
44184 return rc;
44189 int rc = SQLITE_OK;
44206 rc = winMapfile(pFile, -1);
44209 OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
44210 return rc;
44374 int rc = 0; /* Result code form Lock/UnlockFileEx() */
44384 rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
44389 rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
44392 if( rc!= 0 ){
44393 rc = SQLITE_OK;
44396 rc = SQLITE_BUSY;
44401 "winLockFile", pFile->lastErrno, sqlite3ErrName(rc)));
44403 return rc;
44468 int rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1);
44470 if( rc==SQLITE_OK ){
44482 if( rc==SQLITE_OK ){
44499 int rc = SQLITE_OK; /* Result code */
44545 rc = SQLITE_IOERR_NOMEM_BKPT;
44555 rc = winOpen(pDbFd->pVfs, pShmNode->zFilename,
44558 if( rc!=SQLITE_OK ){
44559 rc = winLogError(rc, osGetLastError(), "winOpenShm",
44565 rc = winLockSharedMemory(pShmNode);
44566 if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;
44589 return rc;
44598 return rc;
44656 int rc = SQLITE_OK; /* Result code */
44682 rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);
44684 rc = SQLITE_OK;
44688 if( rc==SQLITE_OK ){
44701 rc = SQLITE_BUSY;
44708 if( rc==SQLITE_OK ){
44710 rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);
44712 rc = SQLITE_OK;
44717 if( rc==SQLITE_OK ){
44726 rc = SQLITE_BUSY;
44734 if( rc==SQLITE_OK ){
44735 rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);
44736 if( rc==SQLITE_OK ){
44745 sqlite3ErrName(rc)));
44746 return rc;
44795 int rc = SQLITE_OK;
44798 rc = winOpenSharedMemory(pDbFd);
44799 if( rc!=SQLITE_OK ) return rc;
44806 rc = winLockSharedMemory(pShmNode);
44807 if( rc!=SQLITE_OK ) goto shmpage_out;
44823 rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
44824 if( rc!=SQLITE_OK ){
44825 rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
44838 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
44839 if( rc!=SQLITE_OK ){
44840 rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
44851 rc = SQLITE_IOERR_NOMEM_BKPT;
44899 rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,
44920 if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;
44922 return rc;
44987 int rc;
44996 rc = winFileSize((sqlite3_file*)pFd, &nMap);
44997 if( rc ){
45036 rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
45040 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
45054 rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
45058 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
45095 int rc = winMapfile(pFd, -1);
45096 if( rc!=SQLITE_OK ){
45098 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
45099 return rc;
45533 int rc = 0;
45540 while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,
45543 if( !rc ){
45593 int rc = SQLITE_OK; /* Function Return Code */
45657 rc = winGetTempname(pVfs, &zTmpname);
45658 if( rc!=SQLITE_OK ){
45659 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
45660 return rc;
45831 && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
45836 OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
45837 return rc;
45868 return rc;
45889 int rc;
45916 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
45918 rc = SQLITE_ERROR;
45929 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
45931 rc = SQLITE_ERROR;
45936 rc = SQLITE_ERROR; /* Files only. */
45940 rc = SQLITE_OK; /* Deleted OK. */
45944 rc = SQLITE_ERROR; /* No more retries. */
45957 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
45959 rc = SQLITE_ERROR;
45964 rc = SQLITE_ERROR; /* Files only. */
45968 rc = SQLITE_OK; /* Deleted OK. */
45972 rc = SQLITE_ERROR; /* No more retries. */
45978 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
45979 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
45984 OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
45985 return rc;
45998 int rc = 0;
46016 while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,
46019 if( rc ){
46050 rc = attr!=INVALID_FILE_ATTRIBUTES;
46053 rc = attr!=INVALID_FILE_ATTRIBUTES &&
46059 *pResOut = rc;
46517 int rc;
46519 rc = winCurrentTimeInt64(pVfs, &i);
46520 if( !rc ){
46523 return rc;
46907 int rc;
46909 && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK
46911 return rc;
46979 int rc = SQLITE_NOTFOUND;
46982 rc = SQLITE_OK;
46995 rc = SQLITE_OK;
46997 return rc;
47177 int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p);
47178 if( rc ) return 0;
47200 int rc;
47228 rc = zSql ? sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0) : SQLITE_NOMEM;
47230 if( rc ) return 0;
47231 rc = sqlite3_step(pStmt);
47232 if( rc!=SQLITE_ROW ){
47248 rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pPage, 0);
47249 if( rc==SQLITE_OK ){
47276 int rc;
47291 rc = SQLITE_ERROR;
47295 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
47297 if( rc ) goto end_deserialize;
47300 rc = sqlite3_step(pStmt);
47302 if( rc!=SQLITE_DONE ){
47303 rc = SQLITE_ERROR;
47308 rc = SQLITE_ERROR;
47318 rc = SQLITE_OK;
47324 return rc;
47557 int rc;
47565 rc = sqlite3BitvecSet(p, i);
47567 if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]);
47570 return rc;
47685 int rc = -1;
47739 rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)
47744 rc = i;
47754 return rc;
48188 int rc;
48197 rc = pCache->xStress(pCache->pStress, pPg);
48199 if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
48200 return rc;
51424 int rc;
51425 rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
51426 return (rc==SQLITE_OK && iRead==0);
51707 int rc = sqlite3OsRead(fd, ac, sizeof(ac), offset);
51708 if( rc==SQLITE_OK ){
51711 return rc;
51740 int rc = SQLITE_OK;
51747 rc = pPager->noLock ? SQLITE_OK : sqlite3OsUnlock(pPager->fd, eLock);
51753 return rc;
51767 int rc = SQLITE_OK;
51771 rc = pPager->noLock ? SQLITE_OK : sqlite3OsLock(pPager->fd, eLock);
51772 if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){
51777 return rc;
51905 int rc; /* Return code */
51913 if( SQLITE_OK!=(rc = sqlite3OsFileSize(pJrnl, &szJ))
51915 || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-16, &len))
51919 || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-12, &cksum))
51920 || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ-8))
51922 || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len))
51924 return rc;
51993 int rc = SQLITE_OK; /* Return code */
52001 rc = sqlite3OsTruncate(pPager->jfd, 0);
52004 rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);
52006 if( rc==SQLITE_OK && !pPager->noSync ){
52007 rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY|pPager->syncFlags);
52016 if( rc==SQLITE_OK && iLimit>0 ){
52018 rc = sqlite3OsFileSize(pPager->jfd, &sz);
52019 if( rc==SQLITE_OK && sz>iLimit ){
52020 rc = sqlite3OsTruncate(pPager->jfd, iLimit);
52024 return rc;
52043 int rc = SQLITE_OK; /* Return code */
52133 for(nWrite=0; rc==SQLITE_OK&&nWrite<JOURNAL_HDR_SZ(pPager); nWrite+=nHeader){
52135 rc = sqlite3OsWrite(pPager->jfd, zHeader, nHeader, pPager->journalOff);
52140 return rc;
52167 int rc; /* Return code */
52189 rc = sqlite3OsRead(pPager->jfd, aMagic, sizeof(aMagic), iHdrOff);
52190 if( rc ){
52191 return rc;
52202 if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+8, pNRec))
52203 || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+12, &pPager->cksumInit))
52204 || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+16, pDbSize))
52206 return rc;
52214 if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+20, &iSectorSize))
52215 || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+24, &iPageSize))
52217 return rc;
52249 rc = sqlite3PagerSetPagesize(pPager, &iPageSize, -1);
52250 testcase( rc!=SQLITE_OK );
52262 return rc;
52286 int rc; /* Return code */
52321 if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))
52322 || (0 != (rc = sqlite3OsWrite(pPager->jfd, zMaster, nMaster, iHdrOff+4)))
52323 || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster, nMaster)))
52324 || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster+4, cksum)))
52325 || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,
52328 return rc;
52342 if( SQLITE_OK==(rc = sqlite3OsFileSize(pPager->jfd, &jrnlSize))
52345 rc = sqlite3OsTruncate(pPager->jfd, pPager->journalOff);
52347 return rc;
52392 int rc = SQLITE_OK; /* Result code */
52397 rc |= sqlite3BitvecSet(p->pInSavepoint, pgno);
52398 testcase( rc==SQLITE_NOMEM );
52399 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
52402 return rc;
52438 int rc; /* Error code returned by pagerUnlockDb() */
52463 rc = pagerUnlockDb(pPager, NO_LOCK);
52464 if( rc!=SQLITE_OK && pPager->eState==PAGER_ERROR ){
52520 static int pager_error(Pager *pPager, int rc){
52521 int rc2 = rc & 0xff;
52522 assert( rc==SQLITE_OK || !MEMDB );
52529 pPager->errCode = rc;
52533 return rc;
52615 int rc = SQLITE_OK; /* Error code from journal finalization operation */
52650 rc = SQLITE_OK;
52652 rc = sqlite3OsTruncate(pPager->jfd, 0);
52653 if( rc==SQLITE_OK && pPager->fullSync ){
52659 rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);
52666 rc = zeroJournalHdr(pPager, hasMaster||pPager->tempFile);
52682 rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, pPager->extraSync);
52701 if( rc==SQLITE_OK ){
52717 }else if( rc==SQLITE_OK && bCommit && pPager->dbFileSize>pPager->dbSize ){
52725 rc = pager_truncate(pPager, pPager->dbSize);
52728 if( rc==SQLITE_OK && bCommit ){
52729 rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_COMMIT_PHASETWO, 0);
52730 if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
52742 return (rc==SQLITE_OK?rc2:rc);
52879 int rc;
52916 rc = read32bits(jfd, *pOffset, &pgno);
52917 if( rc!=SQLITE_OK ) return rc;
52918 rc = sqlite3OsRead(jfd, (u8*)aData, pPager->pageSize, (*pOffset)+4);
52919 if( rc!=SQLITE_OK ) return rc;
52935 rc = read32bits(jfd, (*pOffset)-4, &cksum);
52936 if( rc ) return rc;
52945 if( pDone && (rc = sqlite3BitvecSet(pDone, pgno))!=SQLITE_OK ){
52946 return rc;
53023 CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData);
53024 rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);
53025 CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);
53028 rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);
53036 CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);
53038 CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData);
53063 rc = sqlite3PagerGet(pPager, pgno, &pPg, 1);
53066 if( rc!=SQLITE_OK ) return rc;
53094 if( jrnlEnc ){ CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); }
53098 return rc;
53146 int rc; /* Return code */
53161 rc = SQLITE_NOMEM_BKPT;
53164 rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0);
53166 if( rc!=SQLITE_OK ) goto delmaster_out;
53173 rc = sqlite3OsFileSize(pMaster, &nMasterJournal);
53174 if( rc!=SQLITE_OK ) goto delmaster_out;
53178 rc = SQLITE_NOMEM_BKPT;
53182 rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);
53183 if( rc!=SQLITE_OK ) goto delmaster_out;
53189 rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
53190 if( rc!=SQLITE_OK ){
53200 rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);
53201 if( rc!=SQLITE_OK ){
53205 rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr);
53207 if( rc!=SQLITE_OK ){
53221 rc = sqlite3OsDelete(pVfs, zMaster, 0);
53230 return rc;
53255 int rc = SQLITE_OK;
53266 rc = sqlite3OsFileSize(pPager->fd, ¤tSize);
53268 if( rc==SQLITE_OK && currentSize!=newSize ){
53270 rc = sqlite3OsTruncate(pPager->fd, newSize);
53276 rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);
53278 if( rc==SQLITE_OK ){
53283 return rc;
53403 int rc; /* Result code of a subroutine */
53414 rc = sqlite3OsFileSize(pPager->jfd, &szJ);
53415 if( rc!=SQLITE_OK ){
53431 rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
53432 if( rc==SQLITE_OK && zMaster[0] ){
53433 rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);
53436 if( rc!=SQLITE_OK || !res ){
53452 rc = readJournalHdr(pPager, isHot, szJ, &nRec, &mxPg);
53453 if( rc!=SQLITE_OK ){
53454 if( rc==SQLITE_DONE ){
53455 rc = SQLITE_OK;
53493 rc = pager_truncate(pPager, mxPg);
53494 if( rc!=SQLITE_OK ){
53508 rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0);
53509 if( rc==SQLITE_OK ){
53512 if( rc==SQLITE_DONE ){
53515 }else if( rc==SQLITE_IOERR_SHORT_READ ){
53521 rc = SQLITE_OK;
53538 if( rc==SQLITE_OK ){
53539 rc = sqlite3PagerSetPagesize(pPager, &savedPageSize, -1);
53561 if( rc==SQLITE_OK ){
53563 rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
53564 testcase( rc!=SQLITE_OK );
53566 if( rc==SQLITE_OK
53569 rc = sqlite3PagerSync(pPager, 0);
53571 if( rc==SQLITE_OK ){
53572 rc = pager_end_transaction(pPager, zMaster[0]!='\0', 0);
53573 testcase( rc!=SQLITE_OK );
53575 if( rc==SQLITE_OK && zMaster[0] && res ){
53579 rc = pager_delmaster(pPager, zMaster);
53580 testcase( rc!=SQLITE_OK );
53592 return rc;
53610 int rc = SQLITE_OK; /* Return code */
53619 rc = sqlite3WalFindFrame(pPager->pWal, pPg->pgno, &iFrame);
53620 if( rc ) return rc;
53623 rc = sqlite3WalReadFrame(pPager->pWal, iFrame,pPager->pageSize,pPg->pData);
53628 rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);
53629 if( rc==SQLITE_IOERR_SHORT_READ ){
53630 rc = SQLITE_OK;
53635 if( rc ){
53654 CODEC1(pPager, pPg->pData, pPg->pgno, 3, rc = SQLITE_NOMEM_BKPT);
53662 return rc;
53701 int rc = SQLITE_OK;
53711 rc = readDbPage(pPg);
53712 if( rc==SQLITE_OK ){
53729 return rc;
53736 int rc; /* Return Code */
53747 rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);
53749 while( pList && rc==SQLITE_OK ){
53751 rc = pagerUndoCallback((void *)pPager, pList->pgno);
53755 return rc;
53773 int rc; /* Return code */
53807 rc = sqlite3WalFrames(pPager->pWal,
53810 if( rc==SQLITE_OK && pPager->pBackup ){
53823 return rc;
53835 int rc; /* Return code */
53848 rc = sqlite3WalBeginReadTransaction(pPager->pWal, &changed);
53849 if( rc!=SQLITE_OK || changed ){
53854 return rc;
53889 int rc = sqlite3OsFileSize(pPager->fd, &n);
53890 if( rc!=SQLITE_OK ){
53891 return rc;
53928 int rc = SQLITE_OK;
53934 rc = sqlite3OsAccess(
53937 if( rc==SQLITE_OK ){
53941 rc = pagerPagecount(pPager, &nPage);
53942 if( rc ) return rc;
53944 rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
53947 rc = sqlite3PagerOpenWal(pPager, 0);
53954 return rc;
53997 int rc = SQLITE_OK; /* Return code */
54039 while( rc==SQLITE_OK && pPager->journalOff<iHdrOff ){
54040 rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);
54042 assert( rc!=SQLITE_DONE );
54052 while( rc==SQLITE_OK && pPager->journalOff<szJ ){
54056 rc = readJournalHdr(pPager, 0, szJ, &nJRec, &dummy);
54057 assert( rc!=SQLITE_DONE );
54069 for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){
54070 rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);
54072 assert( rc!=SQLITE_DONE );
54074 assert( rc!=SQLITE_OK || pPager->journalOff>=szJ );
54085 rc = sqlite3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData);
54087 for(ii=pSavepoint->iSubRec; rc==SQLITE_OK && ii<pPager->nSubRec; ii++){
54089 rc = pager_playback_one_page(pPager, &offset, pDone, 0, 1);
54091 assert( rc!=SQLITE_DONE );
54095 if( rc==SQLITE_OK ){
54099 return rc;
54266 int rc; /* Return code */
54274 rc = sqlite3OsOpen(pPager->pVfs, 0, pFile, vfsFlags, 0);
54275 assert( rc!=SQLITE_OK || isOpen(pFile) );
54276 return rc;
54345 int rc = SQLITE_OK;
54367 rc = sqlite3OsFileSize(pPager->fd, &nByte);
54369 if( rc==SQLITE_OK ){
54374 rc = SQLITE_NOMEM_BKPT;
54380 if( rc==SQLITE_OK ){
54382 rc = sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);
54384 if( rc==SQLITE_OK ){
54395 if( rc==SQLITE_OK ){
54402 return rc;
54475 int rc = SQLITE_OK;
54487 rc = sqlite3OsRead(pPager->fd, pDest, N, 0);
54488 if( rc==SQLITE_IOERR_SHORT_READ ){
54489 rc = SQLITE_OK;
54492 return rc;
54524 int rc; /* Return code */
54537 rc = pagerLockDb(pPager, locktype);
54538 }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );
54539 return rc;
54619 int rc = SQLITE_OK;
54621 rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_NORMAL);
54623 if( rc==SQLITE_OK ){
54624 rc = sqlite3OsFileSize(pPager->jfd, &pPager->journalHdr);
54626 return rc;
54713 int rc;
54718 rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_HAS_MOVED, &bHasMoved);
54719 if( rc==SQLITE_NOTFOUND ){
54723 rc = SQLITE_OK;
54724 }else if( rc==SQLITE_OK && bHasMoved ){
54725 rc = SQLITE_READONLY_DBMOVED;
54727 return rc;
54859 int rc; /* Return code */
54867 rc = sqlite3PagerExclusiveLock(pPager);
54868 if( rc!=SQLITE_OK ) return rc;
54907 rc = sqlite3OsRead(pPager->jfd, aMagic, 8, iNextHdrOffset);
54908 if( rc==SQLITE_OK && 0==memcmp(aMagic, aJournalMagic, 8) ){
54910 rc = sqlite3OsWrite(pPager->jfd, &zerobyte, 1, iNextHdrOffset);
54912 if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
54913 return rc;
54930 rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);
54931 if( rc!=SQLITE_OK ) return rc;
54934 rc = sqlite3OsWrite(
54937 if( rc!=SQLITE_OK ) return rc;
54942 rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags|
54945 if( rc!=SQLITE_OK ) return rc;
54951 rc = writeJournalHdr(pPager);
54952 if( rc!=SQLITE_OK ) return rc;
55002 int rc = SQLITE_OK; /* Return code */
55015 assert( pPager->tempFile && rc==SQLITE_OK );
55016 rc = pagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);
55022 assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
55023 if( rc==SQLITE_OK
55032 while( rc==SQLITE_OK && pList ){
55054 rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize, offset);
55082 return rc;
55094 int rc = SQLITE_OK;
55103 rc = sqlite3JournalOpen(pPager->pVfs, 0, pPager->sjfd, flags, nStmtSpill);
55105 return rc;
55120 int rc = SQLITE_OK;
55132 rc = openSubJournal(pPager);
55136 if( rc==SQLITE_OK ){
55148 rc = write32bits(pPager->sjfd, offset, pPg->pgno);
55149 if( rc==SQLITE_OK ){
55150 rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);
55154 if( rc==SQLITE_OK ){
55157 rc = addToSavepointBitvecs(pPager, pPg->pgno);
55159 return rc;
55190 int rc = SQLITE_OK;
55226 rc = subjournalPageIfRequired(pPg);
55227 if( rc==SQLITE_OK ){
55228 rc = pagerWalFrames(pPager, pPg, 0, 0);
55234 rc = sqlite3JournalCreate(pPager->jfd);
55235 if( rc!=SQLITE_OK ) return pager_error(pPager, rc);
55243 rc = syncJournal(pPager, 1);
55247 if( rc==SQLITE_OK ){
55249 rc = pager_write_pagelist(pPager, pPg);
55254 if( rc==SQLITE_OK ){
55259 return pager_error(pPager, rc);
55266 int rc = pPager->errCode;
55270 while( rc==SQLITE_OK && pList ){
55273 rc = pagerStress((void*)pPager, pList);
55279 return rc;
55325 int rc = SQLITE_OK; /* Return code */
55374 rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
55383 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
55390 rc = SQLITE_CANTOPEN_BKPT;
55392 if( rc!=SQLITE_OK ){
55394 return rc;
55458 rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);
55473 if( rc==SQLITE_OK ){
55528 if( rc==SQLITE_OK ){
55530 rc = sqlite3PagerSetPagesize(pPager, &szPageDflt, -1);
55531 testcase( rc!=SQLITE_OK );
55535 if( rc==SQLITE_OK ){
55538 rc = sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,
55544 if( rc!=SQLITE_OK ){
55548 return rc;
55643 int rc = SQLITE_OK; /* Return code */
55657 rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);
55659 if( rc==SQLITE_OK && exists ){
55670 rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
55671 if( rc==SQLITE_OK && !locked ){
55675 rc = pagerPagecount(pPager, &nPage);
55676 if( rc==SQLITE_OK ){
55701 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);
55703 if( rc==SQLITE_OK ){
55705 rc = sqlite3OsRead(pPager->jfd, (void *)&first, 1, 0);
55706 if( rc==SQLITE_IOERR_SHORT_READ ){
55707 rc = SQLITE_OK;
55713 }else if( rc==SQLITE_CANTOPEN ){
55724 rc = SQLITE_OK;
55731 return rc;
55762 int rc = SQLITE_OK; /* Return code */
55779 rc = pager_wait_on_lock(pPager, SHARED_LOCK);
55780 if( rc!=SQLITE_OK ){
55789 rc = hasHotJournal(pPager, &bHotJournal);
55791 if( rc!=SQLITE_OK ){
55796 rc = SQLITE_READONLY_ROLLBACK;
55815 rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
55816 if( rc!=SQLITE_OK ){
55836 rc = sqlite3OsAccess(
55838 if( rc==SQLITE_OK && bExists ){
55842 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);
55843 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
55844 if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){
55845 rc = SQLITE_CANTOPEN_BKPT;
55860 assert( rc==SQLITE_OK );
55861 rc = pagerSyncHotJournal(pPager);
55862 if( rc==SQLITE_OK ){
55863 rc = pager_playback(pPager, !pPager->tempFile);
55870 if( rc!=SQLITE_OK ){
55887 pager_error(pPager, rc);
55917 rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
55918 if( rc!=SQLITE_OK ){
55919 if( rc!=SQLITE_IOERR_SHORT_READ ){
55943 rc = pagerOpenWalIfPresent(pPager);
55945 assert( pPager->pWal==0 || rc==SQLITE_OK );
55950 assert( rc==SQLITE_OK );
55951 rc = pagerBeginReadTransaction(pPager);
55954 if( pPager->tempFile==0 && pPager->eState==PAGER_OPEN && rc==SQLITE_OK ){
55955 rc = pagerPagecount(pPager, &pPager->dbSize);
55959 if( rc!=SQLITE_OK ){
55967 return rc;
56048 int rc = SQLITE_OK;
56062 rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
56063 if( rc!=SQLITE_OK ) goto pager_acquire_err;
56065 rc = SQLITE_NOMEM_BKPT;
56090 rc = SQLITE_CORRUPT_BKPT;
56099 rc = SQLITE_FULL;
56111 TESTONLY( rc = ) sqlite3BitvecSet(pPager->pInJournal, pgno);
56112 testcase( rc==SQLITE_NOMEM );
56114 TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);
56115 testcase( rc==SQLITE_NOMEM );
56123 rc = readDbPage(pPg);
56124 if( rc!=SQLITE_OK ){
56133 assert( rc!=SQLITE_OK );
56139 return rc;
56150 int rc = SQLITE_OK;
56180 rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);
56181 if( rc!=SQLITE_OK ){
56183 return rc;
56188 rc = sqlite3OsFetch(pPager->fd,
56191 if( rc==SQLITE_OK && pData ){
56196 rc = pagerAcquireMapPage(pPager, pgno, pData, &pPg);
56201 assert( rc==SQLITE_OK );
56206 if( rc!=SQLITE_OK ){
56208 return rc;
56324 int rc = SQLITE_OK; /* Return code */
56360 rc = databaseIsUnmoved(pPager);
56361 if( rc==SQLITE_OK ){
56362 rc = sqlite3JournalOpen (
56367 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
56374 if( rc==SQLITE_OK ){
56380 rc = writeJournalHdr(pPager);
56384 if( rc!=SQLITE_OK ){
56392 return rc;
56413 int rc = SQLITE_OK;
56427 rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
56428 if( rc!=SQLITE_OK ){
56429 return rc;
56439 rc = sqlite3WalBeginWriteTransaction(pPager->pWal);
56446 rc = pagerLockDb(pPager, RESERVED_LOCK);
56447 if( rc==SQLITE_OK && exFlag ){
56448 rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
56452 if( rc==SQLITE_OK ){
56469 assert( rc==SQLITE_OK || pPager->eState==PAGER_READER );
56470 assert( rc!=SQLITE_OK || pPager->eState==PAGER_WRITER_LOCKED );
56475 return rc;
56483 int rc;
56506 rc = write32bits(pPager->jfd, iOff, pPg->pgno);
56507 if( rc!=SQLITE_OK ) return rc;
56508 rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize, iOff+4);
56509 if( rc!=SQLITE_OK ) return rc;
56510 rc = write32bits(pPager->jfd, iOff+pPager->pageSize+4, cksum);
56511 if( rc!=SQLITE_OK ) return rc;
56523 rc = sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);
56524 testcase( rc==SQLITE_NOMEM );
56525 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
56526 rc |= addToSavepointBitvecs(pPager, pPg->pgno);
56527 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
56528 return rc;
56540 int rc = SQLITE_OK;
56565 rc = pager_open_journal(pPager);
56566 if( rc!=SQLITE_OK ) return rc;
56584 rc = pagerAddPageToRollbackJournal(pPg);
56585 if( rc!=SQLITE_OK ){
56586 return rc;
56609 rc = subjournalPageIfRequired(pPg);
56616 return rc;
56631 int rc = SQLITE_OK; /* Return code */
56666 for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){
56671 rc = sqlite3PagerGet(pPager, pg, &pPage, 0);
56672 if( rc==SQLITE_OK ){
56673 rc = pager_write(pPage);
56694 if( rc==SQLITE_OK && needSync ){
56707 return rc;
56808 int rc = SQLITE_OK;
56839 rc = sqlite3PagerGet(pPager, 1, &pPgHdr, 0);
56840 assert( pPgHdr==0 || rc==SQLITE_OK );
56847 if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){
56848 rc = sqlite3PagerWrite(pPgHdr);
56851 if( rc==SQLITE_OK ){
56859 CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM_BKPT, zBuf);
56860 if( rc==SQLITE_OK ){
56861 rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
56864 if( rc==SQLITE_OK ){
56880 return rc;
56891 int rc = SQLITE_OK;
56893 rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, pArg);
56894 if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
56895 if( rc==SQLITE_OK && !pPager->noSync ){
56897 rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);
56899 return rc;
56914 int rc = pPager->errCode;
56916 if( rc==SQLITE_OK ){
56923 rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
56926 return rc;
56960 int rc = SQLITE_OK; /* Return code */
56996 rc = sqlite3PagerGet(pPager, 1, &pPageOne, 0);
57000 assert( rc==SQLITE_OK );
57002 rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1);
57005 if( rc==SQLITE_OK ){
57064 rc = pager_incr_changecounter(pPager, 1);
57066 rc = sqlite3JournalCreate(pPager->jfd);
57067 if( rc==SQLITE_OK ){
57068 rc = pager_incr_changecounter(pPager, 0);
57075 rc = sqlite3JournalCreate(pPager->jfd);
57076 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
57080 rc = pager_incr_changecounter(pPager, 0);
57082 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
57088 rc = writeMasterJournal(pPager, zMaster);
57089 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
57102 rc = syncJournal(pPager, 0);
57103 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
57108 rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);
57109 if( rc==SQLITE_OK ){
57110 rc = pager_write_pagelist(pPager, pList);
57111 if( rc==SQLITE_OK ){
57112 rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);
57114 if( rc!=SQLITE_OK ){
57119 if( (rc&0xFF)==SQLITE_IOERR && rc!=SQLITE_IOERR_NOMEM ){
57120 rc = sqlite3JournalCreate(pPager->jfd);
57121 if( rc!=SQLITE_OK ){
57133 rc = pager_write_pagelist(pPager, pList);
57135 if( rc!=SQLITE_OK ){
57136 assert( rc!=SQLITE_IOERR_BLOCKED );
57150 rc = pager_truncate(pPager, nNew);
57151 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
57156 rc = sqlite3PagerSync(pPager, zMaster);
57163 if( rc==SQLITE_OK && !pagerUseWal(pPager) ){
57166 return rc;
57186 int rc = SQLITE_OK; /* Return code */
57221 rc = pager_end_transaction(pPager, pPager->setMaster, 1);
57222 return pager_error(pPager, rc);
57252 int rc = SQLITE_OK; /* Return code */
57265 rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1);
57267 if( rc==SQLITE_OK ) rc = rc2;
57270 rc = pager_end_transaction(pPager, 0, 0);
57279 return rc;
57282 rc = pager_playback(pPager, 0);
57285 assert( pPager->eState==PAGER_READER || rc!=SQLITE_OK );
57286 assert( rc==SQLITE_OK || rc==SQLITE_FULL || rc==SQLITE_CORRUPT
57287 || rc==SQLITE_NOMEM || (rc&0xFF)==SQLITE_IOERR
57288 || rc==SQLITE_CANTOPEN
57294 return pager_error(pPager, rc);
57403 int rc = SQLITE_OK; /* Return code */
57445 return rc;
57490 int rc = pPager->errCode;
57493 if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;
57499 if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){
57519 rc = sqlite3OsTruncate(pPager->sjfd, 0);
57520 assert( rc==SQLITE_OK );
57532 rc = pagerPlaybackSavepoint(pPager, pSavepoint);
57533 assert(rc!=SQLITE_DONE);
57552 return rc;
57691 int rc; /* Return code */
57705 rc = sqlite3PagerWrite(pPg);
57706 if( rc ) return rc;
57728 && SQLITE_OK!=(rc = subjournalPageIfRequired(pPg))
57730 return rc;
57803 rc = sqlite3PagerGet(pPager, needSyncPgno, &pPgHdr, 0);
57804 if( rc!=SQLITE_OK ){
57809 return rc;
57950 int rc = SQLITE_OK;
57954 rc = sqlite3PagerSharedLock(pPager);
57957 assert( rc==SQLITE_OK );
57958 rc = pagerLockDb(pPager, RESERVED_LOCK);
57960 if( rc==SQLITE_OK ){
57963 if( rc==SQLITE_OK && state==PAGER_READER ){
58048 int rc = SQLITE_OK;
58050 rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
58058 return rc;
58080 int rc; /* Return code */
58083 rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
58084 if( rc!=SQLITE_OK ){
58090 return rc;
58100 int rc = SQLITE_OK;
58111 rc = pagerExclusiveLock(pPager);
58117 if( rc==SQLITE_OK ){
58118 rc = sqlite3WalOpen(pPager->pVfs,
58125 return rc;
58148 int rc = SQLITE_OK; /* Return code */
58162 rc = pagerOpenWal(pPager);
58163 if( rc==SQLITE_OK ){
58171 return rc;
58184 int rc = SQLITE_OK;
58194 rc = pagerLockDb(pPager, SHARED_LOCK);
58195 if( rc==SQLITE_OK ){
58196 rc = sqlite3OsAccess(
58200 if( rc==SQLITE_OK && logexists ){
58201 rc = pagerOpenWal(pPager);
58208 if( rc==SQLITE_OK && pPager->pWal ){
58209 rc = pagerExclusiveLock(pPager);
58210 if( rc==SQLITE_OK ){
58211 rc = sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags,
58215 if( rc && !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);
58218 return rc;
58227 int rc = SQLITE_ERROR;
58229 rc = sqlite3WalSnapshotGet(pPager->pWal, ppSnapshot);
58231 return rc;
58240 int rc = SQLITE_OK;
58244 rc = SQLITE_ERROR;
58246 return rc;
58254 int rc;
58256 rc = sqlite3WalSnapshotRecover(pPager->pWal);
58258 rc = SQLITE_ERROR;
58260 return rc;
58276 int rc;
58278 rc = sqlite3WalSnapshotCheck(pPager->pWal, pSnapshot);
58280 rc = SQLITE_ERROR;
58282 return rc;
58888 int rc = SQLITE_OK;
58909 if( !pWal->apWiData[iPage] ) rc = SQLITE_NOMEM_BKPT;
58911 rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ,
58914 assert( pWal->apWiData[iPage]!=0 || rc!=SQLITE_OK || pWal->writeLock==0 );
58915 testcase( pWal->apWiData[iPage]==0 && rc==SQLITE_OK );
58916 if( (rc&0xff)==SQLITE_READONLY ){
58918 if( rc==SQLITE_READONLY ){
58919 rc = SQLITE_OK;
58925 assert( iPage==0 || *ppPage || rc!=SQLITE_OK );
58926 return rc;
59163 int rc;
59165 rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
59168 walLockName(lockIdx), rc ? "failed" : "ok"));
59169 VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
59170 return rc;
59179 int rc;
59181 rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
59184 walLockName(lockIdx), n, rc ? "failed" : "ok"));
59185 VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
59186 return rc;
59241 int rc; /* Return code */
59243 rc = walIndexPage(pWal, iHash, &pLoc->aPgno);
59244 assert( rc==SQLITE_OK || iHash>0 );
59246 if( rc==SQLITE_OK ){
59256 return rc;
59304 int rc; /* Return code form walHashGet() */
59319 rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
59320 if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */
59362 int rc; /* Return code */
59365 rc = walHashGet(pWal, walFramePage(iFrame), &sLoc);
59370 if( rc==SQLITE_OK ){
59437 return rc;
59452 int rc; /* Return Code */
59468 rc = walLockExclusive(pWal, iLock, WAL_READ_LOCK(0)-iLock);
59469 if( rc==SQLITE_OK ){
59470 rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
59471 if( rc!=SQLITE_OK ){
59475 if( rc ){
59476 return rc;
59483 rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);
59484 if( rc!=SQLITE_OK ){
59501 rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);
59502 if( rc!=SQLITE_OK ){
59539 rc = SQLITE_CANTOPEN_BKPT;
59547 rc = SQLITE_NOMEM_BKPT;
59560 rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);
59561 if( rc!=SQLITE_OK ) break;
59564 rc = walIndexAppend(pWal, iFrame, pgno);
59565 if( rc!=SQLITE_OK ) break;
59583 if( rc==SQLITE_OK ){
59615 WALTRACE(("WAL%p: recovery %s\n", pWal, rc ? "failed" : "ok"));
59618 return rc;
59660 int rc; /* Return Code */
59702 rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);
59703 if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){
59707 if( rc!=SQLITE_OK ){
59720 return rc;
59937 int rc = SQLITE_OK; /* Return Code */
59964 rc = SQLITE_NOMEM_BKPT;
59967 for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
59970 rc = walHashGet(pWal, i, &sLoc);
59971 if( rc==SQLITE_OK ){
59997 if( rc!=SQLITE_OK ){
60002 return rc;
60018 int rc;
60020 rc = walLockExclusive(pWal, lockIdx, n);
60021 }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );
60022 return rc;
60106 int rc = SQLITE_OK; /* Return code */
60145 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
60146 if( rc==SQLITE_OK ){
60149 }else if( rc==SQLITE_BUSY ){
60160 rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);
60161 assert( rc==SQLITE_OK || pIter==0 );
60165 && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
60172 rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));
60177 if( rc==SQLITE_OK ){
60180 rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
60181 if( rc==SQLITE_OK && nSize<nReq ){
60188 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
60192 rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;
60200 rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
60201 if( rc!=SQLITE_OK ) break;
60204 rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
60205 if( rc!=SQLITE_OK ) break;
60209 if( rc==SQLITE_OK ){
60213 rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
60214 if( rc==SQLITE_OK ){
60215 rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
60218 if( rc==SQLITE_OK ){
60227 if( rc==SQLITE_BUSY ){
60230 rc = SQLITE_OK;
60239 if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){
60242 rc = SQLITE_BUSY;
60247 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
60248 if( rc==SQLITE_OK ){
60264 rc = sqlite3OsTruncate(pWal->pWalFd, 0);
60273 return rc;
60304 int rc = SQLITE_OK;
60317 && SQLITE_OK==(rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE))
60322 rc = sqlite3WalCheckpoint(pWal, db,
60325 if( rc==SQLITE_OK ){
60358 return rc;
60443 int rc; /* Return code */
60451 rc = walIndexPage(pWal, 0, &page0);
60452 if( rc!=SQLITE_OK ){
60453 assert( rc!=SQLITE_READONLY ); /* READONLY changed to OK in walIndexPage */
60454 if( rc==SQLITE_READONLY_CANTINIT ){
60468 return rc; /* Any other non-OK return is just an error */
60490 if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){
60492 rc = SQLITE_READONLY_RECOVERY;
60494 }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){
60496 if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
60503 rc = walIndexRecover(pWal);
60517 rc = SQLITE_CANTOPEN_BKPT;
60520 if( rc!=SQLITE_OK ){
60527 if( rc==SQLITE_IOERR_SHORT_READ ) rc = WAL_RETRY;
60532 return rc;
60570 int rc; /* Return code */
60580 rc = walLockShared(pWal, WAL_READ_LOCK(0));
60581 if( rc!=SQLITE_OK ){
60582 if( rc==SQLITE_BUSY ) rc = WAL_RETRY;
60609 rc = sqlite3OsShmMap(pWal->pDbFd, 0, WALINDEX_PGSZ, 0, &pDummy);
60610 assert( rc!=SQLITE_OK ); /* SQLITE_OK not possible for read-only connection */
60611 if( rc!=SQLITE_READONLY_CANTINIT ){
60612 rc = (rc==SQLITE_READONLY ? WAL_RETRY : rc);
60625 rc = sqlite3OsFileSize(pWal->pWalFd, &szWal);
60626 if( rc!=SQLITE_OK ){
60637 rc = (pWal->hdr.mxFrame==0 ? SQLITE_OK : WAL_RETRY);
60642 rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);
60643 if( rc!=SQLITE_OK ){
60650 rc = WAL_RETRY;
60658 rc = SQLITE_NOMEM_BKPT;
60677 rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);
60678 if( rc!=SQLITE_OK ) break;
60685 rc = WAL_RETRY;
60694 if( rc!=SQLITE_OK ){
60704 return rc;
60762 int rc = SQLITE_OK; /* Return code */
60798 assert( rc==SQLITE_OK );
60800 rc = walIndexReadHdr(pWal, pChanged);
60802 if( rc==SQLITE_BUSY ){
60819 rc = WAL_RETRY;
60820 }else if( SQLITE_OK==(rc = walLockShared(pWal, WAL_RECOVER_LOCK)) ){
60822 rc = WAL_RETRY;
60823 }else if( rc==SQLITE_BUSY ){
60824 rc = SQLITE_BUSY_RECOVERY;
60827 if( rc!=SQLITE_OK ){
60828 return rc;
60846 rc = walLockShared(pWal, WAL_READ_LOCK(0));
60848 if( rc==SQLITE_OK ){
60868 }else if( rc!=SQLITE_BUSY ){
60869 return rc;
60898 rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
60899 if( rc==SQLITE_OK ){
60904 }else if( rc!=SQLITE_BUSY ){
60905 return rc;
60910 assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );
60911 return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
60914 rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
60915 if( rc ){
60916 return rc==SQLITE_BUSY ? WAL_RETRY : rc;
60963 return rc;
60987 int rc;
60990 rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
60991 if( rc==SQLITE_OK ){
60996 rc = sqlite3OsFileSize(pWal->pDbFd, &szDb);
60997 if( rc==SQLITE_OK ){
61001 rc = SQLITE_NOMEM;
61010 rc = walHashGet(pWal, walFramePage(i), &sLoc);
61011 if( rc!=SQLITE_OK ) break;
61017 rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff);
61019 if( rc==SQLITE_OK ){
61020 rc = sqlite3OsRead(pWal->pDbFd, pBuf2, szPage, iDbOff);
61023 if( rc!=SQLITE_OK || 0==memcmp(pBuf1, pBuf2, szPage) ){
61038 return rc;
61057 int rc; /* Return code */
61069 rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);
61070 }while( rc==WAL_RETRY );
61071 testcase( (rc&0xff)==SQLITE_BUSY );
61072 testcase( (rc&0xff)==SQLITE_IOERR );
61073 testcase( rc==SQLITE_PROTOCOL );
61074 testcase( rc==SQLITE_OK );
61077 if( rc==SQLITE_OK ){
61109 rc = walLockShared(pWal, WAL_CKPT_LOCK);
61111 if( rc==SQLITE_OK ){
61125 rc = SQLITE_ERROR_SNAPSHOT;
61134 if( rc!=SQLITE_OK ){
61140 return rc;
61217 int rc; /* Error code */
61219 rc = walHashGet(pWal, iHash, &sLoc);
61220 if( rc!=SQLITE_OK ){
61221 return rc;
61307 int rc;
61321 rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
61322 if( rc ){
61323 return rc;
61334 rc = SQLITE_BUSY_SNAPSHOT;
61337 return rc;
61367 int rc = SQLITE_OK;
61378 ALWAYS(rc==SQLITE_OK) && iFrame<=iMax;
61393 rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));
61397 return rc;
61421 int rc = SQLITE_OK;
61442 return rc;
61458 int rc = SQLITE_OK;
61467 rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
61468 if( rc==SQLITE_OK ){
61480 }else if( rc!=SQLITE_BUSY ){
61481 return rc;
61489 rc = walTryBeginRead(pWal, ¬Used, 1, ++cnt);
61490 }while( rc==WAL_RETRY );
61491 assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */
61492 testcase( (rc&0xff)==SQLITE_IOERR );
61493 testcase( rc==SQLITE_PROTOCOL );
61494 testcase( rc==SQLITE_OK );
61496 return rc;
61526 int rc;
61529 rc = sqlite3OsWrite(p->pFd, pContent, iFirstAmt, iOffset);
61530 if( rc ) return rc;
61535 rc = sqlite3OsSync(p->pFd, WAL_SYNC_FLAGS(p->syncFlags));
61536 if( iAmt==0 || rc ) return rc;
61538 rc = sqlite3OsWrite(p->pFd, pContent, iAmt, iOffset);
61539 return rc;
61551 int rc; /* Result code from subfunctions */
61560 rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);
61561 if( rc ) return rc;
61563 rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));
61564 return rc;
61577 int rc = SQLITE_OK; /* Return code */
61597 rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, iCksumOff);
61603 for(; rc==SQLITE_OK && iRead<=iLast; iRead++){
61605 rc = sqlite3OsRead(pWal->pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff);
61606 if( rc==SQLITE_OK ){
61612 rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOff);
61617 return rc;
61632 int rc; /* Used to catch return codes */
61665 if( SQLITE_OK!=(rc = walRestartLog(pWal)) ){
61666 return rc;
61694 rc = sqlite3OsWrite(pWal->pWalFd, aWalHdr, sizeof(aWalHdr), 0);
61695 WALTRACE(("WAL%p: wal-header write %s\n", pWal, rc ? "failed" : "ok"));
61696 if( rc!=SQLITE_OK ){
61697 return rc;
61708 rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));
61709 if( rc ) return rc;
61733 VVA_ONLY(rc =) sqlite3WalFindFrame(pWal, p->pgno, &iWrite);
61734 assert( rc==SQLITE_OK || iWrite==0 );
61746 rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOff);
61747 if( rc ) return rc;
61756 rc = walWriteOneFrame(&w, p, nDbSize, iOffset);
61757 if( rc ) return rc;
61765 rc = walRewriteChecksums(pWal, iFrame);
61766 if( rc ) return rc;
61791 rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
61792 if( rc ) return rc;
61798 assert( rc==SQLITE_OK );
61799 rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));
61822 for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
61825 rc = walIndexAppend(pWal, iFrame, p->pgno);
61827 while( rc==SQLITE_OK && nExtra>0 ){
61830 rc = walIndexAppend(pWal, iFrame, pLast->pgno);
61833 if( rc==SQLITE_OK ){
61850 WALTRACE(("WAL%p: frame write %s\n", pWal, rc ? "failed" : "ok"));
61851 return rc;
61876 int rc; /* Return code */
61893 rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
61894 if( rc ){
61901 testcase( rc==SQLITE_BUSY );
61903 return rc;
61917 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);
61918 if( rc==SQLITE_OK ){
61920 }else if( rc==SQLITE_BUSY ){
61923 rc = SQLITE_OK;
61928 if( rc==SQLITE_OK ){
61929 rc = walIndexReadHdr(pWal, &isChanged);
61936 if( rc==SQLITE_OK ){
61939 rc = SQLITE_CORRUPT_BKPT;
61941 rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
61945 if( rc==SQLITE_OK || rc==SQLITE_BUSY ){
61965 WALTRACE(("WAL%p: checkpoint %s\n", pWal, rc ? "failed" : "ok"));
61966 return (rc==SQLITE_OK && eMode!=eMode2 ? SQLITE_BUSY : rc);
62008 int rc;
62027 rc = pWal->exclusiveMode==WAL_NORMAL_MODE;
62030 rc = 0;
62037 rc = 1;
62039 rc = pWal->exclusiveMode==WAL_NORMAL_MODE;
62041 return rc;
62059 int rc = SQLITE_OK;
62071 rc = SQLITE_NOMEM_BKPT;
62077 return rc;
62115 int rc;
62116 rc = walLockShared(pWal, WAL_CKPT_LOCK);
62117 if( rc==SQLITE_OK ){
62122 rc = SQLITE_ERROR_SNAPSHOT;
62126 return rc;
63779 int rc = SQLITE_OK;
63784 rc = SQLITE_NOMEM_BKPT;
63787 if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){
63788 rc = sqlite3BitvecSet(pBt->pHasContent, pgno);
63790 return rc;
63842 int rc = SQLITE_OK;
63861 rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
63862 if( rc==SQLITE_OK ){
63869 rc = SQLITE_NOMEM_BKPT;
63873 return rc;
63884 int rc;
63896 rc = saveCursorKey(pCur);
63897 if( rc==SQLITE_OK ){
63903 return rc;
63955 int rc = saveCursorPosition(p);
63956 if( SQLITE_OK!=rc ){
63957 return rc;
63991 int rc; /* Status code */
64001 rc = SQLITE_CORRUPT_BKPT;
64007 rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);
64012 return rc;
64023 int rc;
64032 rc = SQLITE_IOERR;
64034 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
64036 if( rc==SQLITE_OK ){
64045 return rc;
64098 int rc;
64102 rc = restoreCursorPosition(pCur);
64103 if( rc ){
64105 return rc;
64174 int rc; /* Return code from subfunctions */
64188 rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);
64189 if( rc!=SQLITE_OK ){
64190 *pRC = rc;
64210 *pRC= rc = sqlite3PagerWrite(pDbPage);
64211 if( rc==SQLITE_OK ){
64233 int rc;
64238 rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);
64239 if( rc!=0 ){
64240 return rc;
64260 #define ptrmapPut(w,x,y,z,rc)
64262 #define ptrmapPutOvflPtr(x, y, z, rc)
64799 int rc = SQLITE_OK; /* Integer return code */
64836 u8 *pSpace = pageFindSlot(pPage, nByte, &rc);
64841 }else if( rc ){
64842 return rc;
64853 rc = defragmentPage(pPage, MIN(4, pPage->nFree - (2+nByte)));
64854 if( rc ) return rc;
65288 int rc;
65293 rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, flags);
65294 if( rc ) return rc;
65347 int rc;
65355 rc = SQLITE_CORRUPT_BKPT;
65358 rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, bReadOnly);
65359 if( rc ){
65365 rc = btreeInitPage(*ppPage);
65366 if( rc!=SQLITE_OK ){
65376 rc = SQLITE_CORRUPT_PGNO(pgno);
65389 assert( pgno!=0 || rc==SQLITE_CORRUPT );
65390 return rc;
65437 int rc = btreeGetPage(pBt, pgno, ppPage, flags);
65438 if( rc==SQLITE_OK ){
65448 return rc;
65522 int rc = SQLITE_OK; /* Result code from this function */
65588 rc = sqlite3OsFullPathname(pVfs, zFilename,
65590 if( rc ){
65593 return rc;
65651 rc = SQLITE_NOMEM_BKPT;
65654 rc = sqlite3PagerOpen(pVfs, &pBt->pPager, zFilename,
65656 if( rc==SQLITE_OK ){
65658 rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);
65660 if( rc!=SQLITE_OK ){
65707 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
65708 if( rc ) goto btree_open_out;
65722 rc = SQLITE_NOMEM_BKPT;
65768 if( rc!=SQLITE_OK ){
65795 assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );
65796 return rc;
66033 int rc = SQLITE_OK;
66055 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
66059 return rc;
66165 int rc = SQLITE_OK;
66170 rc = SQLITE_READONLY;
66176 return rc;
66188 int rc;
66190 rc = (
66196 return rc;
66241 int rc; /* Result code from subfunctions */
66249 rc = sqlite3PagerSharedLock(pBt->pPager);
66250 if( rc!=SQLITE_OK ) return rc;
66251 rc = btreeGetPage(pBt, 1, &pPage1, 0);
66252 if( rc!=SQLITE_OK ) return rc;
66269 rc = SQLITE_NOTADB;
66302 rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
66303 if( rc!=SQLITE_OK ){
66312 rc = SQLITE_NOTADB;
66360 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
66362 return rc;
66365 rc = SQLITE_CORRUPT_BKPT;
66412 return rc;
66467 int rc;
66476 rc = sqlite3PagerWrite(pP1->pDbPage);
66477 if( rc ) return rc;
66509 int rc;
66512 rc = newDatabase(p->pBt);
66514 return rc;
66554 int rc = SQLITE_OK;
66576 rc = SQLITE_READONLY;
66602 rc = SQLITE_LOCKED_SHAREDCACHE;
66611 rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);
66612 if( SQLITE_OK!=rc ) goto trans_begun;
66624 while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );
66626 if( rc==SQLITE_OK && wrflag ){
66628 rc = SQLITE_READONLY;
66630 rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));
66631 if( rc==SQLITE_OK ){
66632 rc = newDatabase(pBt);
66633 }else if( rc==SQLITE_BUSY_SNAPSHOT && pBt->inTransaction==TRANS_NONE ){
66637 rc = SQLITE_BUSY;
66642 if( rc!=SQLITE_OK ){
66645 }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
66649 if( rc==SQLITE_OK ){
66681 rc = sqlite3PagerWrite(pPage1->pDbPage);
66682 if( rc==SQLITE_OK ){
66690 if( rc==SQLITE_OK ){
66699 rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
66705 return rc;
66718 int rc; /* Return code */
66723 rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);
66724 if( rc!=SQLITE_OK ) return rc;
66730 ptrmapPutOvflPtr(pPage, pPage, pCell, &rc);
66734 ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);
66740 ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);
66743 return rc;
66772 int rc;
66774 rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);
66775 if( rc ) return rc;
66832 int rc;
66843 rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);
66844 if( rc!=SQLITE_OK ){
66845 return rc;
66858 rc = setChildPtrmaps(pDbPage);
66859 if( rc!=SQLITE_OK ){
66860 return rc;
66865 ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, &rc);
66866 if( rc!=SQLITE_OK ){
66867 return rc;
66877 rc = btreeGetPage(pBt, iPtrPage, &pPtrPage, 0);
66878 if( rc!=SQLITE_OK ){
66879 return rc;
66881 rc = sqlite3PagerWrite(pPtrPage->pDbPage);
66882 if( rc!=SQLITE_OK ){
66884 return rc;
66886 rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType);
66888 if( rc==SQLITE_OK ){
66889 ptrmapPut(pBt, iFreePage, eType, iPtrPage, &rc);
66892 return rc;
66917 int rc;
66931 rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);
66932 if( rc!=SQLITE_OK ){
66933 return rc;
66948 rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, BTALLOC_EXACT);
66949 if( rc!=SQLITE_OK ){
66950 return rc;
66961 rc = btreeGetPage(pBt, iLastPg, &pLastPg, 0);
66962 if( rc!=SQLITE_OK ){
66963 return rc;
66979 rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iNear, eMode);
66980 if( rc!=SQLITE_OK ){
66982 return rc;
66988 rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, bCommit);
66990 if( rc!=SQLITE_OK ){
66991 return rc;
67038 int rc;
67044 rc = SQLITE_DONE;
67051 rc = SQLITE_CORRUPT_BKPT;
67053 rc = saveAllCursors(pBt, 0, 0);
67054 if( rc==SQLITE_OK ){
67056 rc = incrVacuumStep(pBt, nFin, nOrig, 0);
67058 if( rc==SQLITE_OK ){
67059 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
67063 rc = SQLITE_DONE;
67067 return rc;
67080 int rc = SQLITE_OK;
67106 rc = saveAllCursors(pBt, 0, 0);
67108 for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){
67109 rc = incrVacuumStep(pBt, nFin, iFree, 1);
67111 if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){
67112 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
67119 if( rc!=SQLITE_OK ){
67125 return rc;
67159 int rc = SQLITE_OK;
67165 rc = autoVacuumCommit(pBt);
67166 if( rc!=SQLITE_OK ){
67168 return rc;
67175 rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zMaster, 0);
67178 return rc;
67257 int rc;
67261 rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);
67262 if( rc!=SQLITE_OK && bCleanup==0 ){
67264 return rc;
67280 int rc;
67282 rc = sqlite3BtreeCommitPhaseOne(p, 0);
67283 if( rc==SQLITE_OK ){
67284 rc = sqlite3BtreeCommitPhaseTwo(p, 0);
67287 return rc;
67318 int rc = SQLITE_OK;
67326 rc = saveCursorPosition(p);
67327 if( rc!=SQLITE_OK ){
67328 (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
67341 return rc;
67356 int rc;
67364 rc = tripCode = saveAllCursors(pBt, 0, 0);
67365 if( rc ) writeOnly = 0;
67367 rc = SQLITE_OK;
67371 assert( rc==SQLITE_OK || (writeOnly==0 && rc2==SQLITE_OK) );
67372 if( rc2!=SQLITE_OK ) rc = rc2;
67382 rc = rc2;
67403 return rc;
67425 int rc;
67438 rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);
67440 return rc;
67456 int rc = SQLITE_OK;
67463 rc = saveAllCursors(pBt, 0, 0);
67465 if( rc==SQLITE_OK ){
67466 rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
67468 if( rc==SQLITE_OK ){
67472 rc = newDatabase(pBt);
67482 return rc;
67594 int rc;
67596 rc = SQLITE_CORRUPT_BKPT;
67599 rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
67602 return rc;
67801 int rc = SQLITE_OK;
67823 rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
67824 if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
67826 rc = SQLITE_DONE;
67832 assert( next==0 || rc==SQLITE_DONE );
67833 if( rc==SQLITE_OK ){
67834 rc = btreeGetPage(pBt, ovfl, &pPage, (ppPage==0) ? PAGER_GET_READONLY : 0);
67835 assert( rc==SQLITE_OK || pPage==0 );
67836 if( rc==SQLITE_OK ){
67847 return (rc==SQLITE_DONE ? SQLITE_OK : rc);
67870 int rc = sqlite3PagerWrite(pDbPage);
67871 if( rc!=SQLITE_OK ){
67872 return rc;
67919 int rc = SQLITE_OK;
67953 rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage);
67962 if( rc==SQLITE_OK && amt>0 ){
68003 assert( rc==SQLITE_OK && amt>0 );
68023 rc = getOverflowPage(pBt, nextPage, 0, &nextPage);
68059 rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
68067 rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage,
68070 if( rc==SQLITE_OK ){
68073 rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage);
68079 if( amt==0 ) return rc;
68082 if( rc ) break;
68087 if( rc==SQLITE_OK && amt>0 ){
68091 return rc;
68131 int rc;
68136 rc = btreeRestoreCursorPosition(pCur);
68137 return rc ? rc : accessPayload(pCur, offset, amt, pBuf, 0);
68313 int rc = SQLITE_OK;
68343 rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->pPage,
68345 if( rc!=SQLITE_OK ){
68347 return rc;
68383 rc = moveToChild(pCur, subpage);
68386 rc = SQLITE_EMPTY;
68388 return rc;
68400 int rc = SQLITE_OK;
68405 while( rc==SQLITE_OK && !(pPage = pCur->pPage)->leaf ){
68408 rc = moveToChild(pCur, pgno);
68410 return rc;
68425 int rc = SQLITE_OK;
68433 rc = moveToChild(pCur, pgno);
68434 if( rc ) return rc;
68447 int rc;
68451 rc = moveToRoot(pCur);
68452 if( rc==SQLITE_OK ){
68455 rc = moveToLeftmost(pCur);
68456 }else if( rc==SQLITE_EMPTY ){
68459 rc = SQLITE_OK;
68461 return rc;
68469 int rc;
68489 rc = moveToRoot(pCur);
68490 if( rc==SQLITE_OK ){
68493 rc = moveToRightmost(pCur);
68494 if( rc==SQLITE_OK ){
68499 }else if( rc==SQLITE_EMPTY ){
68502 rc = SQLITE_OK;
68504 return rc;
68544 int rc;
68573 rc = sqlite3BtreeNext(pCur, 0);
68574 if( rc==SQLITE_OK ){
68579 }else if( rc==SQLITE_DONE ){
68580 rc = SQLITE_OK;
68582 return rc;
68599 rc = moveToRoot(pCur);
68600 if( rc ){
68601 if( rc==SQLITE_EMPTY ){
68606 return rc;
68714 rc = SQLITE_CORRUPT_PAGE(pPage);
68719 rc = SQLITE_NOMEM_BKPT;
68723 rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
68725 if( rc ){
68743 rc = SQLITE_OK;
68745 if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;
68759 rc = SQLITE_OK;
68769 rc = moveToChild(pCur, chldPg);
68770 if( rc ) break;
68775 return rc;
68840 int rc;
68847 rc = restoreCursorPosition(pCur);
68848 if( rc!=SQLITE_OK ){
68849 return rc;
68882 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
68883 if( rc ) return rc;
68947 int rc;
68954 rc = restoreCursorPosition(pCur);
68955 if( rc!=SQLITE_OK ){
68956 return rc;
68971 rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
68972 if( rc ) return rc;
68973 rc = moveToRightmost(pCur);
68988 rc = sqlite3BtreePrevious(pCur, 0);
68990 rc = SQLITE_OK;
68993 return rc;
69041 int rc;
69075 rc = ptrmapGet(pBt, nearby, &eType, 0);
69076 if( rc ) return rc;
69089 rc = sqlite3PagerWrite(pPage1->pDbPage);
69090 if( rc ) return rc;
69113 rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1);
69115 rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
69117 if( rc ){
69131 rc = sqlite3PagerWrite(pTrunk->pDbPage);
69132 if( rc ){
69142 rc = SQLITE_CORRUPT_PGNO(iTrunk);
69154 rc = sqlite3PagerWrite(pTrunk->pDbPage);
69155 if( rc ){
69162 rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);
69163 if( rc!=SQLITE_OK ){
69176 rc = SQLITE_CORRUPT_PGNO(iTrunk);
69180 rc = btreeGetUnusedPage(pBt, iNewTrunk, &pNewTrunk, 0);
69181 if( rc!=SQLITE_OK ){
69184 rc = sqlite3PagerWrite(pNewTrunk->pDbPage);
69185 if( rc!=SQLITE_OK ){
69197 rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);
69198 if( rc ){
69241 rc = SQLITE_CORRUPT_PGNO(iTrunk);
69253 rc = sqlite3PagerWrite(pTrunk->pDbPage);
69254 if( rc ) goto end_allocate_page;
69260 rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, noContent);
69261 if( rc==SQLITE_OK ){
69262 rc = sqlite3PagerWrite((*ppPage)->pDbPage);
69263 if( rc!=SQLITE_OK ){
69295 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
69296 if( rc ) return rc;
69309 rc = btreeGetUnusedPage(pBt, pBt->nPage, &pPg, bNoContent);
69310 if( rc==SQLITE_OK ){
69311 rc = sqlite3PagerWrite(pPg->pDbPage);
69314 if( rc ) return rc;
69323 rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, bNoContent);
69324 if( rc ) return rc;
69325 rc = sqlite3PagerWrite((*ppPage)->pDbPage);
69326 if( rc!=SQLITE_OK ){
69338 assert( rc!=SQLITE_OK || sqlite3PagerPageRefcount((*ppPage)->pDbPage)<=1 );
69339 assert( rc!=SQLITE_OK || (*ppPage)->isInit==0 );
69340 return rc;
69360 int rc; /* Return Code */
69378 rc = sqlite3PagerWrite(pPage1->pDbPage);
69379 if( rc ) goto freepage_out;
69387 if( (!pPage && ((rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0) )
69388 || ((rc = sqlite3PagerWrite(pPage->pDbPage))!=0)
69399 ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, &rc);
69400 if( rc ) goto freepage_out;
69414 rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);
69415 if( rc!=SQLITE_OK ){
69422 rc = SQLITE_CORRUPT_BKPT;
69445 rc = sqlite3PagerWrite(pTrunk->pDbPage);
69446 if( rc==SQLITE_OK ){
69452 rc = btreeSetHasContent(pBt, iPage);
69465 if( pPage==0 && SQLITE_OK!=(rc = btreeGetPage(pBt, iPage, &pPage, 0)) ){
69468 rc = sqlite3PagerWrite(pPage->pDbPage);
69469 if( rc!=SQLITE_OK ){
69483 return rc;
69502 int rc;
69535 rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
69536 if( rc ) return rc;
69552 rc = SQLITE_CORRUPT_BKPT;
69554 rc = freePage2(pBt, pOvfl, ovflPgno);
69560 if( rc ) return rc;
69586 int nSrc, n, rc, mn;
69713 rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);
69725 if( pBt->autoVacuum && rc==SQLITE_OK ){
69727 ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);
69728 if( rc ){
69733 if( rc ){
69735 return rc;
69772 int rc; /* The return code */
69791 rc = freeSpace(pPage, pc, sz);
69792 if( rc ){
69793 *pRC = rc;
69876 int rc = sqlite3PagerWrite(pPage->pDbPage);
69877 if( rc!=SQLITE_OK ){
69878 *pRC = rc;
69884 rc = allocateSpace(pPage, sz, &idx);
69885 if( rc ){ *pRC = rc; return; }
70172 int sz, rc;
70175 if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){
70403 int rc; /* Return Code */
70418 rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0);
70420 if( rc==SQLITE_OK ){
70437 rc = rebuildPage(&b, 0, 1, pNew);
70438 if( NEVER(rc) ){
70440 return rc;
70454 ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);
70456 ptrmapPutOvflPtr(pNew, pNew, pCell, &rc);
70480 if( rc==SQLITE_OK ){
70482 0, pPage->pgno, &rc);
70492 return rc;
70562 int rc;
70581 rc = btreeInitPage(pTo);
70582 if( rc==SQLITE_OK ) rc = btreeComputeFreeSpace(pTo);
70583 if( rc!=SQLITE_OK ){
70584 *pRC = rc;
70650 int rc = SQLITE_OK; /* The return code */
70726 rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0);
70727 if( rc ){
70732 rc = btreeComputeFreeSpace(apOld[i]);
70733 if( rc ){
70767 rc = SQLITE_CORRUPT_BKPT;
70775 dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc);
70795 rc = SQLITE_NOMEM_BKPT;
70833 rc = SQLITE_CORRUPT_BKPT;
70953 if( k>NB+2 ){ rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; }
70986 rc = SQLITE_CORRUPT_BKPT;
71028 rc = SQLITE_CORRUPT_BKPT;
71056 rc = sqlite3PagerWrite(pNew->pDbPage);
71058 if( rc ) goto balance_cleanup;
71061 rc = allocateBtreePage(pBt, &pNew, &pgno, (bBulk ? 1 : pgno), 0);
71062 if( rc ) goto balance_cleanup;
71070 ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno, &rc);
71071 if( rc!=SQLITE_OK ){
71102 rc = SQLITE_CORRUPT_BKPT;
71194 ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);
71197 ptrmapPutOvflPtr(pNew, pOld, pCell, &rc);
71199 if( rc ) goto balance_cleanup;
71252 insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);
71253 if( rc!=SQLITE_OK ) goto balance_cleanup;
71307 rc = editPage(apNew[iPg], iOld, iNew, nNewCell, &b);
71308 if( rc ) goto balance_cleanup;
71339 rc = defragmentPage(apNew[0], -1);
71340 testcase( rc!=SQLITE_OK );
71344 || rc!=SQLITE_OK
71346 copyNodeContent(apNew[0], pParent, &rc);
71347 freePage(apNew[0], &rc);
71354 ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);
71365 freePage(apOld[i], &rc);
71369 if( ISAUTOVACUUM && rc==SQLITE_OK && apNew[0]->isInit ){
71391 return rc;
71415 int rc; /* Return value from subprocedures */
71427 rc = sqlite3PagerWrite(pRoot->pDbPage);
71428 if( rc==SQLITE_OK ){
71429 rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);
71430 copyNodeContent(pRoot, pChild, &rc);
71432 ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);
71435 if( rc ){
71438 return rc;
71472 int rc = SQLITE_OK;
71494 rc = balance_deeper(pPage, &pCur->apPage[1]);
71495 if( rc==SQLITE_OK ){
71512 rc = sqlite3PagerWrite(pParent->pDbPage);
71513 if( rc==SQLITE_OK && pParent->nFree<0 ){
71514 rc = btreeComputeFreeSpace(pParent);
71516 if( rc==SQLITE_OK ){
71539 rc = balance_quick(pParent, pPage, aBalanceQuickSpace);
71561 rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,
71586 }while( rc==SQLITE_OK );
71591 return rc;
71610 int rc = sqlite3PagerWrite(pPage->pDbPage);
71611 if( rc ) return rc;
71618 int rc = btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData,
71620 if( rc ) return rc;
71624 int rc = sqlite3PagerWrite(pPage->pDbPage);
71625 if( rc ) return rc;
71643 int rc; /* Return code */
71653 rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
71655 if( rc ) return rc;
71666 rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
71667 if( rc ) return rc;
71669 rc = SQLITE_CORRUPT_BKPT;
71676 rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
71680 if( rc ) return rc;
71723 int rc;
71765 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
71766 if( rc ) return rc;
71807 rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
71808 if( rc ) return rc;
71834 rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
71836 rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
71838 if( rc ) return rc;
71863 rc = btreeComputeFreeSpace(pPage);
71864 if( rc ) return rc;
71873 rc = fillInCell(pPage, newCell, pX, &szNew);
71874 if( rc ) goto end_insert;
71881 rc = sqlite3PagerWrite(pPage->pDbPage);
71882 if( rc ){
71889 rc = clearCell(pPage, oldCell, &info);
71902 assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
71907 dropCell(pPage, idx, info.nSize, &rc);
71908 if( rc ) goto end_insert;
71916 insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);
71917 assert( pPage->nOverflow==0 || rc==SQLITE_OK );
71918 assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
71942 assert( rc==SQLITE_OK );
71944 rc = balance(pCur);
71952 if( (flags & BTREE_SAVEPOSITION) && rc==SQLITE_OK ){
71958 rc = SQLITE_NOMEM;
71970 return rc;
71993 int rc; /* Return code */
72010 rc = btreeRestoreCursorPosition(pCur);
72011 if( rc ) return rc;
72037 rc = saveCursorKey(pCur);
72038 if( rc ) return rc;
72052 rc = sqlite3BtreePrevious(pCur, 0);
72053 assert( rc!=SQLITE_DONE );
72054 if( rc ) return rc;
72060 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
72061 if( rc ) return rc;
72073 rc = sqlite3PagerWrite(pPage->pDbPage);
72074 if( rc ) return rc;
72075 rc = clearCell(pPage, pCell, &info);
72076 dropCell(pPage, iCellIdx, info.nSize, &rc);
72077 if( rc ) return rc;
72091 rc = btreeComputeFreeSpace(pLeaf);
72092 if( rc ) return rc;
72105 rc = sqlite3PagerWrite(pLeaf->pDbPage);
72106 if( rc==SQLITE_OK ){
72107 insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
72109 dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);
72110 if( rc ) return rc;
72128 rc = balance(pCur);
72129 if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){
72136 rc = balance(pCur);
72139 if( rc==SQLITE_OK ){
72152 rc = moveToRoot(pCur);
72157 if( rc==SQLITE_EMPTY ) rc = SQLITE_OK;
72160 return rc;
72178 int rc;
72186 rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);
72187 if( rc ){
72188 return rc;
72223 rc = allocateBtreePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, BTALLOC_EXACT);
72224 if( rc!=SQLITE_OK ){
72225 return rc;
72241 rc = saveAllCursors(pBt, 0, 0);
72243 if( rc!=SQLITE_OK ){
72244 return rc;
72248 rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);
72249 if( rc!=SQLITE_OK ){
72250 return rc;
72252 rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);
72254 rc = SQLITE_CORRUPT_BKPT;
72256 if( rc!=SQLITE_OK ){
72258 return rc;
72262 rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);
72266 if( rc!=SQLITE_OK ){
72267 return rc;
72269 rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);
72270 if( rc!=SQLITE_OK ){
72271 return rc;
72273 rc = sqlite3PagerWrite(pRoot->pDbPage);
72274 if( rc!=SQLITE_OK ){
72276 return rc;
72283 ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, &rc);
72284 if( rc ){
72286 return rc;
72294 rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot);
72295 if( NEVER(rc) ){
72297 return rc;
72301 rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);
72302 if( rc ) return rc;
72318 int rc;
72320 rc = btreeCreateTable(p, piTable, flags);
72322 return rc;
72336 int rc;
72346 rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);
72347 if( rc ) return rc;
72349 rc = SQLITE_CORRUPT_BKPT;
72357 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
72358 if( rc ) goto cleardatabasepage_out;
72360 rc = clearCell(pPage, pCell, &info);
72361 if( rc ) goto cleardatabasepage_out;
72364 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
72365 if( rc ) goto cleardatabasepage_out;
72372 freePage(pPage, &rc);
72373 }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){
72380 return rc;
72397 int rc;
72402 rc = saveAllCursors(pBt, (Pgno)iTable, 0);
72404 if( SQLITE_OK==rc ){
72409 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
72412 return rc;
72445 int rc;
72456 rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
72457 if( rc ) return rc;
72458 rc = sqlite3BtreeClearTable(p, iTable, 0);
72459 if( rc ){
72461 return rc;
72467 freePage(pPage, &rc);
72478 freePage(pPage, &rc);
72480 if( rc!=SQLITE_OK ){
72481 return rc;
72490 rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);
72491 if( rc!=SQLITE_OK ){
72492 return rc;
72494 rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);
72496 if( rc!=SQLITE_OK ){
72497 return rc;
72500 rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);
72501 freePage(pMove, &rc);
72503 if( rc!=SQLITE_OK ){
72504 return rc;
72521 rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno);
72523 freePage(pPage, &rc);
72527 return rc;
72530 int rc;
72532 rc = btreeDropTable(p, iTable, piMoved);
72534 return rc;
72591 int rc;
72597 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
72598 if( rc==SQLITE_OK ){
72609 return rc;
72623 int rc; /* Return code */
72625 rc = moveToRoot(pCur);
72626 if( rc==SQLITE_EMPTY ){
72634 while( rc==SQLITE_OK ){
72676 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
72678 rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx)));
72683 return rc;
72776 int rc;
72780 rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);
72781 if( rc!=SQLITE_OK ){
72782 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck->mallocFailed = 1;
72940 int rc; /* Result code from subroutine call */
72972 if( (rc = btreeGetPage(pBt, (Pgno)iPage, &pPage, 0))!=0 ){
72974 "unable to get the page. error code=%d", rc);
72982 if( (rc = btreeInitPage(pPage))!=0 ){
72983 assert( rc==SQLITE_CORRUPT ); /* The only possible error from InitPage */
72985 "btreeInitPage() returns error code %d", rc);
72988 if( (rc = btreeComputeFreeSpace(pPage))!=0 ){
72989 assert( rc==SQLITE_CORRUPT );
72990 checkAppendMsg(pCheck, "free space corruption", rc);
73375 int rc = SQLITE_OK;
73380 rc = SQLITE_LOCKED;
73382 rc = sqlite3PagerCheckpoint(pBt->pPager, p->db, eMode, pnLog, pnCkpt);
73386 return rc;
73442 int rc;
73445 rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);
73446 assert( rc==SQLITE_OK || rc==SQLITE_LOCKED_SHAREDCACHE );
73448 return rc;
73459 int rc = SQLITE_OK;
73467 rc = querySharedCacheTableLock(p, iTab, lockType);
73468 if( rc==SQLITE_OK ){
73469 rc = setSharedCacheTableLock(p, iTab, lockType);
73473 return rc;
73489 int rc;
73494 rc = restoreCursorPosition(pCsr);
73495 if( rc!=SQLITE_OK ){
73496 return rc;
73511 VVA_ONLY(rc =) saveAllCursors(pCsr->pBt, pCsr->pgnoRoot, pCsr);
73512 assert( rc==SQLITE_OK );
73549 int rc; /* Return code */
73559 rc = sqlite3BtreeBeginTrans(pBtree, 0, 0);
73560 if( rc==SQLITE_OK ){
73563 rc = sqlite3BtreeBeginTrans(pBtree, 2, 0);
73564 if( rc==SQLITE_OK ){
73565 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
73566 if( rc==SQLITE_OK ){
73575 return rc;
73649 int rc; /* Backup process error code */
73705 int rc = 0;
73709 sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg);
73710 rc = SQLITE_ERROR;
73714 if( rc ){
73732 int rc;
73733 rc = sqlite3BtreeSetPageSize(p->pDest,sqlite3BtreeGetPageSize(p->pSrc),-1,0);
73734 return rc;
73836 static int isFatalError(int rc){
73837 return (rc!=SQLITE_OK && rc!=SQLITE_BUSY && ALWAYS(rc!=SQLITE_LOCKED));
73863 int rc = SQLITE_OK;
73868 assert( !isFatalError(p->rc) );
73876 rc = SQLITE_READONLY;
73884 rc = SQLITE_READONLY;
73894 rc = sqlite3PagerSetPagesize(pDestPager, &newPgsz, nSrcReserve);
73895 if( rc==SQLITE_OK && newPgsz!=nSrcPgsz ) rc = SQLITE_READONLY;
73903 for(iOff=iEnd-(i64)nSrcPgsz; rc==SQLITE_OK && iOff<iEnd; iOff+=nDestPgsz){
73907 if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 0))
73908 && SQLITE_OK==(rc = sqlite3PagerWrite(pDestPg))
73930 return rc;
73943 int rc = sqlite3OsFileSize(pFile, &iCurrent);
73944 if( rc==SQLITE_OK && iCurrent>iSize ){
73945 rc = sqlite3OsTruncate(pFile, iSize);
73947 return rc;
73967 int rc;
73981 rc = p->rc;
73982 if( !isFatalError(rc) ){
73993 rc = SQLITE_BUSY;
73995 rc = SQLITE_OK;
74002 if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
74003 rc = sqlite3BtreeBeginTrans(p->pSrc, 0, 0);
74013 if( p->bDestLocked==0 && rc==SQLITE_OK && setDestPgsz(p)==SQLITE_NOMEM ){
74014 rc = SQLITE_NOMEM;
74018 if( SQLITE_OK==rc && p->bDestLocked==0
74019 && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2,
74030 if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){
74031 rc = SQLITE_READONLY;
74039 for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){
74043 rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg,PAGER_GET_READONLY);
74044 if( rc==SQLITE_OK ){
74045 rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0);
74051 if( rc==SQLITE_OK ){
74055 rc = SQLITE_DONE;
74066 if( rc==SQLITE_DONE ){
74068 rc = sqlite3BtreeNewDb(p->pDest);
74071 if( rc==SQLITE_OK || rc==SQLITE_DONE ){
74072 rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);
74074 if( rc==SQLITE_OK ){
74079 rc = sqlite3BtreeSetVersion(p->pDest, 2);
74082 if( rc==SQLITE_OK ){
74140 for(iPg=nDestTruncate; rc==SQLITE_OK && iPg<=(Pgno)nDstPage; iPg++){
74143 rc = sqlite3PagerGet(pDestPager, iPg, &pPg, 0);
74144 if( rc==SQLITE_OK ){
74145 rc = sqlite3PagerWrite(pPg);
74150 if( rc==SQLITE_OK ){
74151 rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);
74158 rc==SQLITE_OK && iOff<iEnd;
74163 rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg, 0);
74164 if( rc==SQLITE_OK ){
74166 rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);
74170 if( rc==SQLITE_OK ){
74171 rc = backupTruncateFile(pFile, iSize);
74175 if( rc==SQLITE_OK ){
74176 rc = sqlite3PagerSync(pDestPager, 0);
74180 rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);
74184 if( SQLITE_OK==rc
74185 && SQLITE_OK==(rc = sqlite3BtreeCommitPhaseTwo(p->pDest, 0))
74187 rc = SQLITE_DONE;
74204 if( rc==SQLITE_IOERR_NOMEM ){
74205 rc = SQLITE_NOMEM_BKPT;
74207 p->rc = rc;
74214 return rc;
74223 int rc; /* Value to return */
74250 rc = (p->rc==SQLITE_DONE) ? SQLITE_OK : p->rc;
74252 sqlite3Error(p->pDestDb, rc);
74265 return rc;
74316 if( !isFatalError(p->rc) && iPage<p->iNext ){
74321 int rc;
74324 rc = backupOnePage(p, iPage, aData, 1);
74326 assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );
74327 if( rc!=SQLITE_OK ){
74328 p->rc = rc;
74366 int rc;
74376 rc = sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);
74377 if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
74378 if( rc ) goto copy_finished;
74403 assert( b.rc!=SQLITE_OK );
74405 rc = sqlite3_backup_finish(&b);
74406 if( rc==SQLITE_OK ){
74416 return rc;
74577 int rc;
74593 rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);
74594 assert(rc==SQLITE_OK || rc==SQLITE_NOMEM);
74595 assert(rc==SQLITE_OK || pMem->enc!=desiredEnc);
74596 assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);
74597 return rc;
74702 int rc = vdbeMemAddTerminator(pMem);
74703 if( rc ) return rc;
75105 int rc;
75108 rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc);
75109 if( rc==0 ){
75114 if( rc==1 && sqlite3RealSameAsInt(pMem->u.r, i) ){
75393 int rc = SQLITE_OK;
75402 rc = sqlite3VdbeMemMakeWriteable(pTo);
75406 return rc;
75546 int rc;
75551 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
75552 rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
75553 if( rc==SQLITE_OK ){
75561 return rc;
75571 int rc = SQLITE_OK; /* Return code */
75587 rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem);
75590 return rc;
75765 int rc = SQLITE_OK; /* Return code */
75784 rc = SQLITE_NOMEM_BKPT;
75788 rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
75789 if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;
75795 rc = SQLITE_NOMEM_BKPT;
75799 assert( pCtx->pParse->rc==SQLITE_OK );
75805 rc = ctx.isError;
75809 assert( rc==SQLITE_OK );
75810 rc = sqlite3VdbeChangeEncoding(pVal, enc);
75811 if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
75812 rc = SQLITE_TOOBIG;
75816 pCtx->pParse->rc = rc;
75819 if( rc!=SQLITE_OK ){
75830 return rc;
75859 int rc = SQLITE_OK;
75877 rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
75878 testcase( rc!=SQLITE_OK );
75883 return rc;
75914 rc = sqlite3VdbeChangeEncoding(pVal, enc);
75953 rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
75965 return rc;
76077 int rc = SQLITE_OK;
76097 rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
76103 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
76108 return rc;
76154 int rc = SQLITE_OK;
76170 rc = stat4ValueFromExpr(pParse, pElem, aff, &alloc, &pVal);
76177 return rc;
78150 int rc = SQLITE_OK; /* Return code */
78157 assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );
78166 if( p->rc==SQLITE_NOMEM ){
78202 p->rc = SQLITE_OK;
78203 rc = SQLITE_DONE;
78233 p->rc = sqlite3VdbeMemGrow(pSub, nByte, nSub!=0);
78234 if( p->rc!=SQLITE_OK ){
78235 rc = SQLITE_ERROR;
78250 if( rc==SQLITE_OK ){
78252 p->rc = SQLITE_INTERRUPT;
78253 rc = SQLITE_ERROR;
78254 sqlite3VdbeError(p, sqlite3ErrStr(p->rc));
78324 p->rc = SQLITE_OK;
78325 rc = SQLITE_ROW;
78328 return rc;
78448 p->rc = SQLITE_OK;
78734 int rc;
78744 rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel);
78745 assert( rc!=0 || !zName || (pColName->flags&MEM_Term)!=0 );
78746 return rc;
78760 int rc = SQLITE_OK;
78776 rc = sqlite3VtabSync(db, p);
78784 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
78809 rc = sqlite3PagerExclusiveLock(pPager);
78813 if( rc!=SQLITE_OK ){
78814 return rc;
78819 rc = db->xCommitCallback(db->pCommitArg);
78820 if( rc ){
78837 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
78840 rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
78849 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
78852 rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);
78855 if( rc==SQLITE_OK ){
78898 rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);
78899 }while( rc==SQLITE_OK && res );
78900 if( rc==SQLITE_OK ){
78902 rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster,
78907 if( rc!=SQLITE_OK ){
78909 return rc;
78926 rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);
78928 if( rc!=SQLITE_OK ){
78932 return rc;
78941 && SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))
78946 return rc;
78959 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
78962 rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);
78966 assert( rc!=SQLITE_BUSY );
78967 if( rc!=SQLITE_OK ){
78969 return rc;
78976 rc = sqlite3OsDelete(pVfs, zMaster, 1);
78979 if( rc ){
78980 return rc;
79005 return rc;
79052 int rc = SQLITE_OK;
79070 if( rc==SQLITE_OK ){
79071 rc = rc2;
79078 if( rc==SQLITE_OK ){
79080 rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint);
79082 if( rc==SQLITE_OK ){
79083 rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint);
79094 return rc;
79120 p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
79143 int rc; /* Used to store transient return codes */
79166 p->rc = SQLITE_NOMEM_BKPT;
79182 mrc = p->rc & 0xff;
79214 if( p->rc==SQLITE_OK ){
79228 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
79229 rc = sqlite3VdbeCheckFk(p, 1);
79230 if( rc!=SQLITE_OK ){
79235 rc = SQLITE_CONSTRAINT_FOREIGNKEY;
79241 rc = vdbeCommit(db, p);
79243 if( rc==SQLITE_BUSY && p->readOnly ){
79246 }else if( rc!=SQLITE_OK ){
79247 p->rc = rc;
79262 if( p->rc==SQLITE_OK || p->errorAction==OE_Fail ){
79281 rc = sqlite3VdbeCloseStatement(p, eStatementOp);
79282 if( rc ){
79283 if( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT ){
79284 p->rc = rc;
79323 p->rc = SQLITE_NOMEM_BKPT;
79335 return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);
79344 p->rc = SQLITE_OK;
79357 int rc = p->rc;
79368 db->errCode = rc;
79369 return rc;
79378 if( sqlite3GlobalConfig.xSqllog && v->rc==SQLITE_OK && v->zSql && v->pc>=0 ){
79427 }else if( p->rc && p->expired ){
79432 sqlite3ErrorWithMsg(db, p->rc, p->zErrMsg ? "%s" : 0, p->zErrMsg);
79488 return p->rc & db->errMask;
79496 int rc = SQLITE_OK;
79498 rc = sqlite3VdbeReset(p);
79499 assert( (rc & p->db->errMask)==rc );
79502 return rc;
79617 int res, rc;
79624 rc = sqlite3BtreeMovetoUnpacked(p->uc.pCursor, 0, p->movetoTarget, 0, &res);
79625 if( rc ) return rc;
79643 int isDifferentRow, rc;
79647 rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);
79650 return rc;
80171 int rc = 0;
80223 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
80225 if( rc!=0 ){
80228 rc = -rc; /* Invert the result for DESC sort order. */
80244 rc = pPKey2->default_rc;
80247 if( desiredResult==0 && rc==0 ) return 1;
80248 if( desiredResult<0 && rc<0 ) return 1;
80249 if( desiredResult>0 && rc>0 ) return 1;
80309 int rc;
80321 rc = 0;
80323 rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
80327 return rc;
80561 int rc = 0; /* Return value */
80601 rc = +1;
80603 rc = -1;
80606 rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);
80611 rc = -1;
80613 rc = +1;
80626 rc = +1;
80628 rc = -1;
80633 rc = -1;
80635 rc = +1;
80638 rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);
80648 rc = -1;
80650 rc = +1;
80665 rc = vdbeCompareMemString(
80670 rc = memcmp(&aKey1[d1], pRhs->z, nCmp);
80671 if( rc==0 ) rc = mem1.n - pRhs->n;
80682 rc = -1;
80692 rc = 1;
80694 rc = nStr - pRhs->u.nZero;
80698 rc = memcmp(&aKey1[d1], pRhs->z, nCmp);
80699 if( rc==0 ) rc = nStr - pRhs->n;
80707 rc = (serial_type!=0);
80710 if( rc!=0 ){
80712 rc = -rc;
80714 assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
80716 return rc;
80961 int rc;
80978 rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);
80979 if( rc ){
80980 return rc;
81045 int rc;
81060 rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);
81061 if( rc ){
81062 return rc;
81395 int rc;
81399 rc = SQLITE_OK;
81406 rc = sqlite3VdbeFinalize(v);
81407 rc = sqlite3ApiExit(db, rc);
81410 return rc;
81422 int rc;
81424 rc = SQLITE_OK;
81430 rc = sqlite3VdbeReset(v);
81432 assert( (rc & (db->errMask))==rc );
81433 rc = sqlite3ApiExit(db, rc);
81436 return rc;
81444 int rc = SQLITE_OK;
81459 return rc;
81819 int rc = SQLITE_OK;
81829 if( nEntry>0 && db->xWalCallback && rc==SQLITE_OK ){
81830 rc = db->xWalCallback(db->pWalArg, db, db->aDb[i].zDbSName, nEntry);
81835 return rc;
81850 int rc;
81871 if( (rc = p->rc&0xff)==SQLITE_BUSY || rc==SQLITE_LOCKED ){
81884 p->rc = SQLITE_NOMEM;
81889 p->rc = SQLITE_SCHEMA;
81890 rc = SQLITE_ERROR;
81925 rc = sqlite3VdbeList(p);
81930 rc = sqlite3VdbeExec(p);
81934 if( rc!=SQLITE_ROW ){
81940 if( rc==SQLITE_DONE && db->autoCommit ){
81941 assert( p->rc==SQLITE_OK );
81942 p->rc = doWalCallbacks(db);
81943 if( p->rc!=SQLITE_OK ){
81944 rc = SQLITE_ERROR;
81949 db->errCode = rc;
81950 if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){
81951 p->rc = SQLITE_NOMEM_BKPT;
81961 assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
81962 || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
81964 assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
81965 if( rc!=SQLITE_ROW
81966 && rc!=SQLITE_DONE
81973 rc = sqlite3VdbeTransferError(p);
81975 return (rc&db->errMask);
81984 int rc = SQLITE_OK; /* Result from sqlite3Step() */
81995 while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
81998 rc = sqlite3Reprepare(v);
81999 if( rc!=SQLITE_OK ){
82012 v->rc = rc = sqlite3ApiExit(db, rc);
82015 v->rc = rc = SQLITE_NOMEM_BKPT;
82024 return rc;
82079 int rc;
82088 rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
82089 if( rc ) *piTime = 0;
82335 p->rc = sqlite3ApiExit(p->db, p->rc);
82617 int rc;
82619 rc = vdbeUnbind(p, i);
82620 if( rc==SQLITE_OK ){
82623 rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
82624 if( rc==SQLITE_OK && encoding!=0 ){
82625 rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));
82627 if( rc ){
82628 sqlite3Error(p->db, rc);
82629 rc = sqlite3ApiExit(p->db, rc);
82636 return rc;
82670 int rc;
82672 rc = vdbeUnbind(p, i);
82673 if( rc==SQLITE_OK ){
82677 return rc;
82683 int rc;
82685 rc = vdbeUnbind(p, i);
82686 if( rc==SQLITE_OK ){
82690 return rc;
82693 int rc;
82695 rc = vdbeUnbind(p, i);
82696 if( rc==SQLITE_OK ){
82699 return rc;
82708 int rc;
82710 rc = vdbeUnbind(p, i);
82711 if( rc==SQLITE_OK ){
82717 return rc;
82756 int rc;
82759 rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
82763 rc = sqlite3_bind_double(pStmt, i, pValue->u.r);
82768 rc = sqlite3_bind_zeroblob(pStmt, i, pValue->u.nZero);
82770 rc = sqlite3_bind_blob(pStmt, i, pValue->z, pValue->n,SQLITE_TRANSIENT);
82775 rc = bindText(pStmt,i, pValue->z, pValue->n, SQLITE_TRANSIENT,
82780 rc = sqlite3_bind_null(pStmt, i);
82784 return rc;
82787 int rc;
82789 rc = vdbeUnbind(p, i);
82790 if( rc==SQLITE_OK ){
82794 return rc;
82797 int rc;
82801 rc = SQLITE_TOOBIG;
82804 rc = sqlite3_bind_zeroblob(pStmt, i, n);
82806 rc = sqlite3ApiExit(p->db, rc);
82808 return rc;
83058 int rc = SQLITE_OK;
83063 rc = SQLITE_MISUSE_BKPT;
83070 rc = SQLITE_RANGE;
83082 rc = sqlite3BtreePayload(p->pCsr->uc.pCursor, 0, nRec, aRec);
83083 if( rc==SQLITE_OK ){
83085 if( !p->pUnpacked ) rc = SQLITE_NOMEM;
83087 if( rc!=SQLITE_OK ){
83106 sqlite3Error(db, rc);
83107 return sqlite3ApiExit(db, rc);
83147 int rc = SQLITE_OK;
83151 rc = SQLITE_MISUSE_BKPT;
83158 rc = SQLITE_RANGE;
83168 rc = ExpandBlob(pData);
83169 if( rc!=SQLITE_OK ) goto preupdate_new_out;
83172 rc = SQLITE_NOMEM;
83193 rc = SQLITE_NOMEM;
83203 rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
83204 if( rc!=SQLITE_OK ) goto preupdate_new_out;
83211 sqlite3Error(db, rc);
83212 return sqlite3ApiExit(db, rc);
84196 int rc = SQLITE_OK; /* Value to return */
84226 if( p->rc==SQLITE_NOMEM ){
84231 assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY );
84269 assert( rc==SQLITE_OK );
84419 rc = SQLITE_INTERRUPT;
84606 p->rc = pOp->p1;
84610 if( p->rc ){
84627 rc = sqlite3VdbeHalt(p);
84628 assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );
84629 if( rc==SQLITE_BUSY ){
84630 p->rc = SQLITE_BUSY;
84632 assert( rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT );
84633 assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 );
84634 rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
84695 rc = sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC);
84696 assert( rc==SQLITE_OK || rc==SQLITE_TOOBIG );
84697 if( rc ) goto too_big;
84714 assert( rc==SQLITE_OK );
84970 if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){
84992 rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE);
84993 assert( rc==SQLITE_OK );
85020 rc = SQLITE_ROW;
85335 rc = SQLITE_MISMATCH;
85391 rc = ExpandBlob(pIn1);
85394 if( rc ) goto abort_due_to_error;
86079 rc = sqlite3VdbeCursorMoveto(&pC, &p2);
86080 if( rc ) goto abort_due_to_error;
86178 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, 0, aOffset[0], &sMem);
86179 if( rc!=SQLITE_OK ) goto abort_due_to_error;
86249 assert( rc==SQLITE_OK );
86301 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
86302 if( rc!=SQLITE_OK ) goto abort_due_to_error;
86318 rc = SQLITE_CORRUPT_BKPT;
86554 rc = sqlite3BtreeCount(pCrsr, &nEntry);
86555 if( rc ) goto abort_due_to_error;
86596 rc = SQLITE_BUSY;
86606 rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN,
86608 if( rc!=SQLITE_OK ) goto abort_due_to_error;
86647 rc = SQLITE_ERROR;
86654 rc = SQLITE_BUSY;
86663 if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
86670 p->rc = rc = SQLITE_BUSY;
86674 rc = p->rc;
86681 rc = sqlite3BtreeTripAllCursors(db->aDb[ii].pBt,
86684 if( rc!=SQLITE_OK ) goto abort_due_to_error;
86690 rc = sqlite3BtreeSavepoint(db->aDb[ii].pBt, p1, iSavepoint);
86691 if( rc!=SQLITE_OK ){
86728 rc = sqlite3VtabSavepoint(db, p1, iSavepoint);
86729 if( rc!=SQLITE_OK ) goto abort_due_to_error;
86733 if( rc ) goto abort_due_to_error;
86769 rc = SQLITE_BUSY;
86771 }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
86779 p->rc = rc = SQLITE_BUSY;
86784 if( p->rc==SQLITE_OK ){
86785 rc = SQLITE_DONE;
86787 rc = SQLITE_ERROR;
86796 rc = SQLITE_ERROR;
86845 rc = SQLITE_READONLY;
86851 rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, &iMeta);
86852 testcase( rc==SQLITE_BUSY_SNAPSHOT );
86853 testcase( rc==SQLITE_BUSY_RECOVERY );
86854 if( rc!=SQLITE_OK ){
86855 if( (rc&0xff)==SQLITE_BUSY ){
86857 p->rc = rc;
86873 rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p->iStatement-1);
86874 if( rc==SQLITE_OK ){
86875 rc = sqlite3BtreeBeginStmt(pBt, p->iStatement);
86914 rc = SQLITE_SCHEMA;
86916 if( rc ) goto abort_due_to_error;
86973 rc = sqlite3BtreeUpdateMeta(pDb->pBt, pOp->p2, pOp->p3);
86988 if( rc ) goto abort_due_to_error;
87104 rc = SQLITE_ABORT_ROLLBACK;
87161 rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->uc.pCursor);
87178 if( rc ) goto abort_due_to_error;
87205 rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
87210 assert( rc==SQLITE_OK );
87261 rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
87267 rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
87270 if( rc==SQLITE_OK ){
87271 rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
87273 if( rc==SQLITE_OK ){
87281 rc = sqlite3BtreeCreateTable(pCx->pBtx, (int*)&pCx->pgnoRoot,
87283 if( rc==SQLITE_OK ){
87287 rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
87293 rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,
87300 if( rc ) goto abort_due_to_error;
87324 rc = sqlite3VdbeSorterInit(db, pOp->p3, pCx);
87325 if( rc ) goto abort_due_to_error;
87576 rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)iKey, 0, &res);
87578 if( rc!=SQLITE_OK ){
87620 rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, &r, 0, 0, &res);
87621 if( rc!=SQLITE_OK ){
87637 rc = sqlite3BtreeNext(pC->uc.pCursor, 0);
87638 if( rc!=SQLITE_OK ){
87639 if( rc==SQLITE_DONE ){
87640 rc = SQLITE_OK;
87653 rc = sqlite3BtreePrevious(pC->uc.pCursor, 0);
87654 if( rc!=SQLITE_OK ){
87655 if( rc==SQLITE_DONE ){
87656 rc = SQLITE_OK;
87836 rc = ExpandBlob(pIn3);
87837 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
87838 if( rc ) goto no_mem;
87856 rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res);
87858 if( rc!=SQLITE_OK ){
87958 rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
87959 assert( rc==SQLITE_OK || res==0 );
87967 assert( rc==SQLITE_OK );
87969 rc = SQLITE_CORRUPT_BKPT;
87974 if( rc ) goto abort_due_to_error;
88055 rc = sqlite3BtreeLast(pC->uc.pCursor, &res);
88056 if( rc!=SQLITE_OK ){
88093 rc = SQLITE_FULL; /* IMP: R-17817-00630 */
88113 }while( ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v,
88117 if( rc ) goto abort_due_to_error;
88119 rc = SQLITE_FULL; /* IMP: R-38219-53002 */
88231 rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,
88238 if( rc ) goto abort_due_to_error;
88362 rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);
88365 if( rc ) goto abort_due_to_error;
88418 rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);
88420 if( rc ) goto abort_due_to_error;
88443 rc = sqlite3VdbeSorterRowkey(pC, pOut);
88444 assert( rc!=SQLITE_OK || (pOut->flags & MEM_Blob) );
88446 if( rc ) goto abort_due_to_error;
88506 rc = sqlite3VdbeCursorMoveto(pC);
88507 if( rc!=SQLITE_OK ) goto abort_due_to_error;
88515 rc = sqlite3VdbeMemFromBtree(pCrsr, 0, n, pOut);
88516 if( rc ) goto abort_due_to_error;
88555 rc = pModule->xRowid(pC->uc.pVCur, &v);
88557 if( rc ) goto abort_due_to_error;
88562 rc = sqlite3VdbeCursorRestore(pC);
88563 if( rc ) goto abort_due_to_error;
88643 rc = sqlite3BtreeLast(pCrsr, &res);
88647 if( rc ) goto abort_due_to_error;
88671 rc = sqlite3BtreeFirst(pCrsr, &res);
88672 if( rc ) goto abort_due_to_error;
88740 rc = sqlite3VdbeSorterRewind(pC, &res);
88745 rc = sqlite3BtreeFirst(pCrsr, &res);
88749 if( rc ) goto abort_due_to_error;
88822 rc = sqlite3VdbeSorterNext(db, pC);
88846 rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
88849 VdbeBranchTaken(rc==SQLITE_OK,2);
88850 if( rc==SQLITE_OK ){
88858 if( rc!=SQLITE_DONE ) goto abort_due_to_error;
88859 rc = SQLITE_OK;
88914 rc = ExpandBlob(pIn2);
88915 if( rc ) goto abort_due_to_error;
88917 rc = sqlite3VdbeSorterWrite(pC, pIn2);
88923 rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,
88930 if( rc) goto abort_due_to_error;
88961 rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
88962 if( rc ) goto abort_due_to_error;
88964 rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
88965 if( rc ) goto abort_due_to_error;
89018 rc = sqlite3VdbeCursorRestore(pC);
89023 if( NEVER(rc!=SQLITE_OK) ) goto abort_due_to_error;
89027 rc = sqlite3VdbeIdxRowid(db, pC->uc.pCursor, &rowid);
89028 if( rc!=SQLITE_OK ){
89136 rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
89146 if( rc ) goto abort_due_to_error;
89188 rc = SQLITE_LOCKED;
89195 rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);
89198 if( rc ) goto abort_due_to_error;
89236 rc = sqlite3BtreeClearTable(
89247 if( rc ) goto abort_due_to_error;
89270 rc = sqlite3BtreeClearTableOfCursor(pC->uc.pCursor);
89271 if( rc ) goto abort_due_to_error;
89298 rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, pOp->p3);
89299 if( rc ) goto abort_due_to_error;
89311 rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);
89313 if( rc ) goto abort_due_to_error;
89350 rc = sqlite3InitOne(db, iDb, &p->zErrMsg, INITFLAG_AlterTable);
89365 rc = SQLITE_NOMEM_BKPT;
89369 initData.rc = SQLITE_OK;
89372 rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
89373 if( rc==SQLITE_OK ) rc = initData.rc;
89374 if( rc==SQLITE_OK && initData.nInitRow==0 ){
89378 rc = SQLITE_CORRUPT_BKPT;
89384 if( rc ){
89386 if( rc==SQLITE_NOMEM ){
89403 rc = sqlite3AnalysisLoad(db, pOp->p1);
89404 if( rc ) goto abort_due_to_error;
89658 rc = SQLITE_ERROR;
90074 rc = pCtx->isError;
90085 if( rc ) goto abort_due_to_error;
90128 rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);
90133 rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
90136 if( rc ){
90173 rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &aRes[1], &aRes[2]);
90174 if( rc ){
90175 if( rc!=SQLITE_BUSY ) goto abort_due_to_error;
90176 rc = SQLITE_OK;
90243 rc = SQLITE_ERROR;
90257 rc = sqlite3PagerCloseWal(pPager, db);
90258 if( rc==SQLITE_OK ){
90271 if( rc==SQLITE_OK ){
90272 rc = sqlite3BtreeSetVersion(pBt, (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));
90278 if( rc ) eNew = eOld;
90286 if( rc ) goto abort_due_to_error;
90303 rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1,
90305 if( rc ) goto abort_due_to_error;
90324 rc = sqlite3BtreeIncrVacuum(pBt);
90325 VdbeBranchTaken(rc==SQLITE_DONE,2);
90326 if( rc ){
90327 if( rc!=SQLITE_DONE ) goto abort_due_to_error;
90328 rc = SQLITE_OK;
90384 rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
90385 if( rc ){
90386 if( (rc&0xFF)==SQLITE_LOCKED ){
90410 rc = sqlite3VtabBegin(db, pVTab);
90412 if( rc ) goto abort_due_to_error;
90433 rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]);
90434 assert( rc==SQLITE_OK );
90438 rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);
90441 if( rc ) goto abort_due_to_error;
90454 rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
90457 if( rc ) goto abort_due_to_error;
90480 rc = SQLITE_LOCKED;
90484 rc = pModule->xOpen(pVtab, &pVCur);
90486 if( rc ) goto abort_due_to_error;
90559 rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);
90561 if( rc ) goto abort_due_to_error;
90613 rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2);
90617 rc = sContext.isError;
90626 if( rc ) goto abort_due_to_error;
90660 rc = pModule->xNext(pCur->uc.pVCur);
90662 if( rc ) goto abort_due_to_error;
90697 rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);
90698 if( rc ) goto abort_due_to_error;
90699 rc = pVtab->pModule->xRename(pVtab, pName->z);
90703 if( rc ) goto abort_due_to_error;
90753 rc = SQLITE_LOCKED;
90770 rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
90773 if( rc==SQLITE_OK && pOp->p1 ){
90777 if( (rc&0xff)==SQLITE_CONSTRAINT && pOp->p4.pVtab->bConstraint ){
90779 rc = SQLITE_OK;
90786 if( rc ) goto abort_due_to_error;
90929 rc = pCtx->isError;
90933 if( rc ) goto abort_due_to_error;
91128 if( rc!=0 ) printf("rc=%d\n",rc);
91144 if( db->mallocFailed ) rc = SQLITE_NOMEM_BKPT;
91145 assert( rc );
91146 if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){
91147 sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc));
91149 p->rc = rc;
91150 sqlite3SystemError(db, rc);
91152 sqlite3_log(rc, "statement aborts at %d: [%s] %s",
91155 if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db);
91156 rc = SQLITE_ERROR;
91170 rc = SQLITE_INTERRUPT;
91177 assert( rc!=SQLITE_OK || nExtraDelete==0
91180 return rc;
91187 rc = SQLITE_TOOBIG;
91195 rc = SQLITE_NOMEM_BKPT;
91203 rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;
91204 p->rc = rc;
91205 sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc));
91266 int rc; /* Error code */
91283 rc = sqlite3VdbeExec(v);
91285 rc = sqlite3_step(p->pStmt);
91287 if( rc==SQLITE_ROW ){
91296 rc = SQLITE_ERROR;
91307 if( rc==SQLITE_ROW ){
91308 rc = SQLITE_OK;
91310 rc = sqlite3_finalize(p->pStmt);
91312 if( rc==SQLITE_OK ){
91314 rc = SQLITE_ERROR;
91320 assert( rc!=SQLITE_OK || zErr==0 );
91321 assert( rc!=SQLITE_ROW && rc!=SQLITE_DONE );
91324 return rc;
91341 int rc = SQLITE_OK;
91392 rc = SQLITE_ERROR;
91408 rc = SQLITE_ERROR;
91448 rc = SQLITE_ERROR;
91541 rc = blobSeekToRow(pBlob, iRow, &zErr);
91542 } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );
91545 if( rc==SQLITE_OK && db->mallocFailed==0 ){
91551 sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
91554 rc = sqlite3ApiExit(db, rc);
91556 return rc;
91565 int rc;
91571 rc = sqlite3_finalize(p->pStmt);
91575 rc = SQLITE_OK;
91577 return rc;
91590 int rc;
91602 rc = SQLITE_ERROR;
91607 rc = SQLITE_ABORT;
91638 rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);
91640 if( rc==SQLITE_ABORT ){
91644 v->rc = rc;
91647 sqlite3Error(db, rc);
91648 rc = sqlite3ApiExit(db, rc);
91650 return rc;
91689 int rc;
91701 rc = SQLITE_ABORT;
91704 rc = blobSeekToRow(p, iRow, &zErr);
91705 if( rc!=SQLITE_OK ){
91706 sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
91709 assert( rc!=SQLITE_SCHEMA );
91712 rc = sqlite3ApiExit(db, rc);
91713 assert( rc==SQLITE_OK || p->pStmt==0 );
91715 return rc;
92229 int rc; /* sqlite3OsRead() return code */
92240 rc = sqlite3OsRead(p->pFd, p->aBuffer, nRead, p->iReadOff);
92241 assert( rc!=SQLITE_IOERR_SHORT_READ );
92242 if( rc!=SQLITE_OK ) return rc;
92278 int rc; /* vdbePmaReadBlob() return code */
92284 rc = vdbePmaReadBlob(p, nCopy, &aNext);
92285 if( rc!=SQLITE_OK ) return rc;
92312 int i = 0, rc;
92314 rc = vdbePmaReadBlob(p, 1, &a);
92315 if( rc ) return rc;
92335 int rc = SQLITE_OK;
92339 rc = sqlite3OsFetch(pFd, 0, (int)pFile->iEof, (void**)pp);
92340 testcase( rc!=SQLITE_OK );
92343 return rc;
92357 int rc = SQLITE_OK;
92370 rc = vdbeSorterMapFile(pTask, pFile, &pReadr->aMap);
92371 if( rc==SQLITE_OK && pReadr->aMap==0 ){
92376 if( pReadr->aBuffer==0 ) rc = SQLITE_NOMEM_BKPT;
92379 if( rc==SQLITE_OK && iBuf ){
92384 rc = sqlite3OsRead(
92387 testcase( rc!=SQLITE_OK );
92391 return rc;
92399 int rc = SQLITE_OK; /* Return Code */
92407 rc = vdbeIncrSwap(pIncr);
92408 if( rc==SQLITE_OK && pIncr->bEof==0 ){
92409 rc = vdbePmaReaderSeek(
92419 testcase( rc!=SQLITE_OK );
92420 return rc;
92424 if( rc==SQLITE_OK ){
92425 rc = vdbePmaReadVarint(pReadr, &nRec);
92427 if( rc==SQLITE_OK ){
92429 rc = vdbePmaReadBlob(pReadr, (int)nRec, &pReadr->aKey);
92430 testcase( rc!=SQLITE_OK );
92433 return rc;
92452 int rc;
92459 rc = vdbePmaReaderSeek(pTask, pReadr, pFile, iStart);
92460 if( rc==SQLITE_OK ){
92462 rc = vdbePmaReadVarint(pReadr, &nByte);
92467 if( rc==SQLITE_OK ){
92468 rc = vdbePmaReaderNext(pReadr);
92470 return rc;
92658 int rc = SQLITE_OK;
92690 rc = SQLITE_NOMEM_BKPT;
92730 if( !pSorter->list.aMemory ) rc = SQLITE_NOMEM_BKPT;
92741 return rc;
92827 int rc = SQLITE_OK;
92836 rc = SQLITE_PTR_TO_INT(pRet);
92841 return rc;
92861 int rc = rcin;
92874 if( rc==SQLITE_OK ) rc = rc2;
92876 return rc;
93023 int rc;
93025 rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,
93028 SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE, &rc
93030 if( rc==SQLITE_OK ){
93037 return rc;
93119 int rc;
93121 rc = vdbeSortAllocUnpacked(pTask);
93122 if( rc!=SQLITE_OK ) return rc;
93227 int rc;
93236 rc = p->eFWErr;
93238 return rc;
93268 int rc = SQLITE_OK; /* Return code */
93283 rc = vdbeSorterOpenTempFile(db, 0, &pTask->file.pFd);
93284 assert( rc!=SQLITE_OK || pTask->file.pFd );
93290 if( rc==SQLITE_OK ){
93295 if( rc==SQLITE_OK ){
93296 rc = vdbeSorterSort(pTask, pList);
93299 if( rc==SQLITE_OK ){
93314 rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);
93318 assert( rc!=SQLITE_OK || pList->pList==0 );
93319 assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );
93320 return rc;
93334 int rc;
93339 rc = vdbePmaReaderNext(&pMerger->aReadr[iPrev]);
93342 if( rc==SQLITE_OK ){
93394 return (rc==SQLITE_OK ? pTask->pUnpacked->errCode : rc);
93403 int rc; /* Return code */
93405 rc = vdbeSorterListToPMA(pTask, &pTask->list);
93407 return SQLITE_INT_TO_PTR(rc);
93420 int rc = SQLITE_OK;
93441 rc = vdbeSorterJoinThread(pTask);
93443 if( rc!=SQLITE_OK || pTask->pThread==0 ) break;
93446 if( rc==SQLITE_OK ){
93449 rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker], &pSorter->list);
93471 rc = vdbeSorterCreateThread(pTask, vdbeSorterFlushThread, pCtx);
93475 return rc;
93487 int rc = SQLITE_OK; /* Return Code */
93535 rc = vdbeSorterFlushPMA(pSorter);
93538 assert( rc!=SQLITE_OK || pSorter->list.pList==0 );
93586 return rc;
93595 int rc = SQLITE_OK;
93607 while( rc==SQLITE_OK ){
93622 rc = vdbeMergeEngineStep(pIncr->pMerger, &dummy);
93626 if( rc==SQLITE_OK ) rc = rc2;
93628 return rc;
93671 int rc = SQLITE_OK;
93675 rc = vdbeSorterJoinThread(pIncr->pTask);
93677 if( rc==SQLITE_OK ){
93683 if( rc==SQLITE_OK ){
93687 rc = vdbeIncrBgPopulate(pIncr);
93693 rc = vdbeIncrPopulate(pIncr);
93700 return rc;
93714 int rc = SQLITE_OK;
93724 rc = SQLITE_NOMEM_BKPT;
93726 return rc;
93833 int rc = SQLITE_OK; /* Return code */
93858 rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);
93860 rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i], INCRINIT_NORMAL);
93862 if( rc!=SQLITE_OK ) return rc;
93905 int rc = SQLITE_OK;
93913 rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);
93918 if( rc==SQLITE_OK ){
93922 rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);
93923 if( rc==SQLITE_OK ){
93924 rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);
93931 rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);
93934 if( rc==SQLITE_OK ){
93943 if( rc==SQLITE_OK && pIncr->bUseThread ){
93955 rc = vdbeIncrPopulate(pIncr);
93959 if( rc==SQLITE_OK && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK) ){
93960 rc = vdbePmaReaderNext(pReadr);
93963 return rc;
93994 int rc = SQLITE_OK; /* Return code */
94000 rc = vdbeSorterCreateThread(pIncr->pTask, vdbePmaReaderBgIncrInit, pCtx);
94004 rc = vdbePmaReaderIncrMergeInit(pReadr, eMode);
94007 return rc;
94031 int rc = SQLITE_OK;
94034 if( pNew==0 ) rc = SQLITE_NOMEM_BKPT;
94036 for(i=0; i<nPMA && rc==SQLITE_OK; i++){
94039 rc = vdbePmaReaderInit(pTask, &pTask->file, iOff, pReadr, &nDummy);
94043 if( rc!=SQLITE_OK ){
94048 return rc;
94086 int rc = SQLITE_OK;
94092 rc = vdbeIncrMergerNew(pTask, pLeaf, &pIncr);
94098 for(i=1; i<nDepth && rc==SQLITE_OK; i++){
94105 rc = SQLITE_NOMEM_BKPT;
94107 rc = vdbeIncrMergerNew(pTask, pNew, &pReadr->pIncr);
94110 if( rc==SQLITE_OK ){
94116 if( rc==SQLITE_OK ){
94121 return rc;
94140 int rc = SQLITE_OK;
94150 if( pMain==0 ) rc = SQLITE_NOMEM_BKPT;
94154 for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){
94163 rc = vdbeMergeEngineLevel0(pTask, pTask->nPMA, &iReadOff, &pRoot);
94168 if( pRoot==0 ) rc = SQLITE_NOMEM_BKPT;
94169 for(i=0; i<pTask->nPMA && rc==SQLITE_OK; i += SORTER_MAX_MERGE_COUNT){
94174 rc = vdbeMergeEngineLevel0(pTask, nReader, &iReadOff, &pMerger);
94175 if( rc==SQLITE_OK ){
94176 rc = vdbeSorterAddToTree(pTask, nDepth, iSeq++, pRoot, pMerger);
94181 if( rc==SQLITE_OK ){
94184 rc = vdbeIncrMergerNew(pTask, pRoot, &pMain->aReadr[iTask].pIncr);
94197 if( rc!=SQLITE_OK ){
94202 return rc;
94215 int rc; /* Return code */
94227 rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);
94228 if( rc==SQLITE_OK ){
94235 rc = vdbeSortAllocUnpacked(pLast);
94236 if( rc==SQLITE_OK ){
94239 if( pReadr==0 ) rc = SQLITE_NOMEM_BKPT;
94241 if( rc==SQLITE_OK ){
94242 rc = vdbeIncrMergerNew(pLast, pMain, &pReadr->pIncr);
94243 if( rc==SQLITE_OK ){
94252 for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){
94267 rc = vdbePmaReaderIncrInit(p, INCRINIT_TASK);
94272 if( rc==SQLITE_OK ){
94273 rc = vdbePmaReaderIncrMergeInit(pReadr, INCRINIT_ROOT);
94278 rc = vdbeMergeEngineInit(pTask0, pMain, INCRINIT_NORMAL);
94284 if( rc!=SQLITE_OK ){
94287 return rc;
94298 int rc = SQLITE_OK; /* Return code */
94310 rc = vdbeSorterSort(&pSorter->aTask[0], &pSorter->list);
94314 return rc;
94322 rc = vdbeSorterFlushPMA(pSorter);
94325 rc = vdbeSorterJoinAll(pSorter, rc);
94332 if( rc==SQLITE_OK ){
94333 rc = vdbeSorterSetupMerge(pSorter);
94338 return rc;
94350 int rc; /* Return code */
94361 rc = vdbePmaReaderNext(pSorter->pReader);
94362 if( rc==SQLITE_OK && pSorter->pReader->pFd==0 ) rc = SQLITE_DONE;
94369 rc = vdbeMergeEngineStep(pSorter->pMerger, &res);
94370 if( rc==SQLITE_OK && res ) rc = SQLITE_DONE;
94377 rc = pSorter->list.pList ? SQLITE_OK : SQLITE_DONE;
94379 return rc;
94636 int rc;
94641 rc = sqlite3OsOpen(copy.pVfs, copy.zJournal, pReal, copy.flags, 0);
94642 if( rc==SQLITE_OK ){
94650 rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nChunk, iOff);
94651 if( rc ) break;
94654 if( rc==SQLITE_OK ){
94659 if( rc!=SQLITE_OK ){
94667 return rc;
94687 int rc = memjrnlCreateFile(p);
94688 if( rc==SQLITE_OK ){
94689 rc = sqlite3OsWrite(pJfd, zBuf, iAmt, iOfst);
94691 return rc;
94881 int rc = SQLITE_OK;
94896 rc = memjrnlCreateFile(p);
94898 return rc;
94976 int rc;
94980 rc = pWalker->xExprCallback(pWalker, pExpr);
94981 if( rc ) return rc & WRC_Abort;
95039 int rc = walkWindowList(pWalker, p->pWinDefn);
95040 assert( rc==WRC_Continue );
95041 return rc;
95093 int rc;
95097 rc = pWalker->xSelectCallback(pWalker, p);
95098 if( rc ) return rc & WRC_Abort;
96047 int rc = resolveExprStep(pWalker, pRight);
96048 if( rc==WRC_Abort ) return WRC_Abort;
96155 int rc; /* Return code from subprocedures */
96172 rc = sqlite3ResolveExprNames(&nc, pE);
96174 if( rc ) return 0;
96868 int rc;
96883 if( (rc = sqlite3ResolveExprNames(&sNC, pExpr))!=SQLITE_OK ) return rc;
96884 if( pList ) rc = sqlite3ResolveExprListNames(&sNC, pList);
96885 return rc;
97514 int rc = SQLITE_OK;
97520 rc = SQLITE_ERROR;
97522 return rc;
98972 int rc = 0;
98978 || sqlite3GetInt32(p->u.zToken, &rc)==0 );
98986 rc = sqlite3ExprIsInteger(p->pLeft, pValue);
98994 rc = 1;
99000 return rc;
102684 int rc;
102685 rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);
102686 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
102687 if( rc!=SQLITE_OK ){
103296 int rc;
103308 rc = sqlite3RunParser(p, zSql, &zErr);
103310 assert( rc!=SQLITE_OK || zErr==0 );
103312 if( db->mallocFailed ) rc = SQLITE_NOMEM;
103313 if( rc==SQLITE_OK
103316 rc = SQLITE_CORRUPT_BKPT;
103322 if( rc==SQLITE_OK ){
103332 return rc;
103354 int rc = SQLITE_OK;
103413 rc = SQLITE_NOMEM;
103417 return rc;
103431 int rc = SQLITE_OK;
103443 rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab);
103447 if( rc==SQLITE_OK && pNew->pWhen ){
103448 rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
103451 for(pStep=pNew->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext){
103454 if( pParse->nErr ) rc = pParse->rc;
103456 if( rc==SQLITE_OK && pStep->zTarget ){
103459 rc = SQLITE_ERROR;
103460 }else if( SQLITE_OK==(rc = sqlite3ViewGetColumnNames(pParse, pTarget)) ){
103468 rc = sqlite3ResolveExprNames(&sNC, pStep->pWhere);
103470 if( rc==SQLITE_OK ){
103471 rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList);
103476 assert( rc==SQLITE_OK );
103480 rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
103481 if( rc==SQLITE_OK ){
103483 rc = sqlite3ResolveExprListNames(&sNC, pUpsertSet);
103485 if( rc==SQLITE_OK ){
103486 rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertWhere);
103488 if( rc==SQLITE_OK ){
103489 rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);
103497 return rc;
103584 int rc;
103612 rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp);
103622 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
103626 sParse.rc = SQLITE_OK;
103628 rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);
103629 if( rc==SQLITE_OK ){
103632 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
103674 rc = renameResolveTrigger(&sParse, (bTemp ? 0 : zDb));
103675 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
103701 assert( rc==SQLITE_OK );
103702 rc = renameEditSql(context, &sCtx, zSql, zNew, bQuote);
103705 if( rc!=SQLITE_OK ){
103709 sqlite3_result_error_code(context, rc);
103789 int rc;
103809 rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
103811 if( rc==SQLITE_OK ){
103823 if( sParse.nErr ) rc = sParse.rc;
103870 rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
103871 if( rc==SQLITE_OK ){
103884 if( rc==SQLITE_OK ){
103885 rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
103887 if( rc!=SQLITE_OK ){
103891 sqlite3_result_error_code(context, rc);
103943 int rc;
103945 rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
103946 if( rc==SQLITE_OK ){
103952 if( sParse.nErr ) rc = sParse.rc;
103957 rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
103959 if( rc==SQLITE_OK ){
103967 if( rc!=SQLITE_OK ){
105698 int rc; /* Result codes from subroutines */
105709 rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
105711 if( rc ) return rc;
105758 rc = sqlite3_finalize(pStmt);
105759 if( rc ) return rc;
105765 rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
105767 if( rc ) return rc;
105808 rc = sqlite3_finalize(pStmt);
105809 if( rc==SQLITE_OK ) initAvgEq(pPrevIdx);
105810 return rc;
105818 int rc = SQLITE_OK; /* Result codes from subroutines */
105822 rc = loadStatTbl(db, 0,
105829 if( rc==SQLITE_OK && sqlite3FindTable(db, "sqlite_stat3", zDb) ){
105830 rc = loadStatTbl(db, 1,
105837 return rc;
105865 int rc = SQLITE_OK;
105893 rc = SQLITE_NOMEM_BKPT;
105895 rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
105909 if( rc==SQLITE_OK ){
105911 rc = loadStat4(db, sInfo.zDatabase);
105921 if( rc==SQLITE_NOMEM ){
105924 return rc;
105968 int rc = SQLITE_OK;
105971 rc = sqlite3ResolveExprNames(pName, pExpr);
105976 return rc;
106000 int rc = 0;
106034 rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNew->pBt, 0, SQLITE_OPEN_MAIN_DB);
106079 rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr);
106080 if( rc!=SQLITE_OK ){
106081 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
106088 rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
106093 if( rc==SQLITE_CONSTRAINT ){
106094 rc = SQLITE_ERROR;
106096 }else if( rc==SQLITE_OK ){
106100 rc = SQLITE_NOMEM_BKPT;
106104 rc = SQLITE_ERROR;
106118 if( rc==SQLITE_OK && pNew->zDbSName==0 ){
106119 rc = SQLITE_NOMEM_BKPT;
106124 if( rc==SQLITE_OK ){
106134 rc = SQLITE_ERROR;
106141 rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
106150 rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
106164 if( rc==SQLITE_OK ){
106169 rc = sqlite3Init(db, &zErrDyn);
106172 assert( zErrDyn==0 || rc!=SQLITE_OK );
106175 if( rc==SQLITE_OK && !REOPEN_AS_MEMDB(db) ){
106177 rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);
106179 rc = SQLITE_AUTH_USER;
106183 if( rc ){
106194 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
106213 if( rc ) sqlite3_result_error_code(context, rc);
106280 int rc;
106291 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
106292 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
106293 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
106306 rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);
106307 if(rc!=SQLITE_OK ){
106657 pParse->rc = SQLITE_ERROR;
106677 int rc; /* Auth callback return code */
106680 rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext
106685 if( rc==SQLITE_DENY ){
106689 pParse->rc = SQLITE_AUTH;
106690 }else if( rc!=SQLITE_IGNORE && rc!=SQLITE_OK ){
106693 return rc;
106771 int rc;
106796 rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext
106801 if( rc==SQLITE_DENY ){
106803 pParse->rc = SQLITE_AUTH;
106804 }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){
106805 rc = SQLITE_DENY;
106808 return rc;
106981 if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;
106999 pParse->rc = SQLITE_AUTH_USER;
107073 pParse->rc = SQLITE_DONE;
107075 pParse->rc = SQLITE_ERROR;
107107 if( !db->mallocFailed ) pParse->rc = SQLITE_TOOBIG;
107812 pParse->rc = SQLITE_NOMEM_BKPT;
109141 int rc;
109151 rc = sqlite3VtabCallConnect(pParse, pTable);
109153 if( rc ){
110349 pParse->rc = SQLITE_CORRUPT_BKPT;
111091 int rc;
111100 rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags);
111101 if( rc!=SQLITE_OK ){
111104 pParse->rc = rc;
111273 int rc;
111277 rc = SQLITE_CONSTRAINT_PRIMARYKEY;
111280 rc = SQLITE_CONSTRAINT_ROWID;
111282 sqlite3HaltConstraint(pParse, rc, onError, zMsg, P4_DYNAMIC,
111443 assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );
111453 pParse->rc = SQLITE_ERROR_RETRY;
111640 pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
114164 int rc;
114169 rc = sqlite3_result_zeroblob64(context, n); /* IMP: R-00293-64994 */
114170 if( rc ){
114171 sqlite3_result_error_code(context, rc);
114783 int rc = sqlite3_overload_function(db, "MATCH", 2);
114784 assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );
114785 if( rc==SQLITE_NOMEM ){
116700 pParse->rc = SQLITE_CORRUPT_SEQUENCE;
117154 int rc; /* Result code */
117162 rc = sqlite3Select(pParse, pSelect, &dest);
117164 if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;
118941 int rc = SQLITE_OK; /* Return code */
118952 while( rc==SQLITE_OK && zSql[0] ){
118957 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
118958 assert( rc==SQLITE_OK || pStmt==0 );
118959 if( rc!=SQLITE_OK ){
118971 rc = sqlite3_step(pStmt);
118974 if( xCallback && (SQLITE_ROW==rc ||
118975 (SQLITE_DONE==rc && !callbackIsInit
118991 if( rc==SQLITE_ROW ){
119006 rc = SQLITE_ABORT;
119014 if( rc!=SQLITE_ROW ){
119015 rc = sqlite3VdbeFinalize((Vdbe *)pStmt);
119031 rc = sqlite3ApiExit(db, rc);
119032 if( rc!=SQLITE_OK && pzErrMsg ){
119035 rc = SQLITE_NOMEM_BKPT;
119042 assert( (rc&db->errMask)==rc );
119044 return rc;
120180 int rc;
120281 rc = xInit(db, &zErrmsg, &sqlite3Apis);
120282 if( rc ){
120283 if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;
120312 int rc;
120314 rc = sqlite3LoadExtension(db, zFile, zProc, pzErrMsg);
120315 rc = sqlite3ApiExit(db, rc);
120317 return rc;
120386 int rc = SQLITE_OK;
120388 rc = sqlite3_initialize();
120389 if( rc ){
120390 return rc;
120408 rc = SQLITE_NOMEM_BKPT;
120416 assert( (rc&0xff)==rc );
120417 return rc;
120480 int rc;
120507 if( xInit && (rc = xInit(db, &zErrmsg, pThunk))!=0 ){
120508 sqlite3ErrorWithMsg(db, rc,
121473 int upr, lwr, mid = 0, rc;
121478 rc = sqlite3_stricmp(zName, aPragmaName[mid].zName);
121479 if( rc==0 ) break;
121480 if( rc<0 ){
121533 int rc; /* return value form SQLITE_FCNTL_PRAGMA */
121590 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
121591 if( rc==SQLITE_OK ){
121598 if( rc!=SQLITE_NOTFOUND ){
121604 pParse->rc = rc;
121896 rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
121897 if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){
122047 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_MMAP_SIZE, &sz);
122050 rc = SQLITE_OK;
122052 if( rc==SQLITE_OK ){
122054 }else if( rc!=SQLITE_NOTFOUND ){
122056 pParse->rc = rc;
122098 rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);
122099 if( rc!=SQLITE_OK || res==0 ){
122142 rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);
122143 if( rc!=SQLITE_OK || res==0 ){
123408 int rc;
123438 rc = sqlite3_declare_vtab(db, zBuf);
123439 if( rc==SQLITE_OK ){
123442 rc = SQLITE_NOMEM;
123455 return rc;
123543 int rc = SQLITE_OK;
123549 rc = sqlite3_finalize(pCsr->pPragma);
123553 return rc;
123566 int rc;
123597 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pPragma, 0);
123599 if( rc!=SQLITE_OK ){
123601 return rc;
123718 pData->rc = SQLITE_NOMEM_BKPT;
123723 pData->rc = SQLITE_ERROR;
123725 pData->rc = SQLITE_CORRUPT_BKPT;
123732 pData->rc = SQLITE_CORRUPT_BKPT;
123786 int rc;
123796 rc = db->errCode;
123797 assert( (rc&0xFF)==(rcp&0xFF) );
123800 if( SQLITE_OK!=rc ){
123804 pData->rc = rc;
123805 if( rc==SQLITE_NOMEM ){
123807 }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
123844 int rc;
123876 initData.rc = SQLITE_OK;
123881 if( initData.rc ){
123882 rc = initData.rc;
123892 rc = SQLITE_OK;
123901 rc = sqlite3BtreeBeginTrans(pDb->pBt, 0, 0);
123902 if( rc!=SQLITE_OK ){
123903 sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));
123955 rc = SQLITE_ERROR;
123987 rc = SQLITE_ERROR;
124014 rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
124019 if( rc==SQLITE_OK ) rc = initData.rc;
124022 if( rc==SQLITE_OK ){
124028 rc = SQLITE_NOMEM_BKPT;
124031 if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
124041 rc = SQLITE_OK;
124055 if( rc ){
124056 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
124062 return rc;
124076 int i, rc;
124086 rc = sqlite3InitOne(db, 0, pzErrMsg, 0);
124087 if( rc ) return rc;
124093 rc = sqlite3InitOne(db, i, pzErrMsg, 0);
124094 if( rc ) return rc;
124108 int rc = SQLITE_OK;
124112 rc = sqlite3Init(db, &pParse->zErrMsg);
124113 if( rc!=SQLITE_OK ){
124114 pParse->rc = rc;
124120 return rc;
124132 int rc;
124146 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
124147 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
124150 if( rc!=SQLITE_OK ) return;
124161 pParse->rc = SQLITE_SCHEMA;
124231 int rc = SQLITE_OK; /* Result code */
124278 rc = sqlite3BtreeSchemaLocked(pBt);
124279 if( rc ){
124281 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
124298 rc = sqlite3ApiExit(db, SQLITE_TOOBIG);
124314 if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
124319 sParse.rc = SQLITE_NOMEM_BKPT;
124324 rc = sParse.rc;
124327 if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
124352 if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
124360 sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg);
124363 sqlite3Error(db, rc);
124376 return rc;
124387 int rc;
124403 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
124404 assert( rc==SQLITE_OK || *ppStmt==0 );
124405 }while( rc==SQLITE_ERROR_RETRY
124406 || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
124408 rc = sqlite3ApiExit(db, rc);
124409 assert( (rc&db->errMask)==rc );
124411 return rc;
124424 int rc;
124436 rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);
124437 if( rc ){
124438 if( rc==SQLITE_NOMEM ){
124442 return rc;
124469 int rc;
124470 rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
124471 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
124472 return rc;
124481 int rc;
124487 rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
124489 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );
124490 return rc;
124500 int rc;
124508 rc = sqlite3LockAndPrepare(db,zSql,nBytes,
124511 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );
124512 return rc;
124534 int rc = SQLITE_OK;
124552 rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);
124565 rc = sqlite3ApiExit(db, rc);
124567 return rc;
124585 int rc;
124586 rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
124587 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
124588 return rc;
124597 int rc;
124598 rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);
124599 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
124600 return rc;
124610 int rc;
124611 rc = sqlite3Prepare16(db,zSql,nBytes,
124614 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
124615 return rc;
126943 int rc; /* Result code */
127012 rc = sqlite3Select(pParse, pSetup, &destQueue);
127014 if( rc ) goto end_of_recursive_query;
127093 int rc = 0;
127113 return rc;
127152 int rc = SQLITE_OK; /* Success code from a subroutine */
127170 rc = 1;
127188 rc = multiSelectValues(pParse, p, &dest);
127227 rc = sqlite3Select(pParse, pPrior, &dest);
127229 if( rc ){
127244 rc = sqlite3Select(pParse, p, &dest);
127245 testcase( rc!=SQLITE_OK );
127295 rc = sqlite3Select(pParse, pPrior, &uniondest);
127296 if( rc ){
127314 rc = sqlite3Select(pParse, p, &uniondest);
127315 testcase( rc!=SQLITE_OK );
127376 rc = sqlite3Select(pParse, pPrior, &intersectdest);
127377 if( rc ){
127392 rc = sqlite3Select(pParse, p, &intersectdest);
127393 testcase( rc!=SQLITE_OK );
127453 rc = SQLITE_NOMEM_BKPT;
127485 return rc;
130226 int rc = 1; /* Value to return from this function */
130384 rc = multiSelect(pParse, p, pDest);
130392 return rc;
131223 rc = (pParse->nErr>0);
131239 return rc;
131277 int rc; /* Return code from sqlite3_exec() */
131322 p->rc = SQLITE_ERROR;
131345 p->rc = SQLITE_NOMEM_BKPT;
131367 int rc;
131382 res.rc = SQLITE_OK;
131389 rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
131392 if( (rc&0xff)==SQLITE_ABORT ){
131401 db->errCode = res.rc; /* Assume 32-bit assignment is atomic */
131402 return res.rc;
131405 if( rc!=SQLITE_OK ){
131407 return rc;
131422 return rc;
132307 pTo->rc = pFrom->rc;
132960 int rc;
132961 rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,
132964 if( rc==SQLITE_DENY ){
132966 }else if( rc==SQLITE_IGNORE ){
133710 int rc; /* Result code */
133730 rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
133731 if( rc ) return rc;
133732 rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);
133733 if( rc ) return rc;
133914 int rc;
133917 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
133918 if( rc!=SQLITE_OK ) return rc;
133919 while( SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){
133930 rc = execSql(db, pzErrMsg, zSubSql);
133931 if( rc!=SQLITE_OK ) break;
133934 assert( rc!=SQLITE_ROW );
133935 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
133936 if( rc ){
133940 return rc;
133945 int rc;
133950 rc = execSql(db, pzErrMsg, z);
133952 return rc;
134028 int rc = SQLITE_OK; /* Return code from service routines */
134098 rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut);
134100 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134109 rc = SQLITE_ERROR;
134136 rc = execSql(db, pzErrMsg, "BEGIN");
134137 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134138 rc = sqlite3BtreeBeginTrans(pMain, pOut==0 ? 2 : 0, 0);
134139 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134151 rc = SQLITE_NOMEM_BKPT;
134164 rc = execSqlF(db, pzErrMsg,
134170 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134171 rc = execSqlF(db, pzErrMsg,
134176 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134183 rc = execSqlF(db, pzErrMsg,
134192 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134199 rc = execSqlF(db, pzErrMsg,
134206 if( rc ) goto end_of_vacuum;
134240 rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);
134241 if( NEVER(rc!=SQLITE_OK) ) goto end_of_vacuum;
134245 rc = sqlite3BtreeCopyFile(pMain, pTemp);
134247 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134248 rc = sqlite3BtreeCommit(pTemp);
134249 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134257 assert( rc==SQLITE_OK );
134259 rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);
134291 return rc;
134377 int rc = SQLITE_OK;
134381 rc = SQLITE_MISUSE_BKPT;
134385 rc = sqlite3ApiExit(db, rc);
134386 if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);
134388 return rc;
134805 int rc;
134848 rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
134850 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
134853 if( SQLITE_OK!=rc ){
134871 rc = SQLITE_ERROR;
134916 return rc;
134930 int rc;
134944 rc = SQLITE_ERROR;
134947 rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr);
134948 if( rc!=SQLITE_OK ){
134950 pParse->rc = rc;
134955 return rc;
134999 int rc = SQLITE_OK;
135017 rc = SQLITE_ERROR;
135019 rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);
135024 if( rc==SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab)) ){
135025 rc = growVTrans(db);
135026 if( rc==SQLITE_OK ){
135031 return rc;
135041 int rc = SQLITE_OK;
135087 rc = SQLITE_ERROR;
135101 rc = SQLITE_ERROR;
135111 assert( (rc&0xff)==rc );
135112 rc = sqlite3ApiExit(db, rc);
135114 return rc;
135125 int rc = SQLITE_OK;
135141 rc = xDestroy(p->pVtab);
135143 if( rc==SQLITE_OK ){
135151 return rc;
135192 int rc = SQLITE_OK;
135196 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
135200 rc = x(pVtab);
135205 return rc;
135235 int rc = SQLITE_OK;
135263 rc = growVTrans(db);
135264 if( rc==SQLITE_OK ){
135265 rc = pModule->xBegin(pVTab->pVtab);
135266 if( rc==SQLITE_OK ){
135271 rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1);
135276 return rc;
135295 int rc = SQLITE_OK;
135301 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
135320 rc = xMethod(pVTab->pVtab, iSavepoint);
135326 return rc;
135354 int rc = 0;
135384 rc = pMod->xFindFunction(pVtab, nArg, pDef->zName, &xSFunc, &pArg);
135385 if( rc==0 ){
135448 int rc;
135467 rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
135468 if( rc ){
135520 int rc = SQLITE_OK;
135531 rc = SQLITE_MISUSE_BKPT;
135539 rc = SQLITE_MISUSE_BKPT;
135544 if( rc!=SQLITE_OK ) sqlite3Error(db, rc);
135546 return rc;
137025 int rc = WRC_Continue;
137046 rc = WRC_Prune;
137048 return rc;
138634 int rc; /* Result code to return */
138745 rc = (z!=0);
138747 return rc;
141095 int rc;
141098 rc = pVtab->pModule->xBestIndex(pVtab, p);
141101 if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){
141102 if( rc==SQLITE_NOMEM ){
141105 sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc));
141112 return rc;
141397 int rc = SQLITE_OK;
141407 rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1);
141410 if( pUpper && rc==SQLITE_OK ){
141411 rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2);
141418 for(i=0; rc==SQLITE_OK && i<p->nSample; i++){
141419 rc = sqlite3Stat4Column(db, p->aSample[i].p, p->aSample[i].n, nEq, &pVal);
141420 if( rc==SQLITE_OK && p1 ){
141424 if( rc==SQLITE_OK && p2 ){
141453 return rc;
141504 int rc = SQLITE_OK;
141574 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n);
141575 if( rc==SQLITE_OK && n ){
141591 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n);
141592 if( rc==SQLITE_OK && n ){
141605 if( rc==SQLITE_OK ){
141624 rc = whereRangeSkipScanEst(pParse, pLower, pUpper, pLoop, &bDone);
141625 if( bDone ) return rc;
141657 return rc;
141687 int rc; /* Subfunction return code */
141710 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq-1, &bOk);
141712 if( rc!=SQLITE_OK ) return rc;
141721 return rc;
141751 int rc = SQLITE_OK; /* Subfunction return code */
141757 for(i=0; rc==SQLITE_OK && i<pList->nExpr; i++){
141759 rc = whereEqualScanEst(pParse, pBuilder, pList->a[i].pExpr, &nEst);
141764 if( rc==SQLITE_OK ){
141770 return rc;
142165 int rc;
142258 rc = whereLoopXfer(db, p, pTemplate);
142265 return rc;
142452 int rc = SQLITE_OK; /* Return code */
142487 for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
142677 rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut);
142679 rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
142681 if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
142682 if( rc!=SQLITE_OK ) break; /* Jump out of the pTerm loop */
142718 rc = whereLoopInsert(pBuilder, pNew);
142761 && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
142781 pProbe->pTable->zName, pProbe->zName, saved_nEq, rc));
142782 return rc;
142894 int rc = SQLITE_OK; /* Return code */
142957 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
142989 rc = whereLoopInsert(pBuilder, pNew);
142997 for(; rc==SQLITE_OK && pProbe;
143030 rc = whereLoopInsert(pBuilder, pNew);
143032 if( rc ) break;
143090 rc = whereLoopInsert(pBuilder, pNew);
143092 if( rc ) break;
143097 rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
143111 return rc;
143150 int rc = SQLITE_OK;
143185 rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);
143186 if( rc ){
143187 if( rc==SQLITE_CONSTRAINT ){
143195 return rc;
143271 rc = whereLoopInsert(pBuilder, pNew);
143280 return rc;
143335 int rc = SQLITE_OK; /* Return code */
143370 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
143377 if( rc==SQLITE_OK && ((mBest = (pNew->prereq & ~mPrereq))!=0 || bIn) ){
143387 rc = whereLoopAddVirtualOne(
143399 while( rc==SQLITE_OK ){
143414 rc = whereLoopAddVirtualOne(
143425 if( rc==SQLITE_OK && seenZero==0 ){
143427 rc = whereLoopAddVirtualOne(
143435 if( rc==SQLITE_OK && seenZeroNoIN==0 ){
143437 rc = whereLoopAddVirtualOne(
143444 WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc));
143445 return rc;
143462 int rc = SQLITE_OK;
143476 for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){
143514 rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);
143518 rc = whereLoopAddBtree(&sSubBuild, mPrereq);
143520 if( rc==SQLITE_OK ){
143521 rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);
143523 assert( rc==SQLITE_OK || sCur.n==0 );
143549 for(i=0; rc==SQLITE_OK && i<sSum.n; i++){
143565 rc = whereLoopInsert(pBuilder, pNew);
143570 return rc;
143585 int rc = SQLITE_OK;
143612 rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);
143616 rc = whereLoopAddBtree(pBuilder, mPrereq);
143618 if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){
143619 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
143622 if( rc || db->mallocFailed ){
143623 if( rc==SQLITE_DONE ){
143626 rc = SQLITE_OK;
143634 return rc;
144349 int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,
144351 if( rc==pWInfo->pResultSet->nExpr ){
144372 int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
144376 if( rc==pWInfo->pOrderBy->nExpr ){
144632 int rc; /* Return code */
144811 rc = whereLoopAddAll(&sWLB);
144812 if( rc ) goto whereBeginError;
146302 int rc = SQLITE_OK;
146386 rc = SQLITE_NOMEM;
146400 if( db->mallocFailed ) rc = SQLITE_NOMEM;
146403 return rc;
153933 pParse->rc = SQLITE_OK;
153964 pParse->rc = SQLITE_TOOBIG;
153977 pParse->rc = SQLITE_INTERRUPT;
154016 assert( db->mallocFailed==0 || pParse->rc!=SQLITE_OK || startedWithOom );
154017 if( pParse->rc!=SQLITE_OK ) break;
154033 pParse->rc = SQLITE_NOMEM_BKPT;
154035 if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
154036 pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
154041 sqlite3_log(pParse->rc, "%s in \"%s\"",
154087 assert( nErr==0 || pParse->rc!=SQLITE_OK );
154499 int rc;
154502 rc = sqlite3_initialize();
154503 if( rc ) return rc;
154509 rc = sqlite3_complete(zSql8);
154511 rc = SQLITE_NOMEM_BKPT;
154514 return rc & 0xff;
154757 int rc; /* Result code */
154763 rc = sqlite3_wsd_init(4096, 24);
154764 if( rc!=SQLITE_OK ){
154765 return rc;
154789 rc = sqlite3MutexInit();
154790 if( rc ) return rc;
154802 rc = sqlite3MallocInit();
154804 if( rc==SQLITE_OK ){
154810 rc = SQLITE_NOMEM_BKPT;
154814 if( rc==SQLITE_OK ){
154822 if( rc!=SQLITE_OK ){
154823 return rc;
154851 rc = sqlite3PcacheInitialize();
154853 if( rc==SQLITE_OK ){
154855 rc = sqlite3OsInit();
154858 if( rc==SQLITE_OK ){
154859 rc = sqlite3MemdbInit();
154862 if( rc==SQLITE_OK ){
154894 if( rc==SQLITE_OK ){
154911 rc = SQLITE_EXTRA_INIT(0);
154915 return rc;
154928 int rc = sqlite3_wsd_init(4096, 24);
154929 if( rc!=SQLITE_OK ){
154930 return rc;
154982 int rc = SQLITE_OK;
155093 rc = SQLITE_ERROR;
155279 rc = SQLITE_ERROR;
155284 return rc;
155401 int rc = SQLITE_OK;
155409 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
155413 rc = sqlite3PagerFlush(pPager);
155414 if( rc==SQLITE_BUSY ){
155416 rc = SQLITE_OK;
155422 return ((rc==SQLITE_OK && bSeenBusy) ? SQLITE_BUSY : rc);
155430 int rc;
155437 rc = SQLITE_OK;
155444 rc = setupLookaside(db, pBuf, sz, cnt);
155465 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
155482 rc = SQLITE_OK;
155490 return rc;
155514 int rc, n;
155520 rc = memcmp(pKey1, pKey2, n);
155521 if( rc==0 ){
155532 rc = nKey1 - nKey2;
155535 return rc;
155950 SQLITE_PRIVATE const char *sqlite3ErrName(int rc){
155952 int i, origRc = rc;
155953 for(i=0; i<2 && zName==0; i++, rc &= 0xff){
155954 switch( rc ){
156060 SQLITE_PRIVATE const char *sqlite3ErrStr(int rc){
156097 switch( rc ){
156111 rc &= 0xff;
156112 if( ALWAYS(rc>=0) && rc<ArraySize(aMsg) && aMsg[rc]!=0 ){
156113 zErr = aMsg[rc];
156198 int rc;
156205 rc = xTra(p->pBusyArg, p->nBusy, pFile);
156208 rc = p->xBusyHandler(p->pBusyArg, p->nBusy);
156210 if( rc==0 ){
156215 return rc;
156356 int rc;
156357 rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,
156359 if( rc==SQLITE_OK ){
156360 rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,
156363 if( rc!=SQLITE_OK ){
156364 return rc;
156434 int rc = SQLITE_ERROR;
156454 rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p,
156458 assert( rc!=SQLITE_OK );
156464 rc = sqlite3ApiExit(db, rc);
156466 return rc;
156526 int rc;
156535 rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0,0,0);
156537 rc = sqlite3ApiExit(db, rc);
156539 return rc;
156583 int rc;
156592 rc = sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)!=0;
156594 if( rc ) return SQLITE_OK;
156875 int rc; /* Return code */
156901 rc = SQLITE_ERROR;
156905 rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
156906 sqlite3Error(db, rc);
156908 rc = sqlite3ApiExit(db, rc);
156917 return rc;
156955 int rc = SQLITE_OK; /* Return code */
156963 for(i=0; i<db->nDb && rc==SQLITE_OK; i++){
156965 rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt);
156968 if( rc==SQLITE_BUSY ){
156970 rc = SQLITE_OK;
156975 return (rc==SQLITE_OK && bBusy) ? SQLITE_BUSY : rc;
157116 SQLITE_API const char *sqlite3_errstr(int rc){
157117 return sqlite3ErrStr(rc);
157340 int rc = SQLITE_OK;
157388 rc = SQLITE_ERROR;
157432 rc = SQLITE_ERROR;
157520 rc = SQLITE_ERROR;
157526 rc = SQLITE_PERM;
157550 rc = SQLITE_ERROR;
157553 if( rc!=SQLITE_OK ){
157559 return rc;
157609 int rc; /* Return code */
157619 rc = sqlite3_initialize();
157620 if( rc ) return rc;
157776 rc = SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */
157778 rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
157780 if( rc!=SQLITE_OK ){
157781 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
157782 sqlite3ErrorWithMsg(db, rc, zErrMsg ? "%s" : 0, zErrMsg);
157788 rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0,
157790 if( rc!=SQLITE_OK ){
157791 if( rc==SQLITE_IOERR_NOMEM ){
157792 rc = SQLITE_NOMEM_BKPT;
157794 sqlite3Error(db, rc);
157822 rc = sqlite3_errcode(db);
157828 if( !db->mallocFailed && rc==SQLITE_OK ){
157829 rc = sqlite3Fts5Init(db);
157836 if( rc==SQLITE_OK ){
157838 rc = sqlite3_errcode(db);
157839 if( rc!=SQLITE_OK ){
157847 rc = sqlite3Fts1Init(db);
157852 if( !db->mallocFailed && rc==SQLITE_OK ){
157854 rc = sqlite3Fts2Init(db);
157859 if( !db->mallocFailed && rc==SQLITE_OK ){
157860 rc = sqlite3Fts3Init(db);
157865 if( !db->mallocFailed && rc==SQLITE_OK ){
157866 rc = sqlite3IcuInit(db);
157871 if( !db->mallocFailed && rc==SQLITE_OK){
157872 rc = sqlite3RtreeInit(db);
157877 if( !db->mallocFailed && rc==SQLITE_OK){
157878 rc = sqlite3DbpageRegister(db);
157883 if( !db->mallocFailed && rc==SQLITE_OK){
157884 rc = sqlite3DbstatRegister(db);
157889 if( !db->mallocFailed && rc==SQLITE_OK){
157890 rc = sqlite3Json1Init(db);
157895 if( !db->mallocFailed && rc==SQLITE_OK){
157896 rc = sqlite3StmtVtabInit(db);
157910 if( rc ) sqlite3Error(db, rc);
157924 rc = sqlite3_errcode(db);
157925 assert( db!=0 || rc==SQLITE_NOMEM );
157926 if( rc==SQLITE_NOMEM ){
157929 }else if( rc!=SQLITE_OK ){
157941 if( rc==SQLITE_OK ) sqlite3CodecQueryParameters(db, 0, zOpen);
157944 return rc & 0xff;
157977 int rc;
157984 rc = sqlite3_initialize();
157985 if( rc ) return rc;
157992 rc = openDatabase(zFilename8, ppDb,
157994 assert( *ppDb || rc==SQLITE_NOMEM );
157995 if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){
157999 rc = SQLITE_NOMEM_BKPT;
158003 return rc & 0xff;
158031 int rc;
158038 rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, xDel);
158039 rc = sqlite3ApiExit(db, rc);
158041 return rc;
158055 int rc = SQLITE_OK;
158065 rc = createCollation(db, zName8, (u8)enc, pCtx, xCompare, 0);
158068 rc = sqlite3ApiExit(db, rc);
158070 return rc;
158214 int rc;
158235 rc = sqlite3Init(db, &zErrMsg);
158236 if( SQLITE_OK!=rc ){
158305 if( SQLITE_OK==rc && !pTab ){
158309 rc = SQLITE_ERROR;
158311 sqlite3ErrorWithMsg(db, rc, (zErrMsg?"%s":0), zErrMsg);
158313 rc = sqlite3ApiExit(db, rc);
158315 return rc;
158323 int rc;
158330 rc = (sqlite3OsSleep(pVfs, 1000*ms)/1000);
158331 return rc;
158351 int rc = SQLITE_ERROR;
158369 rc = SQLITE_OK;
158372 rc = SQLITE_OK;
158375 rc = SQLITE_OK;
158378 rc = SQLITE_OK;
158380 rc = sqlite3OsFileControl(fd, op, pArg);
158385 return rc;
158392 int rc = 0;
158439 rc = sqlite3BitvecBuiltinTest(sz, aProg);
158461 rc = sqlite3FaultSim(0);
158494 rc = PENDING_BYTE;
158518 rc = x;
158552 rc = x ? ALWAYS(x) : 0;
158568 rc = SQLITE_BYTEORDER*100 + SQLITE_LITTLEENDIAN*10 + SQLITE_BIGENDIAN;
158674 if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;
158718 if( sqlite3ParserCoverage(out) ) rc = SQLITE_ERROR;
158725 return rc;
158826 int rc = SQLITE_ERROR;
158841 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
158842 if( rc==SQLITE_OK ){
158843 rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
158851 return rc;
158862 int rc = SQLITE_ERROR;
158881 rc = sqlite3PagerSnapshotCheck(pPager, pSnapshot);
158882 if( rc==SQLITE_OK ){
158884 rc = sqlite3BtreeCommit(pBt);
158888 rc = SQLITE_OK;
158890 if( rc==SQLITE_OK ){
158891 rc = sqlite3PagerSnapshotOpen(pPager, pSnapshot);
158893 if( rc==SQLITE_OK ){
158894 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
158906 return rc;
158914 int rc = SQLITE_ERROR;
158929 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
158930 if( rc==SQLITE_OK ){
158931 rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));
158938 return rc;
159155 int rc = SQLITE_OK;
159177 rc = SQLITE_LOCKED; /* Deadlock detected. */
159189 sqlite3ErrorWithMsg(db, rc, (rc?"database is deadlocked":0));
159191 return rc;
160822 int rc = SQLITE_OK; /* Return code */
160827 fts3DbExec(&rc, db,
160844 return (rc==SQLITE_OK ? fts3DisconnectMethod(pVtab) : rc);
160860 int rc; /* Return code */
160880 rc = SQLITE_NOMEM;
160882 rc = sqlite3_declare_vtab(p->db, zSql);
160887 *pRc = rc;
160913 int rc = SQLITE_OK; /* Return code */
160930 if( zContentCols==0 ) rc = SQLITE_NOMEM;
160933 fts3DbExec(&rc, db,
160941 fts3DbExec(&rc, db,
160945 fts3DbExec(&rc, db,
160958 fts3DbExec(&rc, db,
160965 sqlite3Fts3CreateStatTable(&rc, p);
160967 return rc;
160979 int rc; /* Return code */
160985 rc = SQLITE_NOMEM;
160987 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
160988 if( rc==SQLITE_OK ){
160991 rc = sqlite3_finalize(pStmt);
160992 }else if( rc==SQLITE_AUTH ){
160994 rc = SQLITE_OK;
160997 assert( p->nPgsz>0 || rc!=SQLITE_OK );
160999 *pRc = rc;
161316 int rc = SQLITE_OK; /* Return code */
161322 rc = SQLITE_NOMEM;
161324 rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
161325 if( rc!=SQLITE_OK ){
161331 if( rc==SQLITE_OK ){
161349 rc = SQLITE_NOMEM;
161368 return rc;
161393 int rc = SQLITE_OK; /* Return code */
161438 rc = SQLITE_NOMEM;
161453 for(i=3; rc==SQLITE_OK && i<argc; i++){
161464 rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr);
161485 rc = SQLITE_NOMEM;
161497 rc = SQLITE_ERROR;
161525 rc = SQLITE_ERROR;
161551 rc = SQLITE_ERROR;
161572 if( rc==SQLITE_OK && zContent ){
161580 rc = fts3ContentColumns(db, argv[1], zContent,&aCol,&nCol,&nString,pzErr);
161584 if( rc==SQLITE_OK && zLanguageid ){
161597 if( rc!=SQLITE_OK ) goto fts3_init_out;
161607 rc = sqlite3Fts3InitTokenizer(pHash, "simple", &pTokenizer, pzErr);
161608 if( rc!=SQLITE_OK ) goto fts3_init_out;
161612 rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);
161613 if( rc==SQLITE_ERROR ){
161617 if( rc!=SQLITE_OK ) goto fts3_init_out;
161629 rc = SQLITE_NOMEM;
161700 rc = SQLITE_ERROR;
161704 if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){
161706 rc = SQLITE_ERROR;
161709 p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);
161710 p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);
161711 if( rc!=SQLITE_OK ) goto fts3_init_out;
161717 rc = fts3CreateTables(p);
161729 fts3DatabasePageSize(&rc, p);
161733 fts3DeclareVtab(&rc, p);
161745 if( rc!=SQLITE_OK ){
161755 return rc;
162015 int rc = SQLITE_OK;
162025 rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
162028 if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
162030 return rc;
162039 int rc = SQLITE_OK;
162041 rc = fts3CursorSeekStmt(pCsr);
162042 if( rc==SQLITE_OK ){
162048 rc = sqlite3_reset(pCsr->pStmt);
162049 if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){
162053 rc = FTS_CORRUPT_VTAB;
162060 if( rc!=SQLITE_OK && pContext ){
162061 sqlite3_result_error_code(pContext, rc);
162063 return rc;
162089 int rc = SQLITE_OK; /* Return code */
162132 rc = FTS_CORRUPT_VTAB;
162140 rc = SQLITE_NOMEM;
162178 return rc;
162212 int rc = SQLITE_OK; /* Return code */
162218 rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
162219 assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
162221 if( rc==SQLITE_OK && iHeight>1 ){
162226 rc = sqlite3Fts3ReadBlock(p, *piLeaf, &zBlob, &nBlob, 0);
162227 if( rc==SQLITE_OK ){
162228 rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, 0);
162235 if( rc==SQLITE_OK ){
162236 rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);
162238 if( rc==SQLITE_OK ){
162239 rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);
162244 return rc;
162770 int rc = SQLITE_OK;
162825 rc = fts3PoslistMerge(&p, &p1, &p2);
162826 if( rc ) break;
162840 if( rc!=SQLITE_OK ){
162849 return rc;
163005 int rc = fts3DoclistOrMerge(p->bDescIdx,
163008 if( rc!=SQLITE_OK ){
163010 return rc;
163087 int rc = fts3DoclistOrMerge(p->bDescIdx, aMerge, nMerge,
163090 if( rc!=SQLITE_OK ){
163092 return rc;
163150 int rc = SQLITE_OK; /* Error code */
163162 rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);
163163 if( rc==SQLITE_OK && pSeg ){
163164 rc = fts3SegReaderCursorAppend(pCsr, pSeg);
163169 if( rc==SQLITE_OK ){
163170 rc = sqlite3Fts3AllSegdirs(p, iLangid, iIndex, iLevel, &pStmt);
163173 while( rc==SQLITE_OK && SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){
163187 rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
163188 if( rc!=SQLITE_OK ) goto finished;
163192 rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1,
163197 if( rc!=SQLITE_OK ) goto finished;
163198 rc = fts3SegReaderCursorAppend(pCsr, pSeg);
163204 if( rc==SQLITE_DONE ) rc = rc2;
163206 return rc;
163278 int rc = SQLITE_NOMEM; /* Return code */
163290 rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid,
163300 rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid,
163303 if( rc==SQLITE_OK ){
163304 rc = fts3SegReaderCursorAddZero(
163313 rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid,
163321 return rc;
163343 int rc; /* Return code */
163359 rc = sqlite3Fts3SegReaderStart(p, pSegcsr, &filter);
163360 while( SQLITE_OK==rc
163361 && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pSegcsr))
163363 rc = fts3TermSelectMerge(p, &tsc, pSegcsr->aDoclist, pSegcsr->nDoclist);
163366 if( rc==SQLITE_OK ){
163367 rc = fts3TermSelectFinishMerge(p, &tsc);
163369 if( rc==SQLITE_OK ){
163381 return rc;
163420 int rc;
163425 rc = sqlite3_reset(pCsr->pStmt);
163428 rc = SQLITE_OK;
163431 rc = fts3EvalNext((Fts3Cursor *)pCursor);
163434 return rc;
163487 int rc = SQLITE_OK;
163540 rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
163544 if( rc!=SQLITE_OK ){
163545 return rc;
163548 rc = fts3EvalStart(pCsr);
163550 if( rc!=SQLITE_OK ) return rc;
163573 rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
163576 rc = SQLITE_NOMEM;
163579 rc = fts3CursorSeekStmt(pCsr);
163580 if( rc==SQLITE_OK ){
163581 rc = sqlite3_bind_value(pCsr->pStmt, 1, pCons);
163584 if( rc!=SQLITE_OK ) return rc;
163630 int rc = SQLITE_OK; /* Return Code */
163663 rc = fts3CursorSeek(0, pCsr);
163664 if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)-1>iCol ){
163671 return rc;
163716 int rc;
163719 rc = sqlite3Fts3PendingTermsFlush(p);
163720 if( rc==SQLITE_OK
163727 rc = sqlite3Fts3MaxLevel(p, &mxLevel);
163728 assert( rc==SQLITE_OK || mxLevel==0 );
163731 if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge);
163735 return rc;
163745 int rc = SQLITE_OK;
163753 rc = SQLITE_NOMEM;
163756 return rc;
163858 int rc;
163861 rc = SQLITE_OK;
163866 rc = SQLITE_ERROR;
163868 return rc;
163948 int rc; /* Return code */
163959 rc = sqlite3Fts3Optimize(p);
163961 switch( rc ){
163969 sqlite3_result_error_code(pContext, rc);
164039 int rc; /* Return Code */
164043 rc = fts3SetHasStat(p);
164052 if( rc==SQLITE_OK ){
164053 rc = sqlite3Fts3PendingTermsFlush(p);
164057 fts3DbExec(&rc, db,
164064 fts3DbExec(&rc, db,
164070 fts3DbExec(&rc, db,
164075 fts3DbExec(&rc, db,
164079 fts3DbExec(&rc, db,
164083 return rc;
164092 int rc = SQLITE_OK;
164098 rc = fts3SyncMethod(pVtab);
164100 return rc;
164211 int rc = SQLITE_OK;
164229 rc = sqlite3Fts3InitTerm(db);
164230 if( rc!=SQLITE_OK ) return rc;
164233 rc = sqlite3Fts3InitAux(db);
164234 if( rc!=SQLITE_OK ) return rc;
164242 rc = SQLITE_NOMEM;
164248 if( rc==SQLITE_OK ){
164259 rc = SQLITE_NOMEM;
164264 if( rc==SQLITE_OK ){
164265 rc = sqlite3Fts3ExprInitTestInterface(db, pHash);
164273 if( SQLITE_OK==rc
164274 && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
164275 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
164276 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
164277 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
164278 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
164279 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
164281 rc = sqlite3_create_module_v2(
164284 if( rc==SQLITE_OK ){
164285 rc = sqlite3_create_module_v2(
164289 if( rc==SQLITE_OK ){
164290 rc = sqlite3Fts3InitTok(db, (void *)pHash);
164292 return rc;
164297 assert( rc!=SQLITE_OK );
164302 return rc;
164334 int rc = fts3TermSegReaderCursor(pCsr,
164337 if( rc!=SQLITE_OK ){
164338 *pRc = rc;
164369 int rc = SQLITE_OK;
164408 rc = fts3DoclistPhraseMerge(
164417 return rc;
164432 int rc = SQLITE_OK;
164434 for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){
164441 rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);
164442 if( rc==SQLITE_OK ){
164443 rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
164449 return rc;
164478 int rc = sqlite3Fts3DeferredTokenList(pDeferred, &pList, &nList);
164479 if( rc!=SQLITE_OK ) return rc;
164578 int rc = SQLITE_OK; /* Error code */
164605 for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
164609 rc = sqlite3Fts3MsrIncrStart(pTab, pSegcsr, iCol, pToken->z, pToken->n);
164615 rc = fts3EvalPhraseLoad(pCsr, p);
164619 assert( rc!=SQLITE_OK || p->nToken<1 || p->aToken[0].pSegcsr==0 || p->bIncr );
164620 return rc;
164796 int rc = SQLITE_OK;
164811 rc = sqlite3Fts3MsrIncrNext(
164820 return rc;
164846 int rc = SQLITE_OK;
164856 rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr,
164874 for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){
164875 rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
164881 assert( rc!=SQLITE_OK || (p->nToken>=1 && a[p->nToken-1].bIgnore==0) );
164882 assert( rc!=SQLITE_OK || bMaxSet );
164886 while( rc==SQLITE_OK && bEof==0
164889 rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
164930 return rc;
164947 int rc = SQLITE_OK;
164952 rc = fts3EvalIncrPhraseNext(pCsr, p, pbEof);
164962 return rc;
165089 int rc = SQLITE_OK;
165109 rc = sqlite3Fts3SelectDoctotal(p, &pStmt);
165110 if( rc!=SQLITE_OK ) return rc;
165127 rc = sqlite3_reset(pStmt);
165131 return rc;
165156 int rc = SQLITE_OK; /* Return code */
165185 rc = fts3EvalAverageDocsize(pCsr, &nDocSize);
165186 assert( rc!=SQLITE_OK || nDocSize>0 );
165211 for(ii=0; ii<nToken && rc==SQLITE_OK; ii++){
165231 rc = sqlite3Fts3DeferToken(pCsr, pToken, pTC->iCol);
165247 rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);
165248 assert( rc==SQLITE_OK || pList==0 );
165249 if( rc==SQLITE_OK ){
165250 rc = fts3EvalPhraseMergeToken(
165254 if( rc==SQLITE_OK ){
165266 return rc;
165283 int rc = SQLITE_OK;
165288 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
165292 if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
165302 rc = SQLITE_NOMEM;
165308 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
165312 if( rc==SQLITE_OK ){
165313 rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);
165314 for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){
165315 rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);
165324 fts3EvalStartReaders(pCsr, pCsr->pExpr, &rc);
165325 return rc;
165772 int rc = *pRc;
165774 if( rc==SQLITE_OK ){
165783 rc = fts3CursorSeek(0, pCsr);
165784 if( rc==SQLITE_OK ){
165785 rc = sqlite3Fts3CacheDeferredDoclists(pCsr);
165788 bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));
165792 *pRc = rc;
165794 return (rc==SQLITE_OK && bMiss);
165802 int rc = SQLITE_OK; /* Return Code */
165813 fts3EvalNextRow(pCsr, pExpr, &rc);
165818 }while( pCsr->isEof==0 && sqlite3Fts3EvalTestDeferred(pCsr, &rc) );
165823 if( rc==SQLITE_OK && (
165830 return rc;
165931 int rc = SQLITE_OK; /* Return code */
165961 fts3EvalRestart(pCsr, pRoot, &rc);
165963 while( pCsr->isEof==0 && rc==SQLITE_OK ){
165971 fts3EvalNextRow(pCsr, pRoot, &rc);
165978 && sqlite3Fts3EvalTestDeferred(pCsr, &rc)
165981 if( rc==SQLITE_OK && pCsr->isEof==0 ){
165998 fts3EvalRestart(pCsr, pRoot, &rc);
166000 fts3EvalNextRow(pCsr, pRoot, &rc);
166002 }while( pRoot->iDocid!=iDocid && rc==SQLITE_OK );
166005 return rc;
166044 int rc = SQLITE_OK;
166054 rc = fts3EvalGatherStats(pCsr, pExpr);
166055 if( rc==SQLITE_OK ){
166064 return rc;
166109 int rc = SQLITE_OK;
166135 fts3EvalRestart(pCsr, pNear, &rc);
166136 while( rc==SQLITE_OK && !pNear->bEof ){
166137 fts3EvalNextRow(pCsr, pNear, &rc);
166140 assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );
166143 while( rc==SQLITE_OK && !pNear->bEof ){
166144 fts3EvalNextRow(pCsr, pNear, &rc);
166147 if( rc!=SQLITE_OK ) return rc;
166333 int rc; /* value returned by declare_vtab() */
166360 rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);
166361 if( rc!=SQLITE_OK ) return rc;
166533 int rc;
166542 rc = sqlite3Fts3SegReaderStep(pFts3, &pCsr->csr);
166543 if( rc==SQLITE_ROW ){
166614 rc = SQLITE_OK;
166618 return rc;
166633 int rc;
166705 rc = sqlite3Fts3SegReaderCursor(pFts3, iLangVal, 0, FTS3_SEGCURSOR_ALL,
166708 if( rc==SQLITE_OK ){
166709 rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);
166712 if( rc==SQLITE_OK ) rc = fts3auxNextMethod(pCursor);
166713 return rc;
166808 int rc; /* Return code */
166810 rc = sqlite3_create_module(db, "fts4aux", &fts3aux_module, 0);
166811 return rc;
166957 int rc;
166959 rc = pModule->xOpen(pTokenizer, z, n, &pCsr);
166960 assert( rc==SQLITE_OK || pCsr==0 );
166961 if( rc==SQLITE_OK ){
166964 rc = pModule->xLanguageid(pCsr, iLangid);
166965 if( rc!=SQLITE_OK ){
166972 return rc;
167002 int rc;
167014 rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, i, &pCursor);
167015 if( rc==SQLITE_OK ){
167020 rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);
167021 if( rc==SQLITE_OK ){
167025 rc = SQLITE_NOMEM;
167056 }else if( i && rc==SQLITE_DONE ){
167057 rc = SQLITE_OK;
167064 return rc;
167099 int rc;
167127 rc = sqlite3Fts3OpenTokenizer(
167129 if( rc==SQLITE_OK ){
167131 for(ii=0; rc==SQLITE_OK; ii++){
167134 rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);
167135 if( rc==SQLITE_OK ){
167162 if( rc==SQLITE_DONE ){
167186 rc = SQLITE_OK;
167190 return rc;
167230 int rc;
167316 rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed);
167318 return rc;
167351 rc = getNextToken(pParse, iCol, &z[iColLen], n-iColLen, ppExpr, pnConsumed);
167353 return rc;
167438 int rc = SQLITE_OK;
167441 while( rc==SQLITE_OK ){
167445 rc = getNextNode(pParse, zIn, nIn, &p, &nByte);
167446 assert( nByte>0 || (rc!=SQLITE_OK && p==0) );
167447 if( rc==SQLITE_OK ){
167458 rc = SQLITE_NOMEM;
167481 rc = SQLITE_ERROR;
167492 rc = SQLITE_NOMEM;
167514 rc = SQLITE_ERROR;
167535 assert( rc!=SQLITE_OK || (nByte>0 && nByte<=nIn) );
167540 if( rc==SQLITE_DONE && pRet && isRequirePhrase ){
167541 rc = SQLITE_ERROR;
167544 if( rc==SQLITE_DONE ){
167545 rc = SQLITE_OK;
167548 rc = SQLITE_ERROR;
167563 if( rc!=SQLITE_OK ){
167569 return rc;
167577 int rc = SQLITE_OK;
167580 rc = SQLITE_TOOBIG;
167582 rc = fts3ExprCheckDepth(p->pLeft, nMaxDepth-1);
167583 if( rc==SQLITE_OK ){
167584 rc = fts3ExprCheckDepth(p->pRight, nMaxDepth-1);
167588 return rc;
167603 int rc = SQLITE_OK; /* Return code */
167609 rc = SQLITE_ERROR;
167612 if( rc==SQLITE_OK ){
167617 rc = SQLITE_NOMEM;
167622 if( rc==SQLITE_OK ){
167644 rc = fts3ExprBalance(&p, nMaxDepth-1);
167645 if( rc!=SQLITE_OK ) break;
167666 rc = SQLITE_TOOBIG;
167692 if( rc==SQLITE_OK ){
167739 rc = fts3ExprBalance(&pLeft, nMaxDepth-1);
167740 if( rc==SQLITE_OK ){
167741 rc = fts3ExprBalance(&pRight, nMaxDepth-1);
167744 if( rc!=SQLITE_OK ){
167757 if( rc!=SQLITE_OK ){
167762 return rc;
167787 int rc;
167804 rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);
167805 assert( rc==SQLITE_OK || *ppExpr==0 );
167808 if( rc==SQLITE_OK && sParse.nNest ){
167809 rc = SQLITE_ERROR;
167812 return rc;
167850 int rc = fts3ExprParseUnbalanced(
167856 if( rc==SQLITE_OK && *ppExpr ){
167857 rc = fts3ExprBalance(ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);
167858 if( rc==SQLITE_OK ){
167859 rc = fts3ExprCheckDepth(*ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);
167863 if( rc!=SQLITE_OK ){
167866 if( rc==SQLITE_TOOBIG ){
167871 rc = SQLITE_ERROR;
167872 }else if( rc==SQLITE_ERROR ){
167877 return rc;
168001 int rc;
168021 rc = sqlite3Fts3InitTokenizer(pHash, zTokenizer, &pTokenizer, &zErr);
168022 if( rc!=SQLITE_OK ){
168023 if( rc==SQLITE_NOMEM ){
168046 rc = sqlite3Fts3ExprParse(
168049 assert( rc==SQLITE_OK || pExpr==0 );
168052 rc = fts3ExprParseUnbalanced(
168057 if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){
168060 }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){
168071 rc = pTokenizer->pModule->xDestroy(pTokenizer);
168096 int rc = sqlite3_create_function(
168099 if( rc==SQLITE_OK ){
168100 rc = sqlite3_create_function(db, "fts3_exprtest_rebalance",
168104 return rc;
169333 int rc;
169355 rc = SQLITE_ERROR;
169374 rc = m->xCreate(iArg, aArg, ppTok);
169375 assert( rc!=SQLITE_OK || *ppTok );
169376 if( rc!=SQLITE_OK ){
169385 return rc;
169520 int rc;
169524 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
169525 if( rc!=SQLITE_OK ){
169526 return rc;
169543 int rc;
169548 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
169549 if( rc!=SQLITE_OK ){
169550 return rc;
169588 int rc;
169598 rc = queryTokenizer(db, "simple", &p2);
169599 assert( rc==SQLITE_OK );
169601 rc = queryTokenizer(db, "nosuchtokenizer", &p2);
169602 assert( rc==SQLITE_ERROR );
169608 rc = registerTokenizer(db, "nosuchtokenizer", p1);
169609 assert( rc==SQLITE_OK );
169610 rc = queryTokenizer(db, "nosuchtokenizer", &p2);
169611 assert( rc==SQLITE_OK );
169642 int rc = SQLITE_OK;
169653 rc = SQLITE_NOMEM;
169657 if( SQLITE_OK==rc ){
169658 rc = sqlite3_create_function(db, zName, 1, any, p, fts3TokenizerFunc, 0, 0);
169660 if( SQLITE_OK==rc ){
169661 rc = sqlite3_create_function(db, zName, 2, any, p, fts3TokenizerFunc, 0, 0);
169664 if( SQLITE_OK==rc ){
169665 rc = sqlite3_create_function(db, zTest, -1, any, p, testFunc, 0, 0);
169667 if( SQLITE_OK==rc ){
169668 rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0);
169677 return rc;
170033 int rc = SQLITE_OK; /* Return code */
170047 rc = SQLITE_NOMEM;
170060 return rc;
170089 int rc;
170093 rc = sqlite3_declare_vtab(db, FTS3_TOK_SCHEMA);
170094 if( rc!=SQLITE_OK ) return rc;
170097 rc = fts3tokDequoteArray(nDequote, &argv[3], &azDequote);
170099 if( rc==SQLITE_OK ){
170106 rc = fts3tokQueryTokenizer((Fts3Hash*)pHash, zModule, &pMod, pzErr);
170109 assert( (rc==SQLITE_OK)==(pMod!=0) );
170110 if( rc==SQLITE_OK ){
170112 rc = pMod->xCreate((nDequote>1 ? nDequote-1 : 0), azArg, &pTok);
170115 if( rc==SQLITE_OK ){
170118 rc = SQLITE_NOMEM;
170122 if( rc==SQLITE_OK ){
170134 return rc;
170233 int rc; /* Return code */
170236 rc = pTab->pMod->xNext(pCsr->pCsr,
170241 if( rc!=SQLITE_OK ){
170243 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
170246 return rc;
170259 int rc = SQLITE_ERROR;
170271 rc = SQLITE_NOMEM;
170275 rc = pTab->pMod->xOpen(pTab->pTok, pCsr->zInput, nByte, &pCsr->pCsr);
170276 if( rc==SQLITE_OK ){
170282 if( rc!=SQLITE_OK ) return rc;
170369 int rc; /* Return code */
170371 rc = sqlite3_create_module(db, "fts3tokenize", &fts3tok_module, (void*)pHash);
170372 return rc;
170769 int rc = SQLITE_OK;
170788 rc = SQLITE_NOMEM;
170790 rc = sqlite3_prepare_v3(p->db, zSql, -1, f, &pStmt, NULL);
170792 assert( rc==SQLITE_OK || pStmt==0 );
170799 for(i=0; rc==SQLITE_OK && i<nParam; i++){
170800 rc = sqlite3_bind_value(pStmt, i+1, apVal[i]);
170804 return rc;
170814 int rc; /* Return code */
170816 rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);
170817 if( rc==SQLITE_OK ){
170819 rc = sqlite3_step(pStmt);
170820 if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
170821 rc = sqlite3_reset(pStmt);
170822 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
170825 rc = SQLITE_OK;
170830 return rc;
170838 int rc;
170839 rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);
170840 if( rc==SQLITE_OK ){
170845 rc = sqlite3_reset(pStmt);
170846 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
170851 return rc;
170877 int rc;
170879 rc = fts3SqlStmt(p, eStmt, &pStmt, apVal);
170880 if( rc==SQLITE_OK ){
170882 rc = sqlite3_reset(pStmt);
170884 *pRC = rc;
170903 int rc = SQLITE_OK;
170907 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pStmt, 0);
170908 if( rc==SQLITE_OK ){
170911 rc = sqlite3_reset(pStmt);
170915 return rc;
170980 int rc;
170989 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);
170990 if( rc==SQLITE_OK ){
170998 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
170999 if( rc==SQLITE_OK ){
171004 return rc;
171072 int rc = SQLITE_OK;
171083 if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iDelta)) ){
171091 if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, 1))
171092 || SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iCol))
171101 rc = fts3PendingListAppendVarint(&p, 2+iPos-p->iLastPos);
171102 if( rc==SQLITE_OK ){
171108 *pRc = rc;
171135 int rc = SQLITE_OK;
171141 if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){
171148 rc = SQLITE_NOMEM;
171151 if( rc==SQLITE_OK ){
171154 return rc;
171171 int rc;
171196 rc = sqlite3Fts3OpenTokenizer(pTokenizer, iLangid, zText, -1, &pCsr);
171197 if( rc!=SQLITE_OK ){
171198 return rc;
171202 while( SQLITE_OK==rc
171203 && SQLITE_OK==(rc = xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos))
171212 rc = SQLITE_ERROR;
171217 rc = fts3PendingTermsAddOne(
171223 for(i=1; rc==SQLITE_OK && i<p->nIndex; i++){
171226 rc = fts3PendingTermsAddOne(
171234 return (rc==SQLITE_DONE ? SQLITE_OK : rc);
171262 int rc = sqlite3Fts3PendingTermsFlush(p);
171263 if( rc!=SQLITE_OK ) return rc;
171307 int rc = fts3PendingTermsAdd(p, iLangid, zText, iCol, &aSz[iCol]);
171308 if( rc!=SQLITE_OK ){
171309 return rc;
171336 int rc; /* Return code */
171359 rc = fts3SqlStmt(p, SQL_CONTENT_INSERT, &pContentInsert, &apVal[1]);
171360 if( rc==SQLITE_OK && p->zLanguageid ){
171361 rc = sqlite3_bind_int(
171366 if( rc!=SQLITE_OK ) return rc;
171385 rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);
171386 if( rc!=SQLITE_OK ) return rc;
171393 rc = sqlite3_reset(pContentInsert);
171396 return rc;
171406 int rc = SQLITE_OK; /* Return code */
171414 if( bContent ) fts3SqlExec(&rc, p, SQL_DELETE_ALL_CONTENT, 0);
171415 fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGMENTS, 0);
171416 fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGDIR, 0);
171418 fts3SqlExec(&rc, p, SQL_DELETE_ALL_DOCSIZE, 0);
171421 fts3SqlExec(&rc, p, SQL_DELETE_ALL_STAT, 0);
171423 return rc;
171447 int rc;
171452 rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);
171453 if( rc==SQLITE_OK ){
171458 rc = fts3PendingTermsDocid(p, 1, iLangid, iDocid);
171459 for(i=1; rc==SQLITE_OK && i<=p->nColumn; i++){
171463 rc = fts3PendingTermsAdd(p, iLangid, zText, -1, &aSz[iCol]);
171467 if( rc!=SQLITE_OK ){
171469 *pRC = rc;
171474 rc = sqlite3_reset(pSelect);
171478 *pRC = rc;
171509 int rc; /* Return Code */
171517 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pNextIdx, 0);
171518 if( rc==SQLITE_OK ){
171525 rc = sqlite3_reset(pNextIdx);
171528 if( rc==SQLITE_OK ){
171536 rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
171543 return rc;
171580 int rc; /* Return code */
171586 rc = sqlite3_blob_reopen(p->pSegments, iBlockid);
171592 rc = sqlite3_blob_open(
171597 if( rc==SQLITE_OK ){
171603 rc = SQLITE_NOMEM;
171609 rc = sqlite3_blob_read(p->pSegments, aByte, nByte, 0);
171611 if( rc!=SQLITE_OK ){
171620 return rc;
171634 int rc; /* Return code */
171637 rc = sqlite3_blob_read(
171644 if( rc==SQLITE_OK ){
171653 return rc;
171657 int rc = SQLITE_OK;
171661 while( pReader->pBlob && rc==SQLITE_OK
171664 rc = fts3SegReaderIncrRead(pReader);
171666 return rc;
171691 int rc; /* Return code of various sub-routines */
171736 rc = sqlite3Fts3ReadBlock(
171740 if( rc!=SQLITE_OK ) return rc;
171751 rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);
171752 if( rc!=SQLITE_OK ) return rc;
171778 rc = fts3SegReaderRequire(pReader, pNext, nSuffix+FTS3_VARINT_MAX);
171779 if( rc!=SQLITE_OK ) return rc;
171805 int rc = SQLITE_OK;
171817 rc = fts3SegReaderRequire(pReader, pReader->aDoclist, FTS3_VARINT_MAX);
171818 if( rc==SQLITE_OK ){
171823 return rc;
171842 int rc = SQLITE_OK;
171884 rc = fts3SegReaderIncrRead(pReader);
171885 if( rc!=SQLITE_OK ) return rc;
171908 rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);
171909 if( rc==SQLITE_OK ){
171933 int rc = SQLITE_OK;
171939 for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
171947 rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);
171948 if( rc!=SQLITE_OK ) break;
171956 return rc;
172080 int rc = SQLITE_OK; /* Return Code */
172098 rc = SQLITE_NOMEM;
172137 rc = SQLITE_NOMEM;
172150 return rc;
172166 int rc;
172170 rc = memcmp(pLhs->zTerm, pRhs->zTerm, pLhs->nTerm);
172172 rc = memcmp(pLhs->zTerm, pRhs->zTerm, pRhs->nTerm);
172174 if( rc==0 ){
172175 rc = rc2;
172178 rc = (pLhs->aNode==0) - (pRhs->aNode==0);
172180 if( rc==0 ){
172181 rc = pRhs->iIdx - pLhs->iIdx;
172183 assert( rc!=0 );
172184 return rc;
172199 int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);
172200 if( rc==0 ){
172202 rc = pRhs->iIdx - pLhs->iIdx;
172204 rc = (pLhs->iDocid > pRhs->iDocid) ? 1 : -1;
172208 return rc;
172211 int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);
172212 if( rc==0 ){
172214 rc = pRhs->iIdx - pLhs->iIdx;
172216 rc = (pLhs->iDocid < pRhs->iDocid) ? 1 : -1;
172220 return rc;
172296 int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);
172297 if( rc==SQLITE_OK ){
172301 rc = sqlite3_reset(pStmt);
172304 return rc;
172313 int rc;
172317 rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);
172318 if( rc==SQLITE_OK ){
172322 rc = sqlite3_reset(pStmt);
172325 return rc;
172343 int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
172344 if( rc==SQLITE_OK ){
172358 rc = sqlite3_reset(pStmt);
172361 return rc;
172396 int rc;
172477 rc = fts3NodeAddTerm(p, &pParent, isCopyTerm, zTerm, nTerm);
172489 rc = fts3NodeAddTerm(p, &pNew, isCopyTerm, zTerm, nTerm);
172493 return rc;
172535 int rc = SQLITE_OK;
172547 for(pIter=pTree->pLeftmost; pIter && rc==SQLITE_OK; pIter=pIter->pRight){
172551 rc = fts3WriteSegment(p, iNextFree, &pIter->aData[nStart], nWrite);
172555 if( rc==SQLITE_OK ){
172557 rc = fts3NodeWrite(
172563 return rc;
172610 int rc;
172625 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0);
172626 if( rc!=SQLITE_OK ) return rc;
172631 rc = sqlite3_reset(pStmt);
172632 if( rc!=SQLITE_OK ) return rc;
172652 int rc;
172655 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
172656 if( rc!=SQLITE_OK ) return rc;
172672 rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);
172673 if( rc!=SQLITE_OK ) return rc;
172747 int rc; /* Return code */
172755 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);
172756 if( rc==SQLITE_OK ){
172757 rc = fts3NodeWrite(p, pWriter->pTree, 1,
172760 if( rc==SQLITE_OK ){
172761 rc = fts3WriteSegdir(p, iLevel, iIdx,
172766 rc = fts3WriteSegdir(p, iLevel, iIdx,
172770 return rc;
172798 int rc;
172802 rc = SQLITE_OK;
172804 rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, &pRowid);
172805 if( rc==SQLITE_OK ){
172809 rc = sqlite3_reset(pStmt);
172812 return rc;
172830 int rc;
172839 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
172840 if( rc!=SQLITE_OK ) return rc;
172868 int rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
172869 if( rc!=SQLITE_OK ) return rc;
172891 int rc = SQLITE_OK; /* Return code */
172894 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
172895 if( rc==SQLITE_OK ){
172899 rc = sqlite3_reset(pDelete);
172902 return rc;
172927 int rc = SQLITE_OK; /* Return Code */
172931 for(i=0; rc==SQLITE_OK && i<nReader; i++){
172932 rc = fts3DeleteSegment(p, apSegment[i]);
172934 if( rc!=SQLITE_OK ){
172935 return rc;
172940 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);
172941 if( rc==SQLITE_OK ){
172948 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);
172949 if( rc==SQLITE_OK ){
172956 if( rc==SQLITE_OK ){
172958 rc = sqlite3_reset(pDelete);
172961 return rc;
173064 int rc;
173070 rc = fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);
173072 while( rc==SQLITE_OK
173077 rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0);
173080 if( rc!=SQLITE_OK ) return rc;
173084 rc = fts3MsrBufferData(pMsr, pList, nList+1);
173085 if( rc!=SQLITE_OK ) return rc;
173125 int rc = fts3SegReaderNext(p, pSeg, 0);
173126 if( rc!=SQLITE_OK ) return rc;
173155 int rc;
173165 rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm);
173166 if( rc!=SQLITE_OK ) return rc;
173179 rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);
173180 if( rc!=SQLITE_OK ) return rc;
173226 int rc = SQLITE_OK;
173256 rc = fts3SegReaderNext(p, pSeg, 0);
173258 if( rc!=SQLITE_OK ) return rc;
173264 assert( rc==SQLITE_OK );
173303 rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist);
173308 if( rc==SQLITE_OK ) rc = SQLITE_ROW;
173392 rc = SQLITE_ROW;
173396 }while( rc==SQLITE_OK );
173398 return rc;
173467 int rc = SQLITE_OK;
173470 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE2, &pRange, 0);
173472 if( rc==SQLITE_OK ){
173498 rc = sqlite3_reset(pRange);
173505 if( rc==SQLITE_OK ){
173506 rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL_IDX, &pUpdate1, 0);
173508 if( rc==SQLITE_OK ){
173509 rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL, &pUpdate2, 0);
173512 if( rc==SQLITE_OK ){
173529 rc = sqlite3_reset(pUpdate1);
173530 if( rc!=SQLITE_OK ){
173536 if( rc==SQLITE_OK ){
173537 rc = sqlite3_reset(pRange);
173541 if( rc==SQLITE_OK ){
173544 rc = sqlite3_reset(pUpdate2);
173550 return rc;
173570 int rc; /* Return code */
173586 rc = sqlite3Fts3SegReaderCursor(p, iLangid, iIndex, iLevel, 0, 0, 1, 0, &csr);
173587 if( rc!=SQLITE_OK || csr.nSegment==0 ) goto finished;
173590 rc = fts3SegmentMaxLevel(p, iLangid, iIndex, &iMaxLevel);
173591 if( rc!=SQLITE_OK ) goto finished;
173600 rc = SQLITE_DONE;
173613 rc = fts3AllocateSegdirIdx(p, iLangid, iIndex, iLevel+1, &iIdx);
173616 if( rc!=SQLITE_OK ) goto finished;
173628 rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);
173629 while( SQLITE_OK==rc ){
173630 rc = sqlite3Fts3SegReaderStep(p, &csr);
173631 if( rc!=SQLITE_ROW ) break;
173632 rc = fts3SegWriterAdd(p, &pWriter, 1,
173635 if( rc!=SQLITE_OK ) goto finished;
173639 rc = fts3DeleteSegdir(
173642 if( rc!=SQLITE_OK ) goto finished;
173645 rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);
173646 if( rc==SQLITE_OK ){
173648 rc = fts3PromoteSegments(p, iNewLevel, pWriter->nLeafData);
173656 return rc;
173664 int rc = SQLITE_OK;
173667 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
173668 rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
173669 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
173676 if( rc==SQLITE_OK && p->bHasStat
173680 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
173681 if( rc==SQLITE_OK ){
173683 rc = sqlite3_step(pStmt);
173684 if( rc==SQLITE_ROW ){
173687 }else if( rc==SQLITE_DONE ){
173690 rc = sqlite3_reset(pStmt);
173693 return rc;
173746 int rc; /* Result code from subfunctions */
173755 rc = fts3SqlStmt(p, SQL_REPLACE_DOCSIZE, &pStmt, 0);
173756 if( rc ){
173758 *pRC = rc;
173794 int rc; /* Result code from subfunctions */
173805 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
173806 if( rc ){
173808 *pRC = rc;
173819 rc = sqlite3_reset(pStmt);
173820 if( rc!=SQLITE_OK ){
173822 *pRC = rc;
173840 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
173841 if( rc ){
173843 *pRC = rc;
173860 int rc;
173863 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
173864 if( rc==SQLITE_OK ){
173871 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
173872 rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);
173873 if( rc==SQLITE_DONE ){
173875 rc = SQLITE_OK;
173880 if( rc==SQLITE_OK ) rc = rc2;
173886 return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;
173900 int rc; /* Return Code */
173902 rc = fts3DeleteAll(p, 0);
173903 if( rc==SQLITE_OK ){
173913 rc = SQLITE_NOMEM;
173915 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
173919 if( rc==SQLITE_OK ){
173923 rc = SQLITE_NOMEM;
173931 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
173934 rc = fts3PendingTermsDocid(p, 0, iLangid, sqlite3_column_int64(pStmt, 0));
173936 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
173939 rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);
173944 fts3InsertDocsize(&rc, p, aSz);
173946 if( rc!=SQLITE_OK ){
173957 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);
173963 if( rc==SQLITE_OK ){
173964 rc = rc2;
173969 return rc;
173985 int rc; /* Return Code */
173995 rc = SQLITE_NOMEM;
173998 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
174000 if( rc==SQLITE_OK ){
174005 for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){
174006 rc = sqlite3Fts3SegReaderNew(i, 0,
174017 if( rc==SQLITE_OK ) rc = rc2;
174020 return rc;
174122 int rc = SQLITE_OK; /* Return code */
174138 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
174139 if( rc==SQLITE_OK ){
174155 return rc;
174211 int rc = SQLITE_OK;
174232 blobGrowBuffer(pBlk, p->nNodeSize, &rc);
174233 if( rc==SQLITE_OK ){
174238 blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);
174239 blobGrowBuffer(&pNode->key, nTerm, &rc);
174241 if( rc==SQLITE_OK ){
174256 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
174267 if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;
174307 int rc = SQLITE_OK; /* Return code */
174317 blobGrowBuffer(pPrev, nTerm, &rc);
174318 if( rc!=SQLITE_OK ) return rc;
174358 int rc = SQLITE_OK; /* Return code */
174376 rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);
174391 if( rc==SQLITE_OK ){
174392 rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);
174407 blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);
174408 if( rc==SQLITE_OK ){
174413 rc = fts3AppendToNode(
174418 return rc;
174442 int rc = *pRc; /* Error code */
174477 blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);
174478 if( rc==SQLITE_OK ){
174491 if( pNode->block.n>0 && rc==SQLITE_OK ){
174492 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
174499 if( rc==SQLITE_OK ){
174500 rc = fts3WriteSegdir(p,
174513 *pRc = rc;
174553 int rc; /* Return code */
174555 rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);
174556 if( rc==SQLITE_OK ){
174559 rc = sqlite3_reset(pCheck);
174563 return rc;
174589 int rc; /* Return code */
174592 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);
174593 if( rc==SQLITE_OK ){
174620 rc = fts3IsAppendable(p, iEnd, &bAppendable);
174623 if( rc==SQLITE_OK && bAppendable ){
174627 rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);
174628 if( rc==SQLITE_OK ){
174630 for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);
174631 rc==SQLITE_OK && reader.aNode;
174632 rc = nodeReaderNext(&reader)
174644 if( rc==SQLITE_OK && bAppendable ){
174663 blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);
174664 if( rc==SQLITE_OK ){
174669 for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
174673 rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
174674 while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
174675 blobGrowBuffer(&pNode->key, reader.term.n, &rc);
174676 if( rc==SQLITE_OK ){
174684 rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
174685 blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
174686 if( rc==SQLITE_OK ){
174698 if( rc==SQLITE_OK ) rc = rc2;
174701 return rc;
174718 int rc;
174721 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);
174722 if( rc==SQLITE_OK ){
174726 rc = sqlite3_reset(pOutputIdx);
174729 return rc;
174765 int rc; /* Return Code */
174772 rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);
174773 if( rc==SQLITE_OK ){
174779 rc = sqlite3_reset(pLeafEst);
174781 if( rc!=SQLITE_OK ) return rc;
174784 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);
174785 if( rc==SQLITE_OK ){
174791 rc = sqlite3_reset(pFirstBlock);
174793 if( rc!=SQLITE_OK ) return rc;
174798 rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);
174799 if( rc!=SQLITE_OK ) return rc;
174828 int rc; /* Return code */
174831 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);
174832 if( rc==SQLITE_OK ){
174836 rc = sqlite3_reset(pDelete);
174839 return rc;
174851 int rc; /* Return code */
174859 rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);
174860 if( rc==SQLITE_OK ){
174869 rc = SQLITE_NOMEM;
174877 if( rc==SQLITE_OK ) rc = rc2;
174880 if( rc==SQLITE_OK ){
174881 rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);
174883 if( rc==SQLITE_OK ){
174889 for(i=0; rc==SQLITE_OK && i<nIdx; i++){
174894 rc = sqlite3_reset(pUpdate);
174900 return rc;
174932 int rc = SQLITE_OK; /* Return code */
174936 blobGrowBuffer(pNew, nNode, &rc);
174937 if( rc!=SQLITE_OK ) return rc;
174941 for(rc = nodeReaderInit(&reader, aNode, nNode);
174942 rc==SQLITE_OK && reader.aNode;
174943 rc = nodeReaderNext(&reader)
174951 rc = fts3AppendToNode(
174955 if( rc!=SQLITE_OK ) break;
174965 return rc;
174984 int rc = SQLITE_OK; /* Return code */
174992 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);
174993 if( rc==SQLITE_OK ){
175001 rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);
175004 if( rc==SQLITE_OK ) rc = rc2;
175007 while( rc==SQLITE_OK && iBlock ){
175012 rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);
175013 if( rc==SQLITE_OK ){
175014 rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);
175016 if( rc==SQLITE_OK ){
175017 rc = fts3WriteSegment(p, iNewStart, block.a, block.n);
175023 if( rc==SQLITE_OK && iNewStart ){
175025 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);
175026 if( rc==SQLITE_OK ){
175030 rc = sqlite3_reset(pDel);
175034 if( rc==SQLITE_OK ){
175036 rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);
175037 if( rc==SQLITE_OK ){
175043 rc = sqlite3_reset(pChomp);
175050 return rc;
175071 int rc = SQLITE_OK;
175073 for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){
175087 rc = fts3DeleteSegment(p, pSeg);
175088 if( rc==SQLITE_OK ){
175089 rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);
175098 rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);
175103 if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){
175104 rc = fts3RepackSegdirLevel(p, iAbsLevel);
175108 return rc;
175116 int rc; /* Return code */
175118 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);
175119 if( rc==SQLITE_OK ){
175123 rc = sqlite3_reset(pReplace);
175127 return rc;
175140 int rc;
175143 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);
175144 if( rc==SQLITE_OK ){
175151 blobGrowBuffer(pHint, nHint, &rc);
175152 if( rc==SQLITE_OK ){
175159 if( rc==SQLITE_OK ) rc = rc2;
175162 return rc;
175222 int rc; /* Return code */
175239 rc = fts3IncrmergeHintLoad(p, &hint);
175240 while( rc==SQLITE_OK && nRem>0 ){
175252 rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);
175261 rc = sqlite3_reset(pFindLevel);
175268 if( rc==SQLITE_OK && hint.n ){
175273 rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);
175300 if( rc==SQLITE_OK ){
175301 rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);
175305 rc = fts3SegmentIsMaxLevel(p, iAbsLevel+1, &bIgnore);
175312 if( rc==SQLITE_OK ){
175313 rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
175315 if( SQLITE_OK==rc && pCsr->nSegment==nSeg
175316 && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
175317 && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))
175322 rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
175324 rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
175327 if( rc==SQLITE_OK && pWriter->nLeafEst ){
175330 rc = fts3IncrmergeAppend(p, pWriter, pCsr);
175331 if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
175332 if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
175333 }while( rc==SQLITE_ROW );
175336 if( rc==SQLITE_OK ){
175338 rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
175341 fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);
175349 fts3IncrmergeRelease(p, pWriter, &rc);
175359 if( bDirtyHint && rc==SQLITE_OK ){
175360 rc = fts3IncrmergeHintStore(p, &hint);
175365 return rc;
175397 int rc;
175413 rc = SQLITE_ERROR;
175415 rc = SQLITE_OK;
175418 sqlite3Fts3CreateStatTable(&rc, p);
175420 if( rc==SQLITE_OK ){
175421 rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);
175425 return rc;
175440 int rc = SQLITE_OK;
175448 sqlite3Fts3CreateStatTable(&rc, p);
175449 if( rc ) return rc;
175451 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
175452 if( rc ) return rc;
175456 rc = sqlite3_reset(pStmt);
175457 return rc;
175502 int rc;
175512 rc = sqlite3Fts3SegReaderCursor(
175515 if( rc==SQLITE_OK ){
175516 rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);
175519 if( rc==SQLITE_OK ){
175520 while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){
175555 *pRc = rc;
175569 int rc = SQLITE_OK; /* Return code */
175575 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
175576 if( rc==SQLITE_OK ){
175580 while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
175584 cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
175588 if( rc==SQLITE_OK ) rc = rc2;
175592 if( rc==SQLITE_OK ){
175599 rc = SQLITE_NOMEM;
175601 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
175605 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
175610 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
175616 rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);
175617 while( rc==SQLITE_OK ){
175623 rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
175624 if( rc==SQLITE_OK ){
175639 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
175648 return rc;
175685 int rc;
175687 rc = fts3IntegrityCheck(p, &bOk);
175688 if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;
175689 return rc;
175701 int rc; /* Return Code */
175708 rc = fts3DoOptimize(p, 0);
175710 rc = fts3DoRebuild(p);
175712 rc = fts3DoIntegrityCheck(p);
175714 rc = fts3DoIncrmerge(p, &zVal[6]);
175716 rc = fts3DoAutoincrmerge(p, &zVal[10]);
175720 rc = SQLITE_OK;
175723 rc = SQLITE_OK;
175726 rc = SQLITE_OK;
175729 rc = SQLITE_ERROR;
175732 return rc;
175772 int rc = SQLITE_OK; /* Return code */
175785 for(i=0; i<p->nColumn && rc==SQLITE_OK; i++){
175790 rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);
175791 while( rc==SQLITE_OK ){
175797 rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);
175798 for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){
175805 fts3PendingListAppend(&pDef->pList, iDocid, i, iPos, &rc);
175810 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
175814 for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){
175816 rc = fts3PendingListAppendVarint(&pDef->pList, 0);
175821 return rc;
175888 int rc = SQLITE_OK; /* Return code */
175891 fts3DeleteTerms(&rc, p, pRowid, aSzDel, &bFound);
175892 if( bFound && rc==SQLITE_OK ){
175894 rc = fts3IsEmpty(p, pRowid, &isEmpty);
175895 if( rc==SQLITE_OK ){
175900 rc = fts3DeleteAll(p, 1);
175906 fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);
175909 fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);
175915 return rc;
175938 int rc = SQLITE_OK; /* Return Code */
175962 rc = fts3SpecialInsert(p, apVal[p->nColumn+2]);
175967 rc = SQLITE_CONSTRAINT;
175974 rc = SQLITE_NOMEM;
175980 rc = fts3Writelock(p);
175981 if( rc!=SQLITE_OK ) goto update_out;
176021 rc = fts3DeleteByRowid(p, pNewRowid, &nChng, aSzDel);
176023 rc = fts3InsertData(p, apVal, pRowid);
176028 if( rc!=SQLITE_OK ){
176035 rc = fts3DeleteByRowid(p, apVal[0], &nChng, aSzDel);
176039 if( nArg>1 && rc==SQLITE_OK ){
176042 rc = fts3InsertData(p, apVal, pRowid);
176043 if( rc==SQLITE_CONSTRAINT && p->zContentTbl==0 ){
176044 rc = FTS_CORRUPT_VTAB;
176047 if( rc==SQLITE_OK ){
176048 rc = fts3PendingTermsDocid(p, 0, iLangid, *pRowid);
176050 if( rc==SQLITE_OK ){
176052 rc = fts3InsertTerms(p, iLangid, apVal, aSzIns);
176055 fts3InsertDocsize(&rc, p, aSzIns);
176061 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
176067 return rc;
176076 int rc;
176077 rc = sqlite3_exec(p->db, "SAVEPOINT fts3", 0, 0, 0);
176078 if( rc==SQLITE_OK ){
176079 rc = fts3DoOptimize(p, 1);
176080 if( rc==SQLITE_OK || rc==SQLITE_DONE ){
176082 if( rc2!=SQLITE_OK ) rc = rc2;
176089 return rc;
176347 int rc; /* Return code */
176352 rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);
176353 if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){
176354 rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);
176357 rc = x(pExpr, *piPhrase, pCtx);
176360 return rc;
176389 int rc = SQLITE_OK;
176398 return rc;
176416 int rc; /* Return Code */
176419 rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
176422 return rc;
176567 int rc;
176570 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);
176571 assert( rc==SQLITE_OK || pCsr==0 );
176577 rc = FTS_CORRUPT_VTAB;
176585 assert( rc!=SQLITE_OK || (
176590 return rc;
176617 int rc; /* Return Code */
176629 rc = fts3ExprLoadDoclists(pCsr, &nList, 0);
176630 if( rc!=SQLITE_OK ){
176631 return rc;
176652 rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);
176653 if( rc==SQLITE_OK ){
176684 return rc;
176777 int rc; /* Return Code */
176785 rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);
176786 if( rc!=SQLITE_OK ){
176787 return rc;
176789 while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){
176791 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);
176794 if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }
176796 nShift = (rc==SQLITE_DONE)+iCurrent-nSnippet;
176823 int rc; /* Return code */
176846 rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid, zDoc,nDoc,&pC);
176847 if( rc!=SQLITE_OK ){
176848 return rc;
176851 while( rc==SQLITE_OK ){
176869 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);
176870 if( rc!=SQLITE_OK ){
176871 if( rc==SQLITE_DONE ){
176876 rc = fts3StringAppend(pOut, &zDoc[iEnd], -1);
176884 rc = fts3SnippetShift(
176893 if( rc==SQLITE_OK ){
176895 rc = fts3StringAppend(pOut, zEllipsis, -1);
176897 rc = fts3StringAppend(pOut, zDoc, iBegin);
176900 if( rc!=SQLITE_OK || iCurrent<iPos ) continue;
176905 rc = fts3StringAppend(pOut, zEllipsis, -1);
176913 if( iCurrent>iPos ) rc = fts3StringAppend(pOut, &zDoc[iEnd], iBegin-iEnd);
176914 if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zOpen, -1);
176915 if( rc==SQLITE_OK ) rc = fts3StringAppend(pOut, &zDoc[iBegin], iFin-iBegin);
176916 if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zClose, -1);
176922 return rc;
176999 int rc = SQLITE_OK;
177003 rc = fts3ExprLHitGather(pExpr->pLeft, p);
177004 if( rc==SQLITE_OK ) rc = fts3ExprLHitGather(pExpr->pRight, p);
177006 rc = fts3ExprLHits(pExpr, p);
177009 return rc;
177060 int rc = SQLITE_OK;
177065 for(i=0; i<p->nCol && rc==SQLITE_OK; i++){
177067 rc = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i, &pCsr);
177075 return rc;
177143 int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);
177144 if( rc!=SQLITE_OK ) return rc;
177196 int rc = 0;
177201 rc = 1;
177207 return rc;
177226 int rc = SQLITE_OK;
177248 rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);
177249 if( rc!=SQLITE_OK ) goto matchinfo_lcs_out;
177254 rc = FTS_CORRUPT_VTAB;
177290 return rc;
177316 int rc = SQLITE_OK;
177321 for(i=0; rc==SQLITE_OK && zArg[i]; i++){
177335 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);
177345 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a);
177346 if( rc==SQLITE_OK ){
177361 rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);
177362 if( rc==SQLITE_OK ){
177376 rc = fts3ExprLoadDoclists(pCsr, 0, 0);
177377 if( rc==SQLITE_OK ){
177378 rc = fts3MatchinfoLcs(pCsr, pInfo);
177386 rc = fts3ExprLHitGather(pCsr->pExpr, pInfo);
177394 rc = fts3ExprLoadDoclists(pCsr, 0, 0);
177395 if( rc!=SQLITE_OK ) break;
177398 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);
177399 if( rc!=SQLITE_OK ) break;
177401 rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
177402 sqlite3Fts3EvalTestDeferred(pCsr, &rc);
177403 if( rc!=SQLITE_OK ) break;
177414 return rc;
177429 int rc = SQLITE_OK;
177473 if( !pCsr->pMIBuffer ) rc = SQLITE_NOMEM;
177479 if( rc==SQLITE_OK ){
177482 rc = SQLITE_NOMEM;
177486 if( rc==SQLITE_OK ){
177489 rc = fts3MatchinfoValues(pCsr, bGlobal, &sInfo, zArg);
177495 if( rc!=SQLITE_OK ){
177496 sqlite3_result_error_code(pCtx, rc);
177517 int rc = SQLITE_OK;
177571 rc = fts3BestSnippet(nFToken, pCsr, iRead, mCovered, &mSeen, &sF, &iS);
177572 if( rc!=SQLITE_OK ){
177593 for(i=0; i<nSnippet && rc==SQLITE_OK; i++){
177594 rc = fts3SnippetText(pCsr, &aSnippet[i],
177601 if( rc!=SQLITE_OK ){
177602 sqlite3_result_error_code(pCtx, rc);
177636 int rc;
177639 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);
177653 return rc;
177665 int rc; /* Return Code */
177680 rc = fts3ExprLoadDoclists(pCsr, 0, &nToken);
177681 if( rc!=SQLITE_OK ) goto offsets_out;
177686 rc = SQLITE_NOMEM;
177725 rc = SQLITE_NOMEM;
177730 rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid,
177733 if( rc!=SQLITE_OK ) goto offsets_out;
177735 rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);
177736 while( rc==SQLITE_OK ){
177751 rc = SQLITE_DONE;
177759 while( rc==SQLITE_OK && iCurrent<iMinPos ){
177760 rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);
177762 if( rc==SQLITE_OK ){
177767 rc = fts3StringAppend(&res, aBuffer, -1);
177768 }else if( rc==SQLITE_DONE && pTab->zContentTbl==0 ){
177769 rc = FTS_CORRUPT_VTAB;
177773 if( rc==SQLITE_DONE ){
177774 rc = SQLITE_OK;
177778 if( rc!=SQLITE_OK ) goto offsets_out;
177783 assert( rc!=SQLITE_DONE );
177785 if( rc!=SQLITE_OK ){
177786 sqlite3_result_error_code(pCtx, rc);
178049 int rc = SQLITE_OK;
178056 for(i=0; rc==SQLITE_OK && i<nArg; i++){
178070 rc = unicodeAddExceptions(pNew, 1, &z[11], n-11);
178073 rc = unicodeAddExceptions(pNew, 0, &z[11], n-11);
178077 rc = SQLITE_ERROR;
178081 if( rc!=SQLITE_OK ){
178086 return rc;
180595 int rc;
180616 rc = sqlite3_declare_vtab(db,
180619 if( rc==SQLITE_OK ){
180624 return rc;
180647 int rc = jsonEachOpenEach(p, ppCursor);
180648 if( rc==SQLITE_OK ){
180652 return rc;
180941 int rc = SQLITE_NOMEM;
180945 if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR;
180948 return rc;
181062 int rc = SQLITE_OK;
181113 for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
181114 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
181120 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
181121 rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
181128 for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
181129 rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
181132 return rc;
181812 int rc = SQLITE_OK;
181836 rc = sqlite3_blob_reopen(pBlob, iNode);
181838 if( rc ){
181840 if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM;
181846 rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, "data", iNode, 0,
181850 if( rc ){
181855 if( rc==SQLITE_ERROR ){
181856 rc = SQLITE_CORRUPT_VTAB;
181862 rc = SQLITE_NOMEM;
181871 rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,
181885 rc = SQLITE_CORRUPT_VTAB;
181894 if( pNode && rc==SQLITE_OK ){
181896 rc = SQLITE_CORRUPT_VTAB;
181901 if( rc==SQLITE_OK ){
181906 rc = SQLITE_CORRUPT_VTAB;
181918 return rc;
181982 int rc = SQLITE_OK;
181993 rc = sqlite3_reset(p);
181995 if( pNode->iNode==0 && rc==SQLITE_OK ){
182000 return rc;
182008 int rc = SQLITE_OK;
182019 rc = nodeRelease(pRtree, pNode->pParent);
182021 if( rc==SQLITE_OK ){
182022 rc = nodeWrite(pRtree, pNode);
182028 return rc;
182161 int rc;
182171 rc = SQLITE_NOMEM;
182174 rc = sqlite3_exec(pRtree->db, zCreate, 0, 0, 0);
182177 if( rc==SQLITE_OK ){
182181 return rc;
182188 int rc = SQLITE_NOMEM;
182196 rc = SQLITE_OK;
182201 return rc;
182312 int rc; /* Callback return code */
182355 rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo,
182364 rc = pConstraint->u.xQueryFunc(pInfo);
182370 return rc;
182705 int rc = SQLITE_OK;
182714 pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);
182715 if( rc ) return rc;
182725 rc = rtreeCallbackConstraint(pConstraint, eInt, pCellData, p,
182727 if( rc ) return rc;
182772 int rc = SQLITE_OK;
182781 rc = rtreeStepToLeaf(pCsr);
182782 return rc;
182791 int rc = SQLITE_OK;
182792 RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);
182793 if( rc==SQLITE_OK && p ){
182796 return rc;
182807 int rc = SQLITE_OK;
182808 RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);
182810 if( rc ) return rc;
182828 rc = sqlite3_prepare_v3(pRtree->db, pRtree->zReadAuxSql, -1, 0,
182830 if( rc ) return rc;
182834 rc = sqlite3_step(pCsr->pReadAux);
182835 if( rc==SQLITE_ROW ){
182839 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
182840 return rc;
182862 int rc;
182868 rc = nodeAcquire(pRtree, iNode, 0, ppLeaf);
182871 rc = sqlite3_reset(pRtree->pReadRowid);
182873 return rc;
182921 int rc = SQLITE_OK;
182942 rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
182943 if( rc==SQLITE_OK && pLeaf!=0 ){
182949 rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);
182959 rc = nodeAcquire(pRtree, 1, 0, &pRoot);
182960 if( rc==SQLITE_OK && argc>0 ){
182964 rc = SQLITE_NOMEM;
182979 rc = deserializeGeometry(argv[ii], p);
182980 if( rc!=SQLITE_OK ){
182996 if( rc==SQLITE_OK ){
183007 rc = rtreeStepToLeaf(pCsr);
183013 return rc;
183052 int rc = SQLITE_OK;
183133 return rc;
183268 int rc;
183271 rc = nodeAcquire(pRtree, 1, 0, &pNode);
183273 for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){
183308 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
183314 return rc;
183641 int rc = SQLITE_OK;
183657 rc = SQLITE_NOMEM;
183682 rc = SQLITE_NOMEM;
183689 rc = splitNodeStartree(pRtree, aCell, nCell, pLeft, pRight,
183691 if( rc!=SQLITE_OK ){
183700 if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight))
183701 || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft)))
183710 rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1);
183711 if( rc!=SQLITE_OK ){
183717 rc = nodeParentIndex(pRtree, pLeft, &iCell);
183718 if( rc==SQLITE_OK ){
183720 rc = AdjustTree(pRtree, pParent, &leftbbox);
183722 if( rc!=SQLITE_OK ){
183726 if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){
183732 rc = updateMapping(pRtree, iRowid, pRight, iHeight);
183736 if( rc!=SQLITE_OK ){
183743 rc = updateMapping(pRtree, iRowid, pLeft, iHeight);
183744 if( rc!=SQLITE_OK ){
183749 rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);
183752 if( rc==SQLITE_OK ){
183753 rc = nodeRelease(pRtree, pRight);
183756 if( rc==SQLITE_OK ){
183757 rc = nodeRelease(pRtree, pLeft);
183765 return rc;
183780 int rc = SQLITE_OK;
183782 while( rc==SQLITE_OK && pChild->iNode!=1 && pChild->pParent==0 ){
183785 rc = sqlite3_step(pRtree->pReadParent);
183786 if( rc==SQLITE_ROW ){
183801 rc = sqlite3_reset(pRtree->pReadParent);
183802 if( rc==SQLITE_OK ) rc = rc2;
183803 if( rc==SQLITE_OK && !pChild->pParent ){
183805 rc = SQLITE_CORRUPT_VTAB;
183809 return rc;
183815 int rc;
183823 rc = nodeParentIndex(pRtree, pNode, &iCell);
183824 if( rc==SQLITE_OK ){
183827 rc = deleteCell(pRtree, pParent, iCell, iHeight+1);
183830 if( rc==SQLITE_OK ){
183831 rc = rc2;
183833 if( rc!=SQLITE_OK ){
183834 return rc;
183840 if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteNode)) ){
183841 return rc;
183847 if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteParent)) ){
183848 return rc;
183865 int rc = SQLITE_OK;
183877 rc = nodeParentIndex(pRtree, pNode, &ii);
183878 if( rc==SQLITE_OK ){
183880 rc = fixBoundingBox(pRtree, pParent);
183883 return rc;
183892 int rc;
183894 if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
183895 return rc;
183912 rc = removeNode(pRtree, pNode, iHeight);
183914 rc = fixBoundingBox(pRtree, pNode);
183918 return rc;
183935 int rc = SQLITE_OK;
183987 for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){
183992 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
183994 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
183998 if( rc==SQLITE_OK ){
183999 rc = fixBoundingBox(pRtree, pNode);
184001 for(; rc==SQLITE_OK && ii<nCell; ii++){
184007 rc = ChooseLeaf(pRtree, p, iHeight, &pInsert);
184008 if( rc==SQLITE_OK ){
184010 rc = rtreeInsertCell(pRtree, pInsert, p, iHeight);
184012 if( rc==SQLITE_OK ){
184013 rc = rc2;
184019 return rc;
184032 int rc = SQLITE_OK;
184043 rc = SplitNode(pRtree, pNode, pCell, iHeight);
184046 rc = Reinsert(pRtree, pNode, pCell, iHeight);
184049 rc = AdjustTree(pRtree, pNode, pCell);
184050 if( rc==SQLITE_OK ){
184052 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
184054 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
184058 return rc;
184063 int rc = SQLITE_OK;
184066 for(ii=0; rc==SQLITE_OK && ii<nCell; ii++){
184074 rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
184075 if( rc==SQLITE_OK ){
184077 rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);
184079 if( rc==SQLITE_OK ){
184080 rc = rc2;
184084 return rc;
184091 int rc;
184095 rc = sqlite3_reset(pRtree->pWriteRowid);
184097 return rc;
184104 int rc; /* Return code */
184111 rc = nodeAcquire(pRtree, 1, 0, &pRoot);
184116 if( rc==SQLITE_OK ){
184117 rc = findLeafNode(pRtree, iDelete, &pLeaf, 0);
184121 assert( pLeaf!=0 || rc!=SQLITE_OK || CORRUPT_DB );
184125 if( rc==SQLITE_OK && pLeaf ){
184127 rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);
184128 if( rc==SQLITE_OK ){
184129 rc = deleteCell(pRtree, pLeaf, iCell, 0);
184132 if( rc==SQLITE_OK ){
184133 rc = rc2;
184138 if( rc==SQLITE_OK ){
184141 rc = sqlite3_reset(pRtree->pDeleteRowid);
184152 if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){
184156 rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);
184157 if( rc==SQLITE_OK ){
184158 rc = removeNode(pRtree, pChild, pRtree->iDepth-1);
184161 if( rc==SQLITE_OK ) rc = rc2;
184162 if( rc==SQLITE_OK ){
184171 if( rc==SQLITE_OK ){
184172 rc = reinsertNodeContent(pRtree, pLeaf);
184180 if( rc==SQLITE_OK ){
184181 rc = nodeRelease(pRtree, pRoot);
184186 return rc;
184234 int rc;
184239 rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);
184241 rc = SQLITE_NOMEM;
184245 if( rc==SQLITE_OK ){
184261 return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);
184276 int rc = SQLITE_OK;
184322 rc = rtreeConstraintError(pRtree, ii+1);
184333 rc = rtreeConstraintError(pRtree, ii+1);
184349 rc = sqlite3_reset(pRtree->pReadRowid);
184352 rc = rtreeDeleteRowid(pRtree, cell.iRowid);
184354 rc = rtreeConstraintError(pRtree, 0);
184368 rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(aData[0]));
184375 if( rc==SQLITE_OK && nData>1 ){
184381 rc = rtreeNewRowid(pRtree, &cell.iRowid);
184385 if( rc==SQLITE_OK ){
184386 rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);
184388 if( rc==SQLITE_OK ){
184391 rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);
184393 if( rc==SQLITE_OK ){
184394 rc = rc2;
184397 if( rc==SQLITE_OK && pRtree->nAux ){
184405 rc = sqlite3_reset(pUp);
184411 return rc;
184440 int rc = SQLITE_NOMEM;
184451 rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0);
184454 return rc;
184490 int rc;
184493 rc = sqlite3_table_column_metadata(
184496 if( rc!=SQLITE_OK ){
184498 return rc==SQLITE_ERROR ? SQLITE_OK : rc;
184502 rc = SQLITE_NOMEM;
184504 rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
184505 if( rc==SQLITE_OK ){
184507 rc = sqlite3_finalize(p);
184508 }else if( rc!=SQLITE_NOMEM ){
184509 rc = SQLITE_OK;
184512 if( rc==SQLITE_OK ){
184522 return rc;
184575 int rc = SQLITE_OK;
184622 rc = sqlite3_exec(db, zCreate, 0, 0, 0);
184624 if( rc!=SQLITE_OK ){
184625 return rc;
184638 rc = rtreeQueryStat1(db, pRtree);
184639 for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
184652 rc = sqlite3_prepare_v3(db, zSql, -1, f, appStmt[i], 0);
184654 rc = SQLITE_NOMEM;
184663 rc = SQLITE_NOMEM;
184680 rc = SQLITE_NOMEM;
184682 rc = sqlite3_prepare_v3(db, zSql, -1, f, &pRtree->pWriteAux, 0);
184688 return rc;
184699 int rc = SQLITE_NOMEM;
184702 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
184703 if( rc==SQLITE_OK ){
184707 rc = sqlite3_finalize(pStmt);
184710 return rc;
184734 int rc;
184739 rc = getIntFromStmt(db, zSql, &iPageSize);
184740 if( rc==SQLITE_OK ){
184753 rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);
184754 if( rc!=SQLITE_OK ){
184757 rc = SQLITE_CORRUPT_VTAB;
184765 return rc;
184785 int rc = SQLITE_OK;
184848 rc = SQLITE_NOMEM;
184851 rc = SQLITE_ERROR;
184852 }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){
184856 if( rc ) goto rtreeInit_fail;
184874 rc = getNodeSize(db, pRtree, isCreate, pzErr);
184875 if( rc ) goto rtreeInit_fail;
184876 rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate);
184877 if( rc ){
184886 if( rc==SQLITE_OK ) rc = SQLITE_ERROR;
184890 return rc;
184988 int rc; /* Return code */
185000 int rc = sqlite3_reset(pStmt);
185001 if( pCheck->rc==SQLITE_OK ) pCheck->rc = rc;
185023 if( pCheck->rc==SQLITE_OK ){
185025 pCheck->rc = SQLITE_NOMEM;
185027 pCheck->rc = sqlite3_prepare_v2(pCheck->db, z, -1, &pRet, 0);
185044 if( pCheck->rc==SQLITE_OK && pCheck->nErr<RTREE_CHECK_MAX_ERROR ){
185047 pCheck->rc = SQLITE_NOMEM;
185053 pCheck->rc = SQLITE_NOMEM;
185078 if( pCheck->rc==SQLITE_OK && pCheck->pGetNode==0 ){
185085 if( pCheck->rc==SQLITE_OK ){
185092 pCheck->rc = SQLITE_NOMEM;
185099 if( pCheck->rc==SQLITE_OK && pRet==0 ){
185125 int rc;
185138 if( pCheck->rc!=SQLITE_OK ) return;
185142 rc = sqlite3_step(pStmt);
185143 if( rc==SQLITE_DONE ){
185147 }else if( rc==SQLITE_ROW ){
185281 if( pCheck->rc==SQLITE_OK ){
185295 pCheck->rc = sqlite3_finalize(pCount);
185325 check.rc = sqlite3_exec(db, "BEGIN", 0, 0, 0);
185330 if( check.rc==SQLITE_OK ){
185336 check.rc = SQLITE_OK;
185342 int rc;
185349 rc = sqlite3_finalize(pStmt);
185350 if( rc!=SQLITE_CORRUPT ) check.rc = rc;
185355 if( check.rc==SQLITE_OK ){
185369 int rc = sqlite3_exec(db, "END", 0, 0, 0);
185370 if( check.rc==SQLITE_OK ) check.rc = rc;
185373 return check.rc;
185419 int rc;
185429 rc = rtreeCheckTable(sqlite3_context_db_handle(ctx), zDb, zTab, &zReport);
185430 if( rc==SQLITE_OK ){
185433 sqlite3_result_error_code(ctx, rc);
185668 int rc = SQLITE_OK;
185682 rc = SQLITE_NOMEM;
185696 rc = SQLITE_ERROR;
185728 rc = SQLITE_ERROR;
185732 if( pRc ) *pRc = rc;
186167 int rc = SQLITE_OK;
186168 (void)geopolyBBox(context, argv[0], a, &rc);
186169 if( rc==SQLITE_OK ){
186501 int rc = 0;
186548 rc = 1;
186590 rc = 0;
186592 rc = 3;
186594 rc = 2;
186596 rc = 4;
186598 rc = 1;
186603 return rc;
186667 int rc = SQLITE_OK;
186711 rc = SQLITE_NOMEM;
186712 }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){
186716 if( rc ) goto geopolyInit_fail;
186720 rc = getNodeSize(db, pRtree, isCreate, pzErr);
186721 if( rc ) goto geopolyInit_fail;
186722 rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate);
186723 if( rc ){
186732 if( rc==SQLITE_OK ) rc = SQLITE_ERROR;
186736 return rc;
186788 int rc = SQLITE_OK;
186809 rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
186810 if( rc==SQLITE_OK && pLeaf!=0 ){
186816 rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);
186826 rc = nodeAcquire(pRtree, 1, 0, &pRoot);
186827 if( rc==SQLITE_OK && idxNum<=3 ){
186831 geopolyBBox(0, argv[0], bbox, &rc);
186832 if( rc ){
186838 rc = SQLITE_NOMEM;
186879 if( rc==SQLITE_OK ){
186883 rc = SQLITE_NOMEM;
186893 rc = rtreeStepToLeaf(pCsr);
186900 return rc;
186972 int rc = SQLITE_OK;
186973 RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);
186975 if( rc ) return rc;
186981 rc = sqlite3_prepare_v3(pRtree->db, pRtree->zReadAuxSql, -1, 0,
186983 if( rc ) return rc;
186987 rc = sqlite3_step(pCsr->pReadAux);
186988 if( rc==SQLITE_ROW ){
186992 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
186993 return rc;
187030 int rc = SQLITE_OK;
187058 geopolyBBox(0, aData[2], cell.aCoord, &rc);
187059 if( rc ){
187060 if( rc==SQLITE_ERROR ){
187074 rc = sqlite3_reset(pRtree->pReadRowid);
187077 rc = rtreeDeleteRowid(pRtree, cell.iRowid);
187079 rc = rtreeConstraintError(pRtree, 0);
187089 if( rc==SQLITE_OK && (nData==1 || (coordChange && oldRowidValid)) ){
187090 rc = rtreeDeleteRowid(pRtree, oldRowid);
187097 if( rc==SQLITE_OK && nData>1 && coordChange ){
187101 rc = rtreeNewRowid(pRtree, &cell.iRowid);
187104 if( rc==SQLITE_OK ){
187105 rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);
187107 if( rc==SQLITE_OK ){
187110 rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);
187112 if( rc==SQLITE_OK ){
187113 rc = rc2;
187119 if( rc==SQLITE_OK && nData>1 ){
187130 && (p = geopolyFuncParam(0, aData[2], &rc))!=0
187131 && rc==SQLITE_OK
187146 rc = sqlite3_reset(pUp);
187152 return rc;
187208 int rc = SQLITE_OK;
187236 for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
187238 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
187242 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
187243 rc = sqlite3_create_function(db, aAgg[i].zName, 1, SQLITE_UTF8, 0,
187246 if( rc==SQLITE_OK ){
187247 rc = sqlite3_create_module_v2(db, "geopoly", &geopolyModule, 0, 0);
187249 return rc;
187263 int rc;
187265 rc = sqlite3_create_function(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0);
187266 if( rc==SQLITE_OK ){
187267 rc = sqlite3_create_function(db, "rtreedepth", 1, utf8, 0,rtreedepth, 0, 0);
187269 if( rc==SQLITE_OK ){
187270 rc = sqlite3_create_function(db, "rtreecheck", -1, utf8, 0,rtreecheck, 0,0);
187272 if( rc==SQLITE_OK ){
187278 rc = sqlite3_create_module_v2(db, "rtree", &rtreeModule, c, 0);
187280 if( rc==SQLITE_OK ){
187282 rc = sqlite3_create_module_v2(db, "rtree_i32", &rtreeModule, c, 0);
187285 if( rc==SQLITE_OK ){
187286 rc = sqlite3_geopoly_init(db);
187290 return rc;
187903 int rc; /* Return code from sqlite3_create_collation_x() */
187921 rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator,
187924 if( rc!=SQLITE_OK ){
187956 int rc = SQLITE_OK;
187959 for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){
187961 rc = sqlite3_create_function(
187968 return rc;
189232 int rc; /* Value returned by last rbu_step() call */
189579 int rc = sqlite3_prepare_v2(db, zSql, -1, ppStmt, 0);
189580 if( rc!=SQLITE_OK ){
189584 return rc;
189596 int rc = sqlite3_reset(pStmt);
189597 if( rc!=SQLITE_OK ){
189600 return rc;
189624 int rc;
189627 rc = SQLITE_NOMEM;
189630 rc = prepareAndCollectError(db, ppStmt, pzErrmsg, zSql);
189633 return rc;
189704 int rc = p->rc;
189705 if( rc==SQLITE_OK ){
189710 rc = sqlite3_exec(p->dbMain,
189719 if( rc==SQLITE_OK ){
189723 rc = sqlite3_step(pIter->pTblIter);
189724 if( rc!=SQLITE_ROW ){
189725 rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg);
189730 rc = (pIter->zDataTbl && pIter->zTbl) ? SQLITE_OK : SQLITE_NOMEM;
189735 rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);
189737 if( rc==SQLITE_OK ){
189738 rc = sqlite3_step(pIter->pIdxIter);
189739 if( rc!=SQLITE_ROW ){
189740 rc = resetAndCollectError(pIter->pIdxIter, &p->zErrmsg);
189747 rc = pIter->zIdx ? SQLITE_OK : SQLITE_NOMEM;
189754 if( rc!=SQLITE_OK ){
189756 p->rc = rc;
189758 return rc;
189819 int rc;
189822 rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
189831 if( rc==SQLITE_OK ){
189832 rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,
189840 p->rc = rc;
189858 if( p->rc==SQLITE_OK ){
189859 if( zSql==0 ) p->rc = SQLITE_NOMEM;
189883 if( p->rc==SQLITE_OK ){
189885 p->rc = SQLITE_NOMEM;
189887 p->rc = sqlite3_exec(db, zSql, 0, 0, &p->zErrmsg);
189892 return p->rc;
189907 if( p->rc==SQLITE_OK ){
189911 p->rc = SQLITE_NOMEM;
189976 int rc = sqlite3_finalize(pStmt);
189977 if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){
189978 p->rc = rc;
190040 assert( p->rc==SQLITE_OK );
190041 p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[0], &p->zErrmsg,
190047 if( p->rc!=SQLITE_OK || sqlite3_step(aStmt[0])!=SQLITE_ROW ){
190057 p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[1], &p->zErrmsg,
190060 if( p->rc ) goto rbuTableType_end;
190065 p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[2], &p->zErrmsg,
190069 if( p->rc==SQLITE_OK ){
190081 p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[3], &p->zErrmsg,
190084 if( p->rc==SQLITE_OK ){
190110 if( p->rc==SQLITE_OK ){
190112 p->rc = prepareFreeAndCollectError(p->dbMain, &pList, &p->zErrmsg,
190118 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pList) ){
190126 p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,
190129 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
190169 if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_NOTABLE ){
190170 p->rc = SQLITE_ERROR;
190173 if( p->rc ) return p->rc;
190184 p->rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,
190187 if( p->rc==SQLITE_OK ){
190191 for(i=0; p->rc==SQLITE_OK && i<nCol; i++){
190194 char *zCopy = rbuStrndup(zName, &p->rc);
190205 if( p->rc==SQLITE_OK
190209 p->rc = SQLITE_ERROR;
190219 if( p->rc==SQLITE_OK ){
190220 p->rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &p->zErrmsg,
190224 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
190231 p->rc = SQLITE_ERROR;
190245 pIter->azTblType[iOrder] = rbuStrndup(zType, &p->rc);
190258 return p->rc;
190313 int rc = p->rc; /* Error code */
190324 if( rc==SQLITE_OK ){
190326 rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,
190331 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
190370 if( zRet==0 || zImpPK==0 || zImpCols==0 || zWhere==0 ) rc = SQLITE_NOMEM;
190377 if( rc==SQLITE_OK ) rc = rc2;
190379 if( rc!=SQLITE_OK ){
190388 p->rc = rc;
190415 if( p->rc==SQLITE_OK && pIter->abIndexed ){
190427 p->rc = SQLITE_NOMEM;
190492 p->rc = SQLITE_ERROR;
190520 if( p->rc==SQLITE_OK ){
190598 if( p->rc==SQLITE_OK ){
190603 p->rc = prepareFreeAndCollectError(p->dbMain, &pXList, &p->zErrmsg,
190606 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXList) ){
190611 p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,
190620 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
190655 if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_EXTERNAL ){
190667 p->rc = prepareAndCollectError(p->dbMain, &pQuery, &p->zErrmsg,
190670 if( p->rc==SQLITE_OK ){
190677 p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,
190683 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
190729 if( p->rc==SQLITE_OK && pIter->eType!=RBU_PK_VTAB ){
190736 for(iCol=0; p->rc==SQLITE_OK && iCol<pIter->nTblCol; iCol++){
190741 p->rc = sqlite3_table_column_metadata(
190794 p->rc = prepareFreeAndCollectError(
190808 int rc = SQLITE_OK;
190819 for(i=0; rc==SQLITE_OK && i<nVal; i++){
190820 rc = sqlite3_bind_value(p->objiter.pTmpInsert, i+1, apVal[i]);
190822 if( rc==SQLITE_OK ){
190824 rc = sqlite3_reset(p->objiter.pTmpInsert);
190827 if( rc!=SQLITE_OK ){
190828 sqlite3_result_error_code(pCtx, rc);
190834 int rc = p->rc;
190837 if( rc==SQLITE_OK ){
190838 rc = prepareAndCollectError(p->dbMain, &pStmt, &p->zErrmsg,
190842 if( rc==SQLITE_OK ){
190844 rc = sqlite3_bind_text(pStmt, 1, pIter->zIdx, -1, SQLITE_STATIC);
190845 if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
190875 zRet = rbuStrndup(&zSql[i], &rc);
190881 if( rc==SQLITE_OK ) rc = rc2;
190884 p->rc = rc;
190908 if( !zLimit ) p->rc = SQLITE_NOMEM;
190938 if( p->rc==SQLITE_OK ){
190939 p->rc = prepareFreeAndCollectError(
190946 if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){
190947 p->rc = prepareFreeAndCollectError(
190954 if( p->rc==SQLITE_OK ){
190985 p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, zSql);
191014 if( p->rc==SQLITE_OK ){
191015 p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pInsert, pz,
191026 if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){
191027 p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pDelete, pz,
191083 if( p->rc==SQLITE_OK ){
191088 p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz,
191108 return p->rc;
191176 p->rc = prepareFreeAndCollectError(
191185 return p->rc;
191194 if( p->rc==SQLITE_OK ){
191196 p->rc = sqlite3_open_v2(zName, &db, flags, bUseVfs ? p->zVfsName : 0);
191197 if( p->rc ){
191230 int rc;
191236 rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,
191239 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
191247 p->rc = SQLITE_CORRUPT;
191252 pRet->zTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);
191256 pRet->zIdx = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);
191284 pRet->zDataTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);
191288 rc = SQLITE_CORRUPT;
191293 if( rc==SQLITE_OK ) rc = rc2;
191295 p->rc = rc;
191305 assert( p->rc || (p->dbMain==0 && p->dbRbu==0) );
191306 assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 );
191311 if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){
191329 if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){
191330 p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, 0);
191339 if( p->rc==SQLITE_OK ){
191343 p->rc = prepareAndCollectError(p->dbRbu, &pCnt, &p->zErrmsg,
191346 if( p->rc==SQLITE_OK
191353 if( p->rc==SQLITE_OK ) p->rc = rc2;
191355 if( p->rc==SQLITE_OK && bOk==0 ){
191356 p->rc = SQLITE_ERROR;
191360 if( p->rc==SQLITE_OK ){
191361 p->rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0);
191367 if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){
191369 int rc;
191372 rc = sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p);
191373 if( rc!=SQLITE_NOTFOUND ) p->rc = rc;
191387 if( p->rc==SQLITE_OK && p->dbMain==0 ){
191400 p->rc = SQLITE_ERROR;
191419 p->rc = SQLITE_NOMEM;
191427 if( p->rc==SQLITE_OK ){
191428 p->rc = sqlite3_create_function(p->dbMain,
191433 if( p->rc==SQLITE_OK ){
191434 p->rc = sqlite3_create_function(p->dbMain,
191439 if( p->rc==SQLITE_OK ){
191440 p->rc = sqlite3_create_function(p->dbRbu,
191445 if( p->rc==SQLITE_OK ){
191446 p->rc = sqlite3_file_control(p->dbMain, "main", SQLITE_FCNTL_RBU, (void*)p);
191453 if( p->rc==SQLITE_OK ){
191454 p->rc = sqlite3_file_control(p->dbMain, "main", SQLITE_FCNTL_RBU, (void*)p);
191457 if( p->rc==SQLITE_NOTFOUND ){
191458 p->rc = SQLITE_ERROR;
191506 if( p->rc==SQLITE_OK ){
191509 p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, (void volatile**)&ptr);
191510 if( p->rc==SQLITE_OK ){
191540 if( p->rc==SQLITE_OK ){
191541 p->rc = sqlite3_exec(p->dbMain, "SELECT * FROM sqlite_master", 0, 0, 0);
191573 if( p->rc==SQLITE_OK ){
191577 if( rc2!=SQLITE_INTERNAL ) p->rc = rc2;
191580 if( p->rc==SQLITE_OK && p->nFrame>0 ){
191587 if( p->rc==SQLITE_OK ){
191589 p->rc = SQLITE_DONE;
191607 p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL);
191622 pRbu->rc = SQLITE_BUSY;
191664 assert( p->rc==SQLITE_OK );
191666 p->rc = pWal->pMethods->xRead(pWal, p->aBuf, p->pgsz, iOff);
191667 if( p->rc ) return;
191670 p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff);
191679 assert( p->rc==SQLITE_OK );
191680 p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_SHARED);
191681 if( p->rc==SQLITE_OK ){
191682 p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_EXCLUSIVE);
191730 assert( p->rc==SQLITE_OK && p->zErrmsg==0 );
191732 p->rc = SQLITE_NOMEM;
191742 if( p->rc==SQLITE_OK ){
191763 p->rc = SQLITE_OK;
191765 p->rc = SQLITE_IOERR;
191769 p->rc = SQLITE_IOERR_NOMEM;
191773 p->rc = SQLITE_IOERR_NOMEM;
191777 p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK;
191780 if( p->rc==SQLITE_OK ){
191828 p->rc = SQLITE_NOMEM;
191870 assert( p->rc==SQLITE_OK );
191898 p->rc = SQLITE_MISMATCH;
191908 p->rc = sqlite3_bind_value(pWriter, i+1, pVal);
191909 if( p->rc ) return;
191927 p->rc = sqlite3_bind_value(pWriter, pIter->nCol+1, pVal);
191930 if( p->rc==SQLITE_OK ){
191932 p->rc = resetAndCollectError(pWriter, &p->zErrmsg);
191967 if( p->rc==SQLITE_OK ) rbuStepOneOp(p, RBU_INSERT);
191980 for(i=0; p->rc==SQLITE_OK && i<pIter->nCol; i++){
191984 p->rc = sqlite3_bind_value(pUpdate, i+1, pVal);
191987 if( p->rc==SQLITE_OK
191993 p->rc = sqlite3_bind_value(pUpdate, pIter->nCol+1, pVal);
191995 if( p->rc==SQLITE_OK ){
191997 p->rc = resetAndCollectError(pUpdate, &p->zErrmsg);
192002 return p->rc;
192013 if( p->rc==SQLITE_OK ){
192018 p->rc = prepareAndCollectError(dbread, &pStmt, &p->zErrmsg,
192021 if( p->rc==SQLITE_OK ){
192032 if( p->rc==SQLITE_OK ){
192044 if( p->rc==SQLITE_OK || p->rc==SQLITE_DONE ){
192047 int rc;
192050 rc = prepareFreeAndCollectError(p->dbRbu, &pInsert, &p->zErrmsg,
192076 assert( pInsert==0 || rc==SQLITE_OK );
192078 if( rc==SQLITE_OK ){
192080 rc = sqlite3_finalize(pInsert);
192082 if( rc!=SQLITE_OK ) p->rc = rc;
192105 if( p->rc==SQLITE_OK ){
192107 p->rc = prepareFreeAndCollectError(p->dbRbu, &pPragma, &p->zErrmsg,
192110 if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPragma) ){
192111 p->rc = rbuMPrintfExec(p, p->dbMain, "PRAGMA main.%s = %d",
192129 p->rc = sqlite3_exec(p->dbMain, "PRAGMA writable_schema=1", 0,0, &p->zErrmsg);
192130 if( p->rc==SQLITE_OK ){
192131 p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg,
192138 while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){
192140 p->rc = sqlite3_exec(p->dbMain, zSql, 0, 0, &p->zErrmsg);
192143 if( p->rc!=SQLITE_OK ) return;
192145 if( p->rc==SQLITE_OK ){
192146 p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg,
192151 if( p->rc==SQLITE_OK ){
192152 p->rc = prepareAndCollectError(p->dbMain, &pInsert, &p->zErrmsg,
192157 while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){
192163 p->rc = sqlite3_reset(pInsert);
192165 if( p->rc==SQLITE_OK ){
192166 p->rc = sqlite3_exec(p->dbMain, "PRAGMA writable_schema=0",0,0,&p->zErrmsg);
192184 if( rbuIsVacuum(p) && p->nProgress==0 && p->rc==SQLITE_OK ){
192190 while( p->rc==SQLITE_OK && pIter->zTbl ){
192205 if( p->rc==SQLITE_OK ){
192206 int rc = sqlite3_step(pIter->pSelect);
192207 if( rc==SQLITE_ROW ){
192212 p->rc = sqlite3_reset(pIter->pSelect);
192220 if( p->rc==SQLITE_OK ){
192224 if( p->rc==SQLITE_OK ){
192225 p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg);
192227 if( p->rc==SQLITE_OK ){
192228 p->rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, &p->zErrmsg);
192236 if( p->rc==SQLITE_OK ){
192244 if( p->rc==SQLITE_OK ){
192249 p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
192252 if( p->rc==SQLITE_OK ){
192254 p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, &ptr);
192255 if( p->rc==SQLITE_OK ){
192260 if( p->rc==SQLITE_OK ){
192262 p->rc = SQLITE_DONE;
192283 && p->rc==SQLITE_OK
192294 return p->rc;
192322 assert( p->rc==SQLITE_OK );
192325 int rc = SQLITE_OK;
192327 while( rc==SQLITE_OK && pIter->zTbl && (pIter->bCleanup
192332 rc = rbuObjIterNext(p, pIter);
192335 if( rc==SQLITE_OK && !pIter->zTbl ){
192336 rc = SQLITE_ERROR;
192340 if( rc==SQLITE_OK ){
192342 rc = rbuObjIterPrepareAll(p, &p->objiter, p->nStep);
192345 p->rc = rc;
192358 assert( pVfs && p->rc==SQLITE_OK && p->zErrmsg==0 );
192374 assert( p->rc==SQLITE_OK );
192377 p->rc = sqlite3rbu_create_vfs(zRnd, 0);
192378 if( p->rc==SQLITE_OK ){
192410 int rc;
192414 rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &zErrmsg,
192418 if( rc!=SQLITE_OK ){
192425 rc = sqlite3_finalize(pStmt);
192426 if( rc==SQLITE_OK ){
192452 if( p->rc==SQLITE_OK ){
192458 p->rc = sqlite3_create_function(p->dbRbu,
192464 if( p->rc==SQLITE_OK ){
192465 p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,
192469 if( p->rc==SQLITE_OK ){
192473 p->rc = sqlite3_finalize(pStmt);
192476 if( p->rc==SQLITE_OK && bExists ){
192477 p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,
192481 if( p->rc==SQLITE_OK ){
192485 p->rc = sqlite3_finalize(pStmt);
192511 if( p->rc==SQLITE_OK ){
192539 if( p->rc==SQLITE_OK ){
192541 assert( pState || p->rc!=SQLITE_OK );
192542 if( p->rc==SQLITE_OK ){
192556 assert( p->rc!=SQLITE_OK || p->eStage!=0 );
192558 if( p->rc==SQLITE_OK && p->pTargetFd->pWalFd ){
192560 p->rc = SQLITE_ERROR;
192568 if( p->rc==SQLITE_OK
192578 p->rc = SQLITE_BUSY;
192585 if( p->rc==SQLITE_OK ){
192588 p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
192591 if( p->rc==SQLITE_OK ){
192592 p->rc = rbuObjIterFirst(p, &p->objiter);
192597 if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){
192598 p->rc = SQLITE_DONE;
192601 if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){
192608 if( p->rc==SQLITE_OK ){
192609 p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
192615 if( p->rc==SQLITE_OK ){
192618 p->rc = sqlite3_exec(
192623 if( p->rc==SQLITE_OK ){
192632 p->rc = SQLITE_DONE;
192634 p->rc = SQLITE_CORRUPT;
192653 pRet->rc = SQLITE_MISUSE;
192707 if( p->rc==SQLITE_CONSTRAINT && p->zErrmsg ){
192725 int rc;
192729 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
192730 p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg);
192734 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
192736 p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
192741 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
192742 p->rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, &p->zErrmsg);
192753 if( rbuIsVacuum(p) && p->rc!=SQLITE_OK && p->dbRbu ){
192755 if( p->rc==SQLITE_DONE && rc2!=SQLITE_OK ) p->rc = rc2;
192767 rc = p->rc;
192776 rc = SQLITE_NOMEM;
192779 return rc;
192845 if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){
192848 assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );
192859 int rc = p->rc;
192860 if( rc==SQLITE_DONE ) return SQLITE_OK;
192864 assert( rc!=SQLITE_DONE );
192865 if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0);
192869 if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
192871 rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
192874 p->rc = rc;
192876 rc = p->rc;
192879 assert( rc!=SQLITE_DONE );
192880 if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0);
192881 if( rc==SQLITE_OK ){
192883 rc = sqlite3_exec(p->dbRbu, zBegin, 0, 0, 0);
192885 if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "BEGIN IMMEDIATE", 0, 0,0);
192888 p->rc = rc;
192889 return rc;
193045 int rc;
193067 rc = p->pReal->pMethods->xClose(p->pReal);
193068 return rc;
193110 int rc;
193114 rc = rbuCaptureWalRead(p->pRbu, iOfst, iAmt);
193120 rc = SQLITE_OK;
193123 rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);
193130 && rc==SQLITE_IOERR_SHORT_READ && iOfst==0
193132 && pRbu->rc==SQLITE_OK
193135 rc = pFd->pMethods->xRead(pFd, zBuf, iAmt, iOfst);
193136 if( rc==SQLITE_OK ){
193154 if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){
193162 return rc;
193176 int rc;
193180 rc = rbuCaptureDbWrite(p->pRbu, iOfst);
193191 rc = rbuUpdateTempSize(p, szNew);
193192 if( rc!=SQLITE_OK ) return rc;
193196 rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);
193197 if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){
193205 return rc;
193214 int rc = rbuUpdateTempSize(p, size);
193215 if( rc!=SQLITE_OK ) return rc;
193239 int rc;
193240 rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);
193246 if( rc==SQLITE_OK && *pSize==0
193252 return rc;
193261 int rc = SQLITE_OK;
193269 rc = SQLITE_BUSY;
193271 rc = p->pReal->pMethods->xLock(p->pReal, eLock);
193274 return rc;
193299 int rc;
193310 rc = xControl(p->pReal, op, pArg);
193312 if( rc==SQLITE_NOTFOUND ){
193316 rc = xControl(p->pReal, SQLITE_FCNTL_ZIPVFS, &dummy);
193317 if( rc==SQLITE_OK ){
193318 rc = SQLITE_ERROR;
193320 }else if( rc==SQLITE_NOTFOUND ){
193327 rc = SQLITE_OK;
193330 return rc;
193339 rc = xControl(p->pReal, op, pArg);
193340 if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){
193345 if( zOut==0 ) rc = SQLITE_NOMEM;
193348 return rc;
193373 int rc = SQLITE_OK;
193385 if( ofst==WAL_LOCK_CKPT && n==1 ) rc = SQLITE_BUSY;
193396 rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);
193397 if( bCapture && rc==SQLITE_OK ){
193403 return rc;
193417 int rc = SQLITE_OK;
193429 rc = SQLITE_NOMEM;
193437 if( rc==SQLITE_OK && p->apShm[iRegion]==0 ){
193440 rc = SQLITE_NOMEM;
193447 if( rc==SQLITE_OK ){
193454 rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);
193457 return rc;
193473 int rc = SQLITE_OK;
193482 rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
193484 return rc;
193547 int rc = SQLITE_OK;
193588 rc = SQLITE_NOMEM;
193608 if( rc==SQLITE_OK ){
193609 rc = pRealVfs->xOpen(pRealVfs, zOpen, pFd->pReal, oflags, pOutFlags);
193623 return rc;
193646 int rc;
193648 rc = pRealVfs->xAccess(pRealVfs, zPath, flags, pResOut);
193664 if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){
193668 rc = SQLITE_CANTOPEN;
193671 rc = rbuVfsFileSize(&pDb->base, &sz);
193677 return rc;
193819 int rc = SQLITE_OK;
193827 rc = SQLITE_NOMEM;
193833 rc = SQLITE_NOTFOUND;
193846 rc = SQLITE_NOMEM;
193848 rc = sqlite3_vfs_register(&pNew->base, 0);
193852 if( rc!=SQLITE_OK ){
193858 return rc;
194029 int rc = SQLITE_OK;
194043 rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);
194044 if( rc==SQLITE_OK ){
194046 if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
194049 assert( rc==SQLITE_OK || pTab==0 );
194050 if( rc==SQLITE_OK ){
194057 return rc;
194286 int rc;
194289 rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg, 0);
194290 if( rc!=SQLITE_OK ){
194292 return rc;
194340 int rc;
194353 rc = sqlite3_step(pCsr->pStmt);
194354 if( rc==SQLITE_ROW ){
194362 rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0);
194367 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
194426 rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0);
194430 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
194437 if( rc==SQLITE_OK ){
194443 rc = statDecodePage(pBt, p);
194444 if( rc==SQLITE_OK ){
194464 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
194473 return rc;
194489 int rc = SQLITE_OK;
194514 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
194518 if( rc==SQLITE_OK ){
194519 rc = statNext(pCursor);
194521 return rc;
194688 int rc = SQLITE_OK;
194690 rc = sqlite3_declare_vtab(db,
194692 if( rc==SQLITE_OK ){
194694 if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
194697 assert( rc==SQLITE_OK || pTab==0 );
194698 if( rc==SQLITE_OK ){
194704 return rc;
194808 int rc = SQLITE_OK;
194811 return rc;
194836 int rc;
194871 rc = sqlite3PagerGet(pCsr->pPager, 1, &pCsr->pPage1, 0);
194872 return rc;
194881 int rc = SQLITE_OK;
194889 rc = sqlite3PagerGet(pCsr->pPager, pCsr->pgno, (DbPage**)&pDbPage, 0);
194890 if( rc==SQLITE_OK ){
194921 int rc = SQLITE_OK;
194961 rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pDbPage, 0);
194962 if( rc==SQLITE_OK ){
194963 rc = sqlite3PagerWrite(pDbPage);
194964 if( rc==SQLITE_OK ){
194971 return rc;
195080 int rc; /* Non-zero if an error has occurred */
195125 int rc; /* Iterator error code */
195536 int rc;
195541 rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal);
195543 rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal);
195545 if( rc!=SQLITE_OK ) return rc;
195869 int rc; /* Error code from preupdate_new/old */
195879 rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal);
195882 rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal);
195884 assert( rc==SQLITE_OK );
196004 int rc;
196017 rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0);
196018 if( rc==SQLITE_OK ){
196025 }else if( rc==SQLITE_ERROR ){
196028 return rc;
196035 rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);
196037 if( rc!=SQLITE_OK ) return rc;
196044 rc = sqlite3_reset(pStmt);
196046 if( rc==SQLITE_OK ){
196050 rc = SQLITE_NOMEM;
196053 if( rc==SQLITE_OK ){
196075 rc = sqlite3_reset(pStmt);
196082 if( rc==SQLITE_OK ){
196094 return rc;
196113 pSession->rc = sessionTableInfo(pSession->db, pSession->zDb,
196116 if( pSession->rc==SQLITE_OK ){
196129 return (pSession->rc || pTab->abPK==0);
196146 int rc = p->hook.xOld(p->hook.pCtx, iCol, &pVal);
196147 if( rc==SQLITE_OK && iCol==1 && sqlite3_value_type(pVal)==SQLITE_NULL ){
196151 return rc;
196156 int rc = p->hook.xNew(p->hook.pCtx, iCol, &pVal);
196157 if( rc==SQLITE_OK && iCol==1 && sqlite3_value_type(pVal)==SQLITE_NULL ){
196161 return rc;
196188 int rc = SQLITE_OK;
196191 if( pSession->rc ) return;
196199 pSession->rc = SQLITE_SCHEMA;
196205 pSession->rc = SQLITE_NOMEM;
196220 rc = SQLITE_NOMEM;
196231 rc = sessionPreupdateHash(pSession, pTab, op==SQLITE_INSERT, &iHash, &bNull);
196232 if( rc!=SQLITE_OK ) goto error_out;
196249 assert( rc==SQLITE_OK );
196266 rc = sessionSerializeValue(0, p, &nByte);
196267 if( rc!=SQLITE_OK ) goto error_out;
196273 rc = SQLITE_NOMEM;
196320 if( rc!=SQLITE_OK ){
196321 pSession->rc = rc;
196330 int rc = SQLITE_OK;
196345 rc = sqlite3session_attach(pSession, zName);
196346 if( rc==SQLITE_OK ){
196353 assert( rc==SQLITE_OK || pRet==0 );
196355 return rc;
196382 if( pSession->rc ) continue;
196385 pSession->rc = sessionFindTable(pSession, zName, &pTab);
196387 assert( pSession->rc==SQLITE_OK );
196546 int rc = SQLITE_OK;
196550 rc = SQLITE_NOMEM;
196553 rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);
196554 if( rc==SQLITE_OK ){
196561 rc = sqlite3_finalize(pStmt);
196566 return rc;
196575 int rc = SQLITE_OK;
196581 rc = SQLITE_NOMEM;
196588 rc = SQLITE_NOMEM;
196591 rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);
196593 if( rc==SQLITE_OK ){
196600 rc = sqlite3_finalize(pStmt);
196606 return rc;
196616 int rc = pSession->rc;
196624 if( rc==SQLITE_OK ){
196630 rc = sessionFindTable(pSession, zTbl, &pTo);
196633 rc = pSession->rc;
196638 if( rc==SQLITE_OK ){
196644 rc = sessionTableInfo(db, zFrom, zTbl, &nCol, 0, &azCol, &abPK);
196645 if( rc==SQLITE_OK ){
196660 rc = SQLITE_SCHEMA;
196668 if( rc==SQLITE_OK ){
196675 if( rc==SQLITE_OK ){
196676 rc = sessionDiffFindNew(SQLITE_INSERT, pSession, pTo, zDb, zFrom, zExpr);
196680 if( rc==SQLITE_OK ){
196681 rc = sessionDiffFindNew(SQLITE_DELETE, pSession, pTo, zFrom, zDb, zExpr);
196685 if( rc==SQLITE_OK ){
196686 rc = sessionDiffFindModified(pSession, pTo, zFrom, zExpr);
196695 return rc;
196816 int rc = SQLITE_OK;
196836 rc = SQLITE_NOMEM;
196854 return rc;
196892 int rc = *pRc;
196893 if( rc==SQLITE_OK ){
196895 rc = sessionSerializeValue(0, pVal, &nByte);
196896 sessionBufferGrow(p, nByte, &rc);
196897 if( rc==SQLITE_OK ){
196898 rc = sessionSerializeValue(&p->aBuf[p->nBuf], pVal, 0);
196901 *pRc = rc;
197092 int rc = SQLITE_OK;
197099 sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);
197100 sessionAppendByte(pBuf, p->bIndirect, &rc);
197152 sessionAppendBlob(pBuf, pCsr, nAdvance, &rc);
197154 sessionAppendByte(pBuf, 0, &rc);
197161 sessionAppendCol(&buf2, pStmt, i, &rc);
197163 sessionAppendByte(&buf2, 0, &rc);
197172 sessionAppendBlob(pBuf, buf2.aBuf, buf2.nBuf, &rc);
197176 return rc;
197191 int rc = SQLITE_OK;
197193 sessionAppendByte(pBuf, SQLITE_DELETE, &rc);
197194 sessionAppendByte(pBuf, p->bIndirect, &rc);
197197 sessionAppendBlob(pBuf, p->aRecord, p->nRecord, &rc);
197224 sessionAppendBlob(pBuf, pStart, (int)(a-pStart), &rc);
197230 return rc;
197248 int rc = SQLITE_OK;
197257 if( zSql==0 ) rc = SQLITE_NOMEM;
197263 sessionAppendStr(&buf, "SELECT * FROM ", &rc);
197264 sessionAppendIdent(&buf, zDb, &rc);
197265 sessionAppendStr(&buf, ".", &rc);
197266 sessionAppendIdent(&buf, zTab, &rc);
197267 sessionAppendStr(&buf, " WHERE ", &rc);
197270 sessionAppendStr(&buf, zSep, &rc);
197271 sessionAppendIdent(&buf, azCol[i], &rc);
197272 sessionAppendStr(&buf, " IS ?", &rc);
197273 sessionAppendInteger(&buf, i+1, &rc);
197281 if( rc==SQLITE_OK ){
197282 rc = sqlite3_prepare_v2(db, zSql, nSql, ppStmt, 0);
197285 return rc;
197303 int rc = SQLITE_OK;
197306 for(i=0; i<nCol && rc==SQLITE_OK; i++){
197318 rc = sqlite3_bind_int64(pSelect, i+1, iVal);
197329 rc = sqlite3_bind_double(pSelect, i+1, rVal);
197339 rc = sqlite3_bind_text(pSelect, i+1, (char *)a, n, SQLITE_TRANSIENT);
197350 rc = sqlite3_bind_blob(pSelect, i+1, a, n, SQLITE_TRANSIENT);
197358 return rc;
197401 int rc; /* Return code */
197413 if( pSession->rc ) return pSession->rc;
197414 rc = sqlite3_exec(pSession->db, "SAVEPOINT changeset", 0, 0, 0);
197415 if( rc!=SQLITE_OK ) return rc;
197419 for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
197431 rc = sessionTableInfo(db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK);
197432 if( !rc && (pTab->nCol!=nCol || memcmp(abPK, pTab->abPK, nCol)) ){
197433 rc = SQLITE_SCHEMA;
197437 sessionAppendTableHdr(&buf, bPatchset, pTab, &rc);
197440 if( rc==SQLITE_OK ){
197441 rc = sessionSelectStmt(
197446 for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){
197449 for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){
197450 rc = sessionSelectBind(pSel, nCol, abPK, p);
197451 if( rc!=SQLITE_OK ) continue;
197455 sessionAppendByte(&buf, SQLITE_INSERT, &rc);
197456 sessionAppendByte(&buf, p->bIndirect, &rc);
197458 sessionAppendCol(&buf, pSel, iCol, &rc);
197461 rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);
197464 rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);
197466 if( rc==SQLITE_OK ){
197467 rc = sqlite3_reset(pSel);
197473 && rc==SQLITE_OK
197477 rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);
197493 if( rc==SQLITE_OK ){
197499 rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);
197506 return rc;
197707 int rc = SQLITE_OK;
197709 while( !pIn->bEof && (pIn->iNext+nByte)>=pIn->nData && rc==SQLITE_OK ){
197713 if( SQLITE_OK==sessionBufferGrow(&pIn->buf, nNew, &rc) ){
197714 rc = pIn->xInput(pIn->pIn, &pIn->buf.aBuf[pIn->buf.nBuf], &nNew);
197726 return rc;
197808 int rc = SQLITE_OK;
197810 for(i=0; i<nCol && rc==SQLITE_OK; i++){
197813 rc = sessionInputBuffer(pIn, 9);
197814 if( rc==SQLITE_OK ){
197816 rc = SQLITE_CORRUPT_BKPT;
197822 if( !apOut[i] ) rc = SQLITE_NOMEM;
197827 if( rc==SQLITE_OK ){
197832 rc = sessionInputBuffer(pIn, nByte);
197833 if( rc==SQLITE_OK ){
197835 rc = SQLITE_CORRUPT_BKPT;
197838 rc = sessionValueSetStr(apOut[i],&pIn->aData[pIn->iNext],nByte,enc);
197857 return rc;
197874 int rc = SQLITE_OK;
197878 rc = sessionInputBuffer(pIn, 9);
197879 if( rc==SQLITE_OK ){
197889 rc = SQLITE_CORRUPT_BKPT;
197891 rc = sessionInputBuffer(pIn, nRead+nCol+100);
197896 while( rc==SQLITE_OK ){
197901 rc = sessionInputBuffer(pIn, nRead + 100);
197904 return rc;
197921 int rc = SQLITE_OK;
197924 for(i=0; rc==SQLITE_OK && i<nCol; i++){
197926 rc = sessionInputBuffer(pIn, nByte + 10);
197927 if( rc==SQLITE_OK ){
197933 rc = sessionInputBuffer(pIn, nByte);
197940 return rc;
197961 int rc;
197963 assert( p->rc==SQLITE_OK );
197965 rc = sessionChangesetBufferTblhdr(&p->in, &nCopy);
197966 if( rc==SQLITE_OK ){
197975 sessionBufferGrow(&p->tblhdr, nByte, &rc);
197977 rc = SQLITE_CORRUPT_BKPT;
197981 if( rc==SQLITE_OK ){
197991 return (p->rc = rc);
198022 if( p->rc!=SQLITE_OK ) return p->rc;
198036 p->rc = sessionInputBuffer(&p->in, 2);
198037 if( p->rc!=SQLITE_OK ) return p->rc;
198051 if( sessionChangesetReadTblhdr(p) ) return p->rc;
198052 if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;
198062 return (p->rc = SQLITE_CORRUPT_BKPT);
198068 return (p->rc = SQLITE_CORRUPT_BKPT);
198081 p->rc = sessionChangesetBufferRecord(&p->in, nVal, pnRec);
198082 if( p->rc!=SQLITE_OK ) return p->rc;
198092 p->rc = sessionReadRecord(&p->in, p->nCol, abPK, apOld);
198093 if( p->rc!=SQLITE_OK ) return p->rc;
198098 p->rc = sessionReadRecord(&p->in, p->nCol, 0, apNew);
198099 if( p->rc!=SQLITE_OK ) return p->rc;
198112 if( p->apValue[i]==0 ) return (p->rc = SQLITE_CORRUPT_BKPT);
198289 int rc = SQLITE_OK;
198292 rc = p->rc;
198300 return rc;
198310 int rc = SQLITE_OK; /* Return value */
198330 if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;
198346 if( (rc = sessionChangesetBufferTblhdr(pInput, &nByte)) ){
198351 sessionAppendBlob(&sPK, &pInput->aData[pInput->iNext+nVar], nCol, &rc);
198352 sessionAppendByte(&sOut, eType, &rc);
198353 sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);
198354 if( rc ) goto finished_invert;
198369 assert( rc==SQLITE_OK );
198370 rc = sessionChangesetBufferRecord(pInput, nCol, &nByte);
198371 sessionAppendByte(&sOut, eType2, &rc);
198372 sessionAppendByte(&sOut, bIndirect, &rc);
198373 sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);
198375 if( rc ) goto finished_invert;
198385 rc = SQLITE_NOMEM;
198392 sessionAppendByte(&sOut, eType, &rc);
198393 sessionAppendByte(&sOut, pInput->aData[pInput->iNext+1], &rc);
198397 rc = sessionReadRecord(pInput, nCol, 0, &apVal[0]);
198398 if( rc==SQLITE_OK ){
198399 rc = sessionReadRecord(pInput, nCol, 0, &apVal[nCol]);
198407 sessionAppendValue(&sOut, pVal, &rc);
198415 sessionAppendValue(&sOut, pVal, &rc);
198422 if( rc!=SQLITE_OK ){
198430 rc = SQLITE_CORRUPT_BKPT;
198434 assert( rc==SQLITE_OK );
198436 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
198438 if( rc!=SQLITE_OK ) goto finished_invert;
198442 assert( rc==SQLITE_OK );
198448 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
198455 return rc;
198488 int rc;
198495 rc = sessionChangesetInvert(&sInput, xOutput, pOut, 0, 0);
198497 return rc;
198542 int rc = SQLITE_OK;
198546 sessionAppendStr(&buf, "DELETE FROM ", &rc);
198547 sessionAppendIdent(&buf, zTab, &rc);
198548 sessionAppendStr(&buf, " WHERE ", &rc);
198553 sessionAppendStr(&buf, zSep, &rc);
198554 sessionAppendIdent(&buf, p->azCol[i], &rc);
198555 sessionAppendStr(&buf, " = ?", &rc);
198556 sessionAppendInteger(&buf, i+1, &rc);
198562 sessionAppendStr(&buf, " AND (?", &rc);
198563 sessionAppendInteger(&buf, p->nCol+1, &rc);
198564 sessionAppendStr(&buf, " OR ", &rc);
198569 sessionAppendStr(&buf, zSep, &rc);
198570 sessionAppendIdent(&buf, p->azCol[i], &rc);
198571 sessionAppendStr(&buf, " IS ?", &rc);
198572 sessionAppendInteger(&buf, i+1, &rc);
198576 sessionAppendStr(&buf, ")", &rc);
198579 if( rc==SQLITE_OK ){
198580 rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pDelete, 0);
198584 return rc;
198623 int rc = SQLITE_OK;
198629 sessionAppendStr(&buf, "UPDATE ", &rc);
198630 sessionAppendIdent(&buf, zTab, &rc);
198631 sessionAppendStr(&buf, " SET ", &rc);
198635 sessionAppendStr(&buf, zSep, &rc);
198636 sessionAppendIdent(&buf, p->azCol[i], &rc);
198637 sessionAppendStr(&buf, " = CASE WHEN ?", &rc);
198638 sessionAppendInteger(&buf, i*3+2, &rc);
198639 sessionAppendStr(&buf, " THEN ?", &rc);
198640 sessionAppendInteger(&buf, i*3+3, &rc);
198641 sessionAppendStr(&buf, " ELSE ", &rc);
198642 sessionAppendIdent(&buf, p->azCol[i], &rc);
198643 sessionAppendStr(&buf, " END", &rc);
198648 sessionAppendStr(&buf, " WHERE ", &rc);
198651 sessionAppendIdent(&buf, p->azCol[i], &rc);
198652 sessionAppendStr(&buf, " = ?", &rc);
198653 sessionAppendInteger(&buf, i*3+1, &rc);
198654 sessionAppendStr(&buf, " AND ", &rc);
198659 sessionAppendStr(&buf, " (?", &rc);
198660 sessionAppendInteger(&buf, p->nCol*3+1, &rc);
198661 sessionAppendStr(&buf, " OR 1", &rc);
198664 sessionAppendStr(&buf, " AND (?", &rc);
198665 sessionAppendInteger(&buf, i*3+2, &rc);
198666 sessionAppendStr(&buf, "=0 OR ", &rc);
198667 sessionAppendIdent(&buf, p->azCol[i], &rc);
198668 sessionAppendStr(&buf, " IS ?", &rc);
198669 sessionAppendInteger(&buf, i*3+1, &rc);
198670 sessionAppendStr(&buf, ")", &rc);
198673 sessionAppendStr(&buf, ")", &rc);
198675 if( rc==SQLITE_OK ){
198676 rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pUpdate, 0);
198680 return rc;
198720 int rc = SQLITE_OK;
198724 sessionAppendStr(&buf, "INSERT INTO main.", &rc);
198725 sessionAppendIdent(&buf, zTab, &rc);
198726 sessionAppendStr(&buf, "(", &rc);
198728 if( i!=0 ) sessionAppendStr(&buf, ", ", &rc);
198729 sessionAppendIdent(&buf, p->azCol[i], &rc);
198732 sessionAppendStr(&buf, ") VALUES(?", &rc);
198734 sessionAppendStr(&buf, ", ?", &rc);
198736 sessionAppendStr(&buf, ")", &rc);
198738 if( rc==SQLITE_OK ){
198739 rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pInsert, 0);
198742 return rc;
198756 int rc = sessionSelectRow(db, "sqlite_stat1", p);
198757 if( rc==SQLITE_OK ){
198758 rc = sessionPrepare(db, &p->pInsert,
198764 if( rc==SQLITE_OK ){
198765 rc = sessionPrepare(db, &p->pUpdate,
198775 if( rc==SQLITE_OK ){
198776 rc = sessionPrepare(db, &p->pDelete,
198782 return rc;
198830 int rc = SQLITE_OK;
198838 for(i=0; rc==SQLITE_OK && i<nCol; i++){
198845 rc = SQLITE_CORRUPT_BKPT;
198847 rc = sessionBindValue(pStmt, i+1, pVal);
198851 return rc;
198877 int rc; /* Return code */
198883 rc = sessionBindRow(pIter,
198888 if( rc==SQLITE_OK ){
198889 rc = sqlite3_step(pSelect);
198890 if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect);
198893 return rc;
198911 int rc = SQLITE_OK;
198918 sessionAppendByte(&p->rebase, 'T', &rc);
198919 sessionAppendVarint(&p->rebase, p->nCol, &rc);
198920 sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc);
198921 sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc);
198929 (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc
198931 sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc);
198939 sessionAppendValue(&p->rebase, pVal, &rc);
198942 return rc;
198989 int rc;
199002 rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect);
199004 rc = SQLITE_OK;
199007 if( rc==SQLITE_ROW ){
199012 rc = sqlite3_reset(p->pSelect);
199013 }else if( rc==SQLITE_OK ){
199019 sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);
199024 if( res==SQLITE_CHANGESET_REPLACE ) rc = SQLITE_MISUSE;
199028 if( rc==SQLITE_OK ){
199039 rc = SQLITE_ABORT;
199043 rc = SQLITE_MISUSE;
199046 if( rc==SQLITE_OK ){
199047 rc = sessionRebaseAdd(p, res, pIter);
199051 return rc;
199089 int rc = SQLITE_OK;
199111 rc = sessionBindRow(pIter, sqlite3changeset_old, nCol, abPK, p->pDelete);
199112 if( rc==SQLITE_OK && sqlite3_bind_parameter_count(p->pDelete)>nCol ){
199113 rc = sqlite3_bind_int(p->pDelete, nCol+1, (pbRetry==0 || abPK));
199115 if( rc!=SQLITE_OK ) return rc;
199118 rc = sqlite3_reset(p->pDelete);
199119 if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){
199120 rc = sessionConflictHandler(
199123 }else if( (rc&0xff)==SQLITE_CONSTRAINT ){
199124 rc = sessionConflictHandler(
199133 for(i=0; rc==SQLITE_OK && i<nCol; i++){
199139 rc = sessionBindValue(p->pUpdate, i*3+1, pOld);
199141 if( rc==SQLITE_OK && pNew ){
199142 rc = sessionBindValue(p->pUpdate, i*3+3, pNew);
199145 if( rc==SQLITE_OK ){
199148 if( rc!=SQLITE_OK ) return rc;
199153 rc = sqlite3_reset(p->pUpdate);
199155 if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){
199160 rc = sessionConflictHandler(
199164 }else if( (rc&0xff)==SQLITE_CONSTRAINT ){
199166 rc = sessionConflictHandler(
199177 rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect);
199178 if( rc==SQLITE_ROW ){
199179 rc = SQLITE_CONSTRAINT;
199184 if( rc==SQLITE_OK ){
199185 rc = sessionBindRow(pIter, sqlite3changeset_new, nCol, 0, p->pInsert);
199186 if( rc!=SQLITE_OK ) return rc;
199189 rc = sqlite3_reset(p->pInsert);
199192 if( (rc&0xff)==SQLITE_CONSTRAINT ){
199193 rc = sessionConflictHandler(
199199 return rc;
199221 int rc;
199223 rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry);
199224 if( rc==SQLITE_OK ){
199234 rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
199244 rc = sqlite3_exec(db, "SAVEPOINT replace_op", 0, 0, 0);
199245 if( rc==SQLITE_OK ){
199246 rc = sessionBindRow(pIter,
199250 if( rc==SQLITE_OK ){
199252 rc = sqlite3_reset(pApply->pDelete);
199254 if( rc==SQLITE_OK ){
199255 rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
199257 if( rc==SQLITE_OK ){
199258 rc = sqlite3_exec(db, "RELEASE replace_op", 0, 0, 0);
199263 return rc;
199277 int rc = SQLITE_OK;
199284 rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf, 0);
199285 if( rc==SQLITE_OK ){
199292 sessionBufferGrow(&pIter2->tblhdr, nByte, &rc);
199294 if( rc==SQLITE_OK ) memset(pIter2->apValue, 0, nByte);
199296 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter2) ){
199297 rc = sessionApplyOneWithRetry(db, pIter2, pApply, xConflict, pCtx);
199301 if( rc==SQLITE_OK ) rc = rc2;
199306 if( rc!=SQLITE_OK ) break;
199313 return rc;
199340 int rc = SQLITE_OK; /* Return code */
199353 rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
199355 if( rc==SQLITE_OK ){
199356 rc = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 1", 0, 0, 0);
199358 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){
199368 rc = sessionRetryConstraints(
199371 if( rc!=SQLITE_OK ) break;
199398 rc = SQLITE_NOMEM;
199408 rc = sessionTableInfo(
199411 if( rc!=SQLITE_OK ) break;
199439 if( (rc = sessionStat1Sql(db, &sApply) ) ){
199444 if((rc = sessionSelectRow(db, zTab, &sApply))
199445 || (rc = sessionUpdateRow(db, zTab, &sApply))
199446 || (rc = sessionDeleteRow(db, zTab, &sApply))
199447 || (rc = sessionInsertRow(db, zTab, &sApply))
199462 rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);
199466 if( rc==SQLITE_OK ){
199467 rc = sqlite3changeset_finalize(pIter);
199472 if( rc==SQLITE_OK ){
199473 rc = sessionRetryConstraints(db, bPatchset, zTab, &sApply, xConflict, pCtx);
199476 if( rc==SQLITE_OK ){
199486 rc = SQLITE_CONSTRAINT;
199493 if( rc==SQLITE_OK ){
199494 rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
199502 if( rc==SQLITE_OK && bPatchset==0 && sApply.bRebase ){
199515 return rc;
199541 int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset,bInverse);
199542 if( rc==SQLITE_OK ){
199543 rc = sessionChangesetApply(
199547 return rc;
199599 int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse);
199600 if( rc==SQLITE_OK ){
199601 rc = sessionChangesetApply(
199605 return rc;
199631 int rc; /* Error code */
199653 int rc = SQLITE_OK;
199692 rc = SQLITE_NOMEM;
199816 return rc;
199830 int rc = SQLITE_OK;
199846 rc = SQLITE_ERROR;
199865 rc = SQLITE_NOMEM;
199882 rc = SQLITE_SCHEMA;
199888 rc = SQLITE_NOMEM;
199913 rc = sessionChangeMerge(pTab, bRebase,
199916 if( rc ) break;
199924 if( rc==SQLITE_OK ) rc = pIter->rc;
199925 return rc;
199953 int rc = SQLITE_OK;
199961 for(pTab=pGrp->pList; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
199965 sessionAppendTableHdr(&buf, pGrp->bPatch, pTab, &rc);
199969 sessionAppendByte(&buf, p->op, &rc);
199970 sessionAppendByte(&buf, p->bIndirect, &rc);
199971 sessionAppendBlob(&buf, p->aRecord, p->nRecord, &rc);
199972 if( rc==SQLITE_OK && xOutput && buf.nBuf>=sessions_strm_chunk_size ){
199973 rc = xOutput(pOut, buf.aBuf, buf.nBuf);
199980 if( rc==SQLITE_OK ){
199982 if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
199991 return rc;
199998 int rc = SQLITE_OK; /* Return code */
200002 rc = SQLITE_NOMEM;
200007 return rc;
200016 int rc; /* Return code */
200018 rc = sqlite3changeset_start(&pIter, nData, pData);
200019 if( rc==SQLITE_OK ){
200020 rc = sessionChangesetToHash(pIter, pGrp, 0);
200023 return rc;
200047 int rc; /* Return code */
200049 rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
200050 if( rc==SQLITE_OK ){
200051 rc = sessionChangesetToHash(pIter, pGrp, 0);
200054 return rc;
200090 int rc;
200092 rc = sqlite3changegroup_new(&pGrp);
200093 if( rc==SQLITE_OK ){
200094 rc = sqlite3changegroup_add(pGrp, nLeft, pLeft);
200096 if( rc==SQLITE_OK ){
200097 rc = sqlite3changegroup_add(pGrp, nRight, pRight);
200099 if( rc==SQLITE_OK ){
200100 rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);
200104 return rc;
200119 int rc;
200121 rc = sqlite3changegroup_new(&pGrp);
200122 if( rc==SQLITE_OK ){
200123 rc = sqlite3changegroup_add_strm(pGrp, xInputA, pInA);
200125 if( rc==SQLITE_OK ){
200126 rc = sqlite3changegroup_add_strm(pGrp, xInputB, pInB);
200128 if( rc==SQLITE_OK ){
200129 rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut);
200133 return rc;
200274 int rc = SQLITE_OK;
200294 rc = SQLITE_ERROR;
200298 sessionAppendByte(&sOut, pIter->bPatchset ? 'P' : 'T', &rc);
200299 sessionAppendVarint(&sOut, pIter->nCol, &rc);
200300 sessionAppendBlob(&sOut, pIter->abPK, pIter->nCol, &rc);
200301 sessionAppendBlob(&sOut,(u8*)pIter->zTab,(int)strlen(pIter->zTab)+1,&rc);
200304 if( pTab && rc==SQLITE_OK ){
200321 sessionAppendByte(&sOut, SQLITE_UPDATE, &rc);
200322 sessionAppendByte(&sOut, pIter->bIndirect, &rc);
200323 sessionAppendBlob(&sOut, pChange->aRecord, pChange->nRecord, &rc);
200324 sessionAppendBlob(&sOut, aRec, nRec, &rc);
200335 sessionAppendByte(&sOut, SQLITE_INSERT, &rc);
200336 sessionAppendByte(&sOut, pIter->bIndirect, &rc);
200339 pChange->aRecord, pChange->nRecord, &rc
200344 aRec, nRec, pChange->aRecord, pChange->nRecord, &rc
200353 sessionAppendByte(&sOut, SQLITE_DELETE, &rc);
200354 sessionAppendByte(&sOut, pIter->bIndirect, &rc);
200356 pChange->aRecord, pChange->nRecord, aRec, nRec, &rc
200364 sessionAppendByte(&sOut, pIter->op, &rc);
200365 sessionAppendByte(&sOut, pIter->bIndirect, &rc);
200366 sessionAppendBlob(&sOut, aRec, nRec, &rc);
200368 if( rc==SQLITE_OK && xOutput && sOut.nBuf>sessions_strm_chunk_size ){
200369 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
200372 if( rc ) break;
200375 if( rc!=SQLITE_OK ){
200380 if( rc==SQLITE_OK ){
200383 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
200392 return rc;
200399 int rc = SQLITE_OK;
200404 rc = SQLITE_NOMEM;
200409 return rc;
200420 int rc; /* Return code */
200421 rc = sqlite3changeset_start(&pIter, nRebase, (void*)pRebase);
200422 if( rc==SQLITE_OK ){
200423 rc = sessionChangesetToHash(pIter, &p->grp, 1);
200426 return rc;
200438 int rc = sqlite3changeset_start(&pIter, nIn, (void*)pIn);
200440 if( rc==SQLITE_OK ){
200441 rc = sessionRebase(p, pIter, 0, 0, pnOut, ppOut);
200445 return rc;
200459 int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
200461 if( rc==SQLITE_OK ){
200462 rc = sessionRebase(p, pIter, xOutput, pOut, 0, 0);
200466 return rc;
200483 int rc = SQLITE_OK;
200494 rc = SQLITE_MISUSE;
200497 return rc;
203447 int rc = SQLITE_OK;
203451 while( rc==SQLITE_OK && pIter->iInst<pIter->nInst ){
203453 rc = pIter->pApi->xInst(pIter->pFts, pIter->iInst, &ip, &ic, &io);
203454 if( rc==SQLITE_OK ){
203470 return rc;
203483 int rc;
203489 rc = pApi->xInstCount(pFts, &pIter->nInst);
203491 if( rc==SQLITE_OK ){
203492 rc = fts5CInstIterNext(pIter);
203495 return rc;
203550 int rc = SQLITE_OK;
203564 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff);
203565 fts5HighlightAppend(&rc, p, p->zOpen, -1);
203571 fts5HighlightAppend(&rc, p, p->zOpen, -1);
203573 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);
203574 fts5HighlightAppend(&rc, p, p->zClose, -1);
203576 if( rc==SQLITE_OK ){
203577 rc = fts5CInstIterNext(&p->iter);
203582 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);
203585 fts5HighlightAppend(&rc, p, p->zClose, -1);
203589 return rc;
203603 int rc;
203616 rc = pApi->xColumnText(pFts, iCol, &ctx.zIn, &ctx.nIn);
203619 if( rc==SQLITE_OK ){
203620 rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter);
203623 if( rc==SQLITE_OK ){
203624 rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);
203626 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);
203628 if( rc==SQLITE_OK ){
203633 if( rc!=SQLITE_OK ){
203634 sqlite3_result_error_code(pCtx, rc);
203685 int rc = SQLITE_OK;
203700 rc = fts5SentenceFinderAdd(p, p->iPos);
203703 rc = fts5SentenceFinderAdd(p, 0);
203707 return rc;
203721 int rc;
203732 rc = pApi->xInstCount(pFts, &nInst);
203733 for(i=0; i<nInst && rc==SQLITE_OK; i++){
203734 rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);
203735 if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<iEnd ){
203751 return rc;
203775 int rc = SQLITE_OK; /* Return code */
203808 rc = SQLITE_NOMEM;
203810 if( rc==SQLITE_OK ){
203811 rc = pApi->xInstCount(pFts, &nInst);
203822 rc = pApi->xColumnText(pFts, i, &sFinder.zDoc, &nDoc);
203823 if( rc!=SQLITE_OK ) break;
203824 rc = pApi->xTokenize(pFts,
203827 if( rc!=SQLITE_OK ) break;
203828 rc = pApi->xColumnSize(pFts, i, &nDocsize);
203829 if( rc!=SQLITE_OK ) break;
203831 for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){
203837 rc = pApi->xInst(pFts, ii, &ip, &ic, &io);
203839 if( io>nDocsize ) rc = FTS5_CORRUPT;
203840 if( rc!=SQLITE_OK ) continue;
203842 rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
203845 if( rc==SQLITE_OK && nScore>nBestScore ){
203852 if( rc==SQLITE_OK && sFinder.nFirst && nDocsize>nToken ){
203859 rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
203864 if( rc==SQLITE_OK && nScore>nBestScore ){
203876 if( rc==SQLITE_OK ){
203877 rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn);
203879 if( rc==SQLITE_OK && nColSize==0 ){
203880 rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);
203883 if( rc==SQLITE_OK ){
203884 rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter);
203891 fts5HighlightAppend(&rc, &ctx, zEllips, -1);
203896 while( ctx.iter.iStart>=0 && ctx.iter.iStart<iBestStart && rc==SQLITE_OK ){
203897 rc = fts5CInstIterNext(&ctx.iter);
203900 if( rc==SQLITE_OK ){
203901 rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);
203904 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);
203906 fts5HighlightAppend(&rc, &ctx, zEllips, -1);
203909 if( rc==SQLITE_OK ){
203912 sqlite3_result_error_code(pCtx, rc);
203958 int rc = SQLITE_OK; /* Return code */
203974 rc = SQLITE_NOMEM;
203983 if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow);
203984 assert( rc!=SQLITE_OK || nRow>0 );
203985 if( rc==SQLITE_OK ) rc = pApi->xColumnTotalSize(pFts, -1, &nToken);
203986 if( rc==SQLITE_OK ) p->avgdl = (double)nToken / (double)nRow;
203989 for(i=0; rc==SQLITE_OK && i<nPhrase; i++){
203991 rc = pApi->xQueryPhrase(pFts, i, (void*)&nHit, fts5CountCb);
203992 if( rc==SQLITE_OK ){
204012 if( rc!=SQLITE_OK ){
204015 rc = pApi->xSetAuxdata(pFts, p, sqlite3_free);
204017 if( rc!=SQLITE_OK ) p = 0;
204020 return rc;
204035 int rc = SQLITE_OK; /* Error code */
204045 rc = fts5Bm25GetData(pApi, pFts, &pData);
204046 if( rc==SQLITE_OK ){
204049 rc = pApi->xInstCount(pFts, &nInst);
204051 for(i=0; rc==SQLITE_OK && i<nInst; i++){
204053 rc = pApi->xInst(pFts, i, &ip, &ic, &io);
204054 if( rc==SQLITE_OK ){
204061 if( rc==SQLITE_OK ){
204063 rc = pApi->xColumnSize(pFts, -1, &nTok);
204068 for(i=0; rc==SQLITE_OK && i<pData->nPhrase; i++){
204077 if( rc==SQLITE_OK ){
204080 sqlite3_result_error_code(pCtx, rc);
204095 int rc = SQLITE_OK; /* Return code */
204098 for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){
204099 rc = pApi->xCreateFunction(pApi,
204107 return rc;
204350 int rc = 0; /* Initialized only to suppress erroneous warning from Clang */
204351 if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;
204436 int rc = SQLITE_OK;
204437 *pp = sqlite3Fts5MallocZero(&rc, sizeof(Fts5Termset));
204438 return rc;
204447 int rc = SQLITE_OK;
204475 pEntry = sqlite3Fts5MallocZero(&rc, sizeof(Fts5TermsetEntry) + nTerm);
204487 return rc;
204745 int rc = SQLITE_OK;
204752 pConfig->aPrefix = sqlite3Fts5MallocZero(&rc, nByte);
204753 if( rc ) return rc;
204769 rc = SQLITE_ERROR;
204777 rc = SQLITE_ERROR;
204788 rc = SQLITE_ERROR;
204797 return rc;
204803 char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg);
204804 char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2);
204810 rc = SQLITE_ERROR;
204829 rc = SQLITE_ERROR;
204831 rc = sqlite3Fts5GetTokenizer(pGlobal,
204841 return rc;
204847 rc = SQLITE_ERROR;
204851 pConfig->zContent = sqlite3Fts5Mprintf(&rc, "%Q.%Q", pConfig->zDb,zArg);
204856 return rc;
204862 rc = SQLITE_ERROR;
204864 pConfig->zContentRowid = sqlite3Fts5Strndup(&rc, zArg, -1);
204866 return rc;
204872 rc = SQLITE_ERROR;
204876 return rc;
204887 if( (rc = fts5ConfigSetEnum(aDetail, zArg, &pConfig->eDetail)) ){
204890 return rc;
204970 int rc = SQLITE_OK;
204975 rc = SQLITE_ERROR;
204981 rc = SQLITE_ERROR;
204986 return rc;
204994 int rc = SQLITE_OK;
204997 sqlite3Fts5BufferAppendPrintf(&rc, &buf, "T.%Q", p->zContentRowid);
205001 sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.%Q", p->azCol[i]);
205003 sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.c%d", i);
205010 return rc;
205033 int rc = SQLITE_OK; /* Return code */
205045 pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte);
205047 pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1);
205048 pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1);
205054 if( rc==SQLITE_OK && sqlite3_stricmp(pRet->zName, FTS5_RANK_NAME)==0 ){
205056 rc = SQLITE_ERROR;
205059 for(i=3; rc==SQLITE_OK && i<nArg; i++){
205067 z = fts5ConfigGobbleWord(&rc, zOrig, &zOne, &bMustBeCol);
205077 z = fts5ConfigGobbleWord(&rc, z, &zTwo, &bDummy);
205081 if( rc==SQLITE_OK ){
205084 rc = SQLITE_ERROR;
205087 rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:"", pzErr);
205089 rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);
205102 if( rc==SQLITE_OK && pRet->pTok==0 ){
205103 rc = fts5ConfigDefaultTokenizer(pGlobal, pRet);
205107 if( rc==SQLITE_OK && pRet->zContent==0 ){
205120 &rc, "%Q.'%q_%s'", pRet->zDb, pRet->zName, zTail
205125 if( rc==SQLITE_OK && pRet->zContentRowid==0 ){
205126 pRet->zContentRowid = sqlite3Fts5Strndup(&rc, "rowid", -1);
205130 if( rc==SQLITE_OK ){
205131 rc = fts5ConfigMakeExprlist(pRet);
205134 if( rc!=SQLITE_OK ){
205138 return rc;
205173 int rc = SQLITE_OK;
205176 zSql = sqlite3Fts5Mprintf(&rc, "CREATE TABLE x(");
205179 zSql = sqlite3Fts5Mprintf(&rc, "%z%s%Q", zSql, zSep, pConfig->azCol[i]);
205181 zSql = sqlite3Fts5Mprintf(&rc, "%z, %Q HIDDEN, %s HIDDEN)",
205185 assert( zSql || rc==SQLITE_NOMEM );
205187 rc = sqlite3_declare_vtab(pConfig->db, zSql);
205191 return rc;
205272 int rc = SQLITE_OK;
205278 rc = SQLITE_ERROR;
205285 zRank = sqlite3Fts5MallocZero(&rc, 1 + p - pRank);
205288 rc = SQLITE_ERROR;
205291 if( rc==SQLITE_OK ){
205293 if( *p!='(' ) rc = SQLITE_ERROR;
205296 if( rc==SQLITE_OK ){
205303 rc = SQLITE_ERROR;
205305 zRankArgs = sqlite3Fts5MallocZero(&rc, 1 + p - pArgs);
205312 if( rc!=SQLITE_OK ){
205319 return rc;
205328 int rc = SQLITE_OK;
205396 rc = sqlite3Fts5ConfigParseRank(zIn, &zRank, &zRankArgs);
205397 if( rc==SQLITE_OK ){
205402 }else if( rc==SQLITE_ERROR ){
205403 rc = SQLITE_OK;
205409 return rc;
205419 int rc = SQLITE_OK;
205429 zSql = sqlite3Fts5Mprintf(&rc, zSelect, pConfig->zDb, pConfig->zName);
205431 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p, 0);
205435 assert( rc==SQLITE_OK || p==0 );
205436 if( rc==SQLITE_OK ){
205447 rc = sqlite3_finalize(p);
205450 if( rc==SQLITE_OK && iVersion!=FTS5_CURRENT_VERSION ){
205451 rc = SQLITE_ERROR;
205461 if( rc==SQLITE_OK ){
205464 return rc;
205593 int rc;
205602 if( pParse->rc==SQLITE_OK ){
205604 pParse->rc = SQLITE_ERROR;
205707 }while( sParse.rc==SQLITE_OK && t!=FTS5_EOF );
205712 if( iCol<pConfig->nCol && sParse.pExpr && sParse.rc==SQLITE_OK ){
205714 Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&sParse.rc, n);
205722 assert( sParse.rc!=SQLITE_OK || sParse.zErr==0 );
205723 if( sParse.rc==SQLITE_OK ){
205726 sParse.rc = SQLITE_NOMEM;
205731 pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&sParse.rc, nByte);
205750 return sParse.rc;
205816 int rc = SQLITE_OK;
205828 rc = SQLITE_NOMEM;
205862 if( iMin==FTS5_LARGEST_INT64 || rc!=SQLITE_OK ) break;
205863 rc = sqlite3Fts5PoslistWriterAppend(pBuf, &writer, iMin);
205866 if( rc==SQLITE_OK ){
205874 return rc;
205898 int rc = SQLITE_OK;
205920 rc = fts5ExprSynonymList(pTerm, pNode->iRowid, &buf, &a, &n);
205921 if( rc ){
205955 rc = sqlite3Fts5PoslistWriterAppend(&pPhrase->poslist, &writer, iPos);
205956 if( rc!=SQLITE_OK ) goto ismatch_out;
205970 return rc;
206033 int rc = *pRc;
206042 a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte);
206046 if( rc!=SQLITE_OK ){
206047 *pRc = rc;
206111 *pRc = rc;
206138 int rc = sqlite3Fts5IterNextFrom(pIter, iLast);
206139 if( rc || sqlite3Fts5IterEof(pIter) ){
206140 *pRc = rc;
206158 int rc = SQLITE_OK;
206163 for(p=pTerm; rc==SQLITE_OK && p; p=p->pSynonym){
206167 rc = sqlite3Fts5IterNextFrom(p->pIter, iLast);
206172 if( rc!=SQLITE_OK ){
206173 *pRc = rc;
206188 int rc = *pRc;
206209 for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){
206215 rc = fts5ExprPhraseIsMatch(pNode, pPhrase, &bMatch);
206219 fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);
206223 *pRc = rc;
206262 int rc;
206267 rc = sqlite3Fts5IndexQuery(
206274 assert( (rc==SQLITE_OK)==(p->pIter!=0) );
206275 if( rc!=SQLITE_OK ) return rc;
206384 int rc = SQLITE_OK;
206417 if( fts5ExprSynonymAdvanceto(pTerm, bDesc, &iLast, &rc) ){
206420 return rc;
206426 if( fts5ExprAdvanceto(pIter, bDesc, &iLast, &rc, &pNode->bEof) ){
206427 return rc;
206435 pNode->bNomatch = ((0==fts5ExprNearTest(&rc, pExpr, pNode)) && rc==SQLITE_OK);
206438 return rc;
206455 int rc = SQLITE_OK;
206474 rc = sqlite3Fts5IterNextFrom(p->pIter, iFrom);
206476 rc = sqlite3Fts5IterNext(p->pIter);
206478 if( rc!=SQLITE_OK ) break;
206490 pNode->bEof = (rc || bEof);
206496 rc = sqlite3Fts5IterNextFrom(pIter, iFrom);
206498 rc = sqlite3Fts5IterNext(pIter);
206501 pNode->bEof = (rc || sqlite3Fts5IterEof(pIter));
206505 assert( rc==SQLITE_OK );
206506 rc = fts5ExprNodeTest_STRING(pExpr, pNode);
206509 return rc;
206547 int rc;
206552 rc = sqlite3Fts5IterNextFrom(pIter, iFrom);
206554 rc = sqlite3Fts5IterNext(pIter);
206556 if( rc==SQLITE_OK && sqlite3Fts5IterEof(pIter)==0 ){
206557 rc = fts5ExprNodeTest_TERM(pExpr, pNode);
206562 return rc;
206600 int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);
206601 if( rc!=SQLITE_OK ){
206603 return rc;
206622 int rc = SQLITE_OK;
206634 rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);
206635 if( rc!=SQLITE_OK ){
206637 return rc;
206674 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
206675 if( rc==SQLITE_OK ){
206676 rc = fts5ExprNodeTest_AND(pExpr, pNode);
206680 return rc;
206687 int rc = SQLITE_OK;
206692 while( rc==SQLITE_OK && p1->bEof==0 ){
206695 rc = fts5ExprNodeNext(pExpr, p2, 1, p1->iRowid);
206698 assert( rc!=SQLITE_OK || cmp<=0 );
206700 rc = fts5ExprNodeNext(pExpr, p1, 0, 0);
206708 return rc;
206717 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
206718 if( rc==SQLITE_OK ){
206719 rc = fts5ExprNodeTest_NOT(pExpr, pNode);
206721 if( rc!=SQLITE_OK ){
206724 return rc;
206736 int rc = SQLITE_OK;
206741 rc = fts5ExprNodeTest_STRING(pExpr, pNode);
206746 rc = fts5ExprNodeTest_TERM(pExpr, pNode);
206751 rc = fts5ExprNodeTest_AND(pExpr, pNode);
206761 rc = fts5ExprNodeTest_NOT(pExpr, pNode);
206766 return rc;
206778 int rc = SQLITE_OK;
206784 rc = fts5ExprNearInitAll(pExpr, pNode);
206790 for(i=0; i<pNode->nChild && rc==SQLITE_OK; i++){
206792 rc = fts5ExprNodeFirst(pExpr, pNode->apChild[i]);
206814 if( rc==SQLITE_OK ){
206815 rc = fts5ExprNodeTest(pExpr, pNode);
206817 return rc;
206838 int rc; /* Return code */
206842 rc = fts5ExprNodeFirst(p, pRoot);
206846 if( rc==SQLITE_OK
206850 rc = fts5ExprNodeNext(p, pRoot, 1, iFirst);
206855 assert( pRoot->bEof==0 && rc==SQLITE_OK );
206856 rc = fts5ExprNodeNext(p, pRoot, 0, 0);
206858 return rc;
206868 int rc;
206872 rc = fts5ExprNodeNext(p, pRoot, 0, 0);
206873 assert( pRoot->bNomatch==0 || (rc==SQLITE_OK && pRoot->bEof==0) );
206878 return rc;
206890 int rc = SQLITE_OK;
206891 *pz = sqlite3Fts5Strndup(&rc, pToken->p, pToken->n);
206892 return rc;
206945 if( pParse->rc==SQLITE_OK ){
206954 pParse->rc = SQLITE_NOMEM;
206965 pParse->rc = SQLITE_NOMEM;
206973 assert( pParse->rc!=SQLITE_OK );
207000 int rc;
207014 int rc = SQLITE_OK;
207022 if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;
207030 rc = SQLITE_NOMEM;
207048 rc = SQLITE_NOMEM;
207056 if( rc==SQLITE_OK ){
207059 pTerm->zTerm = sqlite3Fts5Strndup(&rc, pToken, nToken);
207063 pCtx->rc = rc;
207064 return rc;
207107 int rc; /* Tokenize return code */
207113 rc = fts5ParseStringFromToken(pToken, &z);
207114 if( rc==SQLITE_OK ){
207119 rc = sqlite3Fts5Tokenize(pConfig, flags, z, n, &sCtx, fts5ParseTokenize);
207122 if( rc || (rc = sCtx.rc) ){
207123 pParse->rc = rc;
207134 pParse->rc = SQLITE_NOMEM;
207146 sCtx.pPhrase = sqlite3Fts5MallocZero(&pParse->rc, sizeof(Fts5ExprPhrase));
207165 int rc = SQLITE_OK; /* Return code */
207171 pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr));
207172 if( rc==SQLITE_OK ){
207173 pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc,
207176 if( rc==SQLITE_OK ){
207177 pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&rc,
207180 if( rc==SQLITE_OK ){
207181 pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc,
207184 if( rc==SQLITE_OK ){
207190 pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
207200 for(i=0; rc==SQLITE_OK && i<pOrig->nTerm; i++){
207203 for(p=&pOrig->aTerm[i]; p && rc==SQLITE_OK; p=p->pSynonym){
207205 rc = fts5ParseTokenize((void*)&sCtx, tflags, zTerm, (int)strlen(zTerm),
207209 if( rc==SQLITE_OK ){
207217 sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));
207220 if( rc==SQLITE_OK ){
207247 return rc;
207307 assert( pParse->rc==SQLITE_OK );
207312 pParse->rc = SQLITE_NOMEM;
207344 pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc,
207372 z = sqlite3Fts5Strndup(&pParse->rc, p->p, p->n);
207373 if( pParse->rc==SQLITE_OK ){
207388 assert( pParse->rc!=SQLITE_OK );
207452 if( pParse->rc==SQLITE_OK ){
207469 pNear->pColset = fts5CloneColset(&pParse->rc, pColset);
207491 pParse->rc = SQLITE_ERROR;
207558 if( pParse->rc==SQLITE_OK ){
207578 pRet = (Fts5ExprNode*)sqlite3Fts5MallocZero(&pParse->rc, nByte);
207600 assert( pParse->rc==SQLITE_OK );
207601 pParse->rc = SQLITE_ERROR;
207619 assert( pParse->rc!=SQLITE_OK );
207635 if( pParse->rc ){
207916 int rc;
207954 rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr);
207955 if( rc==SQLITE_OK ){
207956 rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr);
207958 if( rc==SQLITE_OK ){
207968 rc = SQLITE_NOMEM;
207975 if( rc!=SQLITE_OK ){
207980 sqlite3_result_error_code(pCtx, rc);
208062 int rc = SQLITE_OK;
208065 for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){
208067 rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
208077 return rc;
208183 int rc = sqlite3Fts5PoslistWriterAppend(
208186 if( rc ) return rc;
208294 int rc = SQLITE_OK;
208306 rc = fts5ExprSynonymList(
208318 return rc;
208406 int rc = SQLITE_OK;
208411 rc = SQLITE_NOMEM;
208424 rc = SQLITE_NOMEM;
208429 return rc;
208598 int rc = fts5HashResize(pHash);
208599 if( rc!=SQLITE_OK ) return rc;
209178 int rc; /* Current error code */
209457 return sqlite3Fts5MallocZero(&p->rc, nByte);
209519 if( p->rc==SQLITE_OK ){
209520 int rc = SQLITE_OK;
209528 rc = sqlite3_blob_reopen(pBlob, iRowid);
209531 if( rc!=SQLITE_OK ){
209534 if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
209539 if( p->pReader==0 && rc==SQLITE_OK ){
209541 rc = sqlite3_blob_open(pConfig->db,
209551 if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT;
209553 if( rc==SQLITE_OK ){
209562 rc = SQLITE_NOMEM;
209565 if( rc==SQLITE_OK ){
209566 rc = sqlite3_blob_read(p->pReader, aOut, nByte, 0);
209568 if( rc!=SQLITE_OK ){
209577 p->rc = rc;
209581 assert( (pRet==0)==(p->rc!=SQLITE_OK) );
209597 p->rc = FTS5_CORRUPT;
209610 if( p->rc==SQLITE_OK ){
209612 p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
209616 p->rc = SQLITE_NOMEM;
209620 return p->rc;
209628 if( p->rc!=SQLITE_OK ) return;
209636 if( p->rc ) return;
209642 p->rc = sqlite3_reset(p->pWriter);
209652 if( p->rc!=SQLITE_OK ) return;
209666 p->rc = sqlite3_reset(p->pDeleter);
209683 if( p->rc==SQLITE_OK ){
209686 p->rc = sqlite3_reset(p->pIdxDeleter);
209727 int rc = SQLITE_OK;
209752 pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);
209760 for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){
209766 rc = FTS5_CORRUPT;
209770 if( nTotal<pLvl->nMerge ) rc = FTS5_CORRUPT;
209771 pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc,
209777 if( rc==SQLITE_OK ){
209782 rc = FTS5_CORRUPT;
209789 rc = FTS5_CORRUPT;
209793 if( iLvl>0 && pLvl[-1].nMerge && nTotal==0 ) rc = FTS5_CORRUPT;
209794 if( iLvl==nLevel-1 && pLvl->nMerge ) rc = FTS5_CORRUPT;
209797 if( nSegment!=0 && rc==SQLITE_OK ) rc = FTS5_CORRUPT;
209799 if( rc!=SQLITE_OK ){
209806 return rc;
209872 if( p->rc==SQLITE_OK ){
209875 p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);
209876 if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){
209877 p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);
209880 if( p->rc!=SQLITE_OK ){
209892 if( p->rc==SQLITE_OK ){
209894 p->rc = fts5IndexPrepareStmt(p, &p->pDataVersion,
209897 if( p->rc ) return 0;
209903 p->rc = sqlite3_reset(p->pDataVersion);
209924 if( p->rc==SQLITE_OK ){
209952 if( p->rc!=SQLITE_OK ) return 0;
210003 if( p->rc==SQLITE_OK ){
210015 if( 0==sqlite3Fts5BufferSize(&p->rc, &buf, 4+9+9+9) ){
210026 fts5BufferAppendVarint(&p->rc, &buf, pLvl->nMerge);
210027 fts5BufferAppendVarint(&p->rc, &buf, pLvl->nSeg);
210031 fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].iSegid);
210032 fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoFirst);
210033 fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoLast);
210045 int rc = SQLITE_OK;
210048 fts5DebugStructure(&rc, &buf, pStruct);
210082 fts5StructureExtendLevel(&p->rc, pStruct, iPromote, 1, 1);
210083 if( p->rc ) return;
210114 if( p->rc==SQLITE_OK ){
210237 return p->rc!=SQLITE_OK || pIter->aLvl[0].bEof;
210244 for(i=pIter->nLvl-1; p->rc==SQLITE_OK && i>=0; i--){
210362 for(i=0; p->rc==SQLITE_OK && bDone==0; i++){
210368 p->rc = SQLITE_NOMEM;
210382 if( p->rc==SQLITE_OK ){
210391 if( p->rc!=SQLITE_OK ){
210469 if( p->rc==SQLITE_OK ){
210505 if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;
210537 p->rc = FTS5_CORRUPT;
210541 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
210596 if( p->rc==SQLITE_OK ){
210604 if( p->rc==SQLITE_OK ){
210665 p->rc = SQLITE_NOMEM;
210688 while( p->rc==SQLITE_OK && pIter->iLeafPgno>pIter->iTermLeafPgno ){
210736 return (p->rc==SQLITE_OK && pSeg->pLeaf && pSeg->nPos==0);
210785 assert( p->rc==SQLITE_OK );
210795 if( p->rc || pIter->pLeaf==0 ) return;
210825 sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm);
210905 sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm),
210938 p->rc = FTS5_CORRUPT;
210964 assert( p->rc==SQLITE_OK );
211019 for(pgno=pIter->iLeafPgno+1; !p->rc && pgno<=pSeg->pgnoLast; pgno++){
211124 assert( p->rc==SQLITE_OK );
211130 p->rc = FTS5_CORRUPT;
211173 p->rc = FTS5_CORRUPT;
211195 p->rc = FTS5_CORRUPT;
211211 p->rc = FTS5_CORRUPT;
211217 fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);
211218 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
211272 if( p->rc ) return;
211280 p->rc = sqlite3_reset(pIdxSelect);
211295 if( p->rc==SQLITE_OK && bGe==0 ){
211320 assert_nc( p->rc!=SQLITE_OK /* 1 */
211347 assert( p->rc==SQLITE_OK );
211352 p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm);
211362 p->rc = sqlite3Fts5HashQuery(p->pHash, sizeof(Fts5Data),
211374 sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);
211454 if( p->rc==SQLITE_OK ){
211560 p->rc = FTS5_CORRUPT;
211566 assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );
211568 if( p->rc==SQLITE_OK ){
211575 p->rc = FTS5_CORRUPT;
211609 assert_nc( iLeafPgno>=pIter->iLeafPgno || p->rc );
211632 if( bMove && p->rc==SQLITE_OK ) pIter->xNext(p, pIter, 0);
211637 }while( p->rc==SQLITE_OK );
211662 for(i=(pIter->nSeg+iChanged)/2; i>=iMinset && p->rc==SQLITE_OK; i=i/2){
211666 assert( p->rc==SQLITE_OK );
211747 while( p->rc==SQLITE_OK ){
211751 assert( p->rc==SQLITE_OK );
211783 if( p->rc==SQLITE_OK ){
211790 assert( p->rc==SQLITE_OK );
211997 if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){
212204 int *pRc = &pIter->pIndex->rc;
212283 if( p->rc==SQLITE_OK ){
212298 fts5IterSetOutputCb(&p->rc, pNew);
212302 if( p->rc==SQLITE_OK ){
212334 if( p->rc==SQLITE_OK ){
212339 if( p->rc==SQLITE_OK ) pSeg->xNext(p, pSeg, 0);
212404 assert( p->rc
212407 return (p->rc || pIter->base.bEof);
212460 if( p->rc==SQLITE_OK ){
212462 p->rc = SQLITE_FULL;
212495 if( p->rc==SQLITE_OK ){
212500 p->rc = sqlite3_reset(pIdxSelect);
212568 if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){
212573 p->rc = SQLITE_NOMEM;
212581 return p->rc;
212620 if( p->rc==SQLITE_OK ){
212627 p->rc = sqlite3_reset(p->pIdxWriter);
212648 if( p->rc==SQLITE_OK ){
212649 fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
212667 sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, 0);
212696 for(i=0; p->rc==SQLITE_OK && bDone==0; i++){
212713 if( p->rc==SQLITE_OK && pDlidx[1].buf.n==0 ){
212718 sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, 0);
212719 sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, pDlidx->pgno);
212720 sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, iFirst);
212737 sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, !bDone);
212738 sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iPgno);
212742 sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iVal);
212765 fts5BufferAppendBlob(&p->rc, &pPage->buf, pPage->pgidx.n, pPage->pgidx.p);
212775 fts5BufferAppendBlob(&p->rc, &pPage->buf, 4, zero);
212804 assert( p->rc==SQLITE_OK );
212812 if( p->rc!=SQLITE_OK ) return;
212814 fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);
212848 if( p->rc!=SQLITE_OK ) return;
212853 fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
212858 fts5BufferAppendVarint(&p->rc, &pPage->buf, nTerm - nPrefix);
212859 fts5BufferAppendBlob(&p->rc, &pPage->buf, nTerm - nPrefix, &pTerm[nPrefix]);
212862 fts5BufferSet(&p->rc, &pPage->term, nTerm, pTerm);
212868 assert( p->rc || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n==0) );
212880 if( p->rc==SQLITE_OK ){
212897 fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);
212899 assert_nc( p->rc || iRowid>pWriter->iPrevRowid );
212900 fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
212919 while( p->rc==SQLITE_OK
212928 fts5BufferAppendBlob(&p->rc, &pPage->buf, nCopy, a);
212934 fts5BufferAppendBlob(&p->rc, &pPage->buf, n, a);
212949 if( p->rc==SQLITE_OK ){
212989 sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.pgidx, nBuffer);
212990 sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.buf, nBuffer);
213000 if( p->rc==SQLITE_OK ){
213021 for(i=0; i<pIter->nSeg && p->rc==SQLITE_OK; i++){
213046 p->rc = FTS5_CORRUPT;
213049 fts5BufferGrow(&p->rc, &buf, pData->nn);
213050 fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);
213051 fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
213052 fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
213053 fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff,&pData->p[iOff]);
213054 if( p->rc==SQLITE_OK ){
213060 fts5BufferAppendVarint(&p->rc, &buf, 4);
213066 fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);
213067 fts5BufferAppendBlob(&p->rc, &buf,
213135 fts5StructureAddLevel(&p->rc, ppStruct);
213138 fts5StructureExtendLevel(&p->rc, pStruct, iLvl+1, 1, 0);
213139 if( p->rc ) return;
213172 fts5BufferSet(&p->rc, &term, nTerm, pTerm);
213179 if( p->rc==SQLITE_OK && bTermWritten==0 ){
213191 fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);
213193 fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);
213199 fts5BufferAppendVarint(&p->rc, &writer.writer.buf, nPos);
213253 while( nRem>0 && p->rc==SQLITE_OK ){
213287 if( p->rc==SQLITE_OK && pStruct->aLevel[iBestLvl].nMerge==0 ){
213308 if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){
213332 assert( p->rc!=SQLITE_OK || pStruct->nLevel>0 );
213333 while( p->rc==SQLITE_OK && pStruct->aLevel[iLvl].nSeg>=nCrisis ){
213335 assert( p->rc!=SQLITE_OK || pStruct->nLevel>(iLvl+1) );
213343 int rc = p->rc;
213344 p->rc = SQLITE_OK;
213345 return rc;
213407 assert( p->rc || pBuf->nSpace>=(pgsz + FTS5_DATA_PADDING) );
213408 assert( p->rc || pPgidx->nSpace>=(pgsz + FTS5_DATA_PADDING) );
213412 if( p->rc==SQLITE_OK ){
213413 p->rc = sqlite3Fts5HashScanInit(pHash, 0, 0);
213415 while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){
213423 if( p->rc!=SQLITE_OK ) break;
213437 while( p->rc==SQLITE_OK && iOff<nDoclist ){
213446 if( p->rc!=SQLITE_OK ) break;
213479 while( p->rc==SQLITE_OK ){
213504 if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash);
213512 fts5StructureAddLevel(&p->rc, &pStruct);
213514 fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0);
213515 if( p->rc==SQLITE_OK ){
213573 pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
213582 pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);
213609 assert( p->rc==SQLITE_OK );
213623 while( p->rc==SQLITE_OK && pNew->aLevel[iLvl].nSeg>0 ){
213668 fts5BufferAppendVarint(&p->rc, pBuf, iDelta);
213680 if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nByte) ){
213786 sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n);
213787 if( p->rc ) return;
213838 if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n + 9) ) return;
213874 sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist);
213875 if( p->rc ) break;
213942 fts5BufferSet(&p->rc, p1, out.n, out.p);
213986 fts5IterSetOutputCb(&p->rc, p1);
214004 for(i=0; p->rc==SQLITE_OK && doclist.n; i++){
214022 if( p->rc==SQLITE_OK ){
214049 assert( p->rc==SQLITE_OK );
214053 p->rc = sqlite3Fts5HashNew(p->pConfig, &p->pHash, &p->nPendingData);
214073 assert( p->rc==SQLITE_OK );
214120 int rc = SQLITE_OK;
214123 *pp = p = (Fts5Index*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Index));
214124 if( rc==SQLITE_OK ){
214127 p->zDataTbl = sqlite3Fts5Mprintf(&rc, "%s_data", pConfig->zName);
214129 rc = sqlite3Fts5CreateTable(
214132 if( rc==SQLITE_OK ){
214133 rc = sqlite3Fts5CreateTable(pConfig, "idx",
214138 if( rc==SQLITE_OK ){
214139 rc = sqlite3Fts5IndexReinit(p);
214144 assert( rc!=SQLITE_OK || p->rc==SQLITE_OK );
214145 if( rc ){
214149 return rc;
214156 int rc = SQLITE_OK;
214170 return rc;
214230 int rc = SQLITE_OK; /* Return code */
214233 assert( p->rc==SQLITE_OK );
214237 rc = sqlite3Fts5HashWrite(
214241 for(i=0; i<pConfig->nPrefix && rc==SQLITE_OK; i++){
214245 rc = sqlite3Fts5HashWrite(p->pHash,
214252 return rc;
214273 if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
214315 assert( p->rc!=SQLITE_OK || pRet->pColset==0 );
214316 fts5IterSetOutputCb(&p->rc, pRet);
214317 if( p->rc==SQLITE_OK ){
214323 if( p->rc ){
214343 assert( pIter->pIndex->rc==SQLITE_OK );
214355 assert( pIter->pIndex->rc==SQLITE_OK );
214358 if( p->rc==SQLITE_OK ){
214416 if( p->rc==SQLITE_OK && pData->nn ){
214434 assert( p->rc==SQLITE_OK );
214455 int rc; /* Return code */
214460 assert( p->rc==SQLITE_OK );
214463 rc = sqlite3_blob_open(pConfig->db, pConfig->zDb, p->zDataTbl,
214466 if( rc==SQLITE_OK ){
214468 rc = sqlite3_blob_close(pBlob);
214471 return rc;
214550 if( p->rc==SQLITE_OK && cksum1!=cksum2 ) p->rc = FTS5_CORRUPT;
214564 int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);
214566 while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){
214582 if( rc==SQLITE_OK ){
214583 rc = sqlite3Fts5IterNext(pIter);
214589 return rc;
214604 int rc = p->rc;
214606 fts5BufferSet(&rc, pPrev, n, (const u8*)z);
214608 if( rc==SQLITE_OK && (pPrev->n!=n || memcmp(pPrev->p, z, n)) ){
214619 rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, flags, &ck1);
214620 if( rc==SQLITE_OK ){
214622 rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);
214624 if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;
214634 if( iIdx>0 && rc==SQLITE_OK ){
214637 rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);
214638 if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;
214640 if( iIdx>0 && rc==SQLITE_OK ){
214643 rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);
214644 if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;
214649 fts5BufferSet(&rc, pPrev, n, (const u8*)z);
214651 if( rc==SQLITE_OK && cksum3!=expected ){
214652 rc = FTS5_CORRUPT;
214656 p->rc = rc;
214683 for(i=iFirst; p->rc==SQLITE_OK && i<=iLast; i++){
214686 if( !fts5LeafIsTermless(pLeaf) ) p->rc = FTS5_CORRUPT;
214687 if( i>=iNoRowid && 0!=fts5LeafFirstRowidOff(pLeaf) ) p->rc = FTS5_CORRUPT;
214701 while( ii<pLeaf->nn && p->rc==SQLITE_OK ){
214711 p->rc = FTS5_CORRUPT;
214716 p->rc = FTS5_CORRUPT;
214718 fts5BufferSet(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);
214725 p->rc = FTS5_CORRUPT;
214728 fts5BufferAppendBlob(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);
214731 if( p->rc==SQLITE_OK ){
214733 if( res<=0 ) p->rc = FTS5_CORRUPT;
214736 fts5BufferSet(&p->rc, &buf2, buf1.n, buf1.p);
214761 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
214782 p->rc = FTS5_CORRUPT;
214792 p->rc = FTS5_CORRUPT;
214797 if( res<0 ) p->rc = FTS5_CORRUPT;
214803 if( p->rc ) break;
214810 if( p->rc ) break;
214830 if( fts5LeafFirstRowidOff(pLeaf)!=0 ) p->rc = FTS5_CORRUPT;
214845 p->rc = FTS5_CORRUPT;
214848 if( iRowid!=fts5DlidxIterRowid(pDlidx) ) p->rc = FTS5_CORRUPT;
214866 if( p->rc==SQLITE_OK ) p->rc = rc2;
214870 if( p->rc==SQLITE_OK && iter.iLeaf!=pSeg->pgnoLast ){
214871 p->rc = FTS5_CORRUPT;
214958 if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
215049 int rc; /* Return code */
215052 rc = fts5StructureDecode(pBlob, nBlob, 0, &p);
215053 if( rc!=SQLITE_OK ){
215054 *pRc = rc;
215189 int rc = SQLITE_OK; /* Return code */
215204 a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
215210 fts5DebugRowid(&rc, &s, iRowid);
215223 sqlite3Fts5BufferAppendPrintf(&rc, &s,
215229 fts5DecodeAverages(&rc, &s, a, n);
215231 fts5DecodeStructure(&rc, &s, a, n);
215249 fts5DecodeRowidList(&rc, &s, &a[4], iTermOff-4);
215258 fts5BufferAppendBlob(&rc, &term, nAppend, &a[iOff]);
215260 &rc, &s, " term=%.*s", term.n, (const char*)term.p
215273 fts5DecodeRowidList(&rc, &s, &a[iOff], iTermOff-iOff);
215294 sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)"corrupt");
215302 rc = FTS5_CORRUPT;
215316 rc = FTS5_CORRUPT;
215319 fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
215325 rc = FTS5_CORRUPT;
215328 fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
215330 while( iPgidxOff<n && rc==SQLITE_OK ){
215346 rc = FTS5_CORRUPT;
215353 rc = FTS5_CORRUPT;
215360 rc = FTS5_CORRUPT;
215363 fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);
215367 &rc, &s, " term=%.*s", term.n, (const char*)term.p
215369 iOff += fts5DecodeDoclist(&rc, &s, &a[iOff], iEnd-iOff);
215377 if( rc==SQLITE_OK ){
215380 sqlite3_result_error_code(pCtx, rc);
215428 int rc = sqlite3_create_function(
215432 if( rc==SQLITE_OK ){
215433 rc = sqlite3_create_function(
215439 if( rc==SQLITE_OK ){
215440 rc = sqlite3_create_function(
215444 return rc;
215788 int rc = sqlite3Fts5DropAll(pTab->pConfig);
215789 if( rc==SQLITE_OK ){
215792 return rc;
215817 int rc = SQLITE_OK; /* Return code */
215822 pTab = (Fts5FullTable*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5FullTable));
215823 if( rc==SQLITE_OK ){
215824 rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr);
215825 assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 );
215827 if( rc==SQLITE_OK ){
215833 if( rc==SQLITE_OK ){
215834 rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->p.pIndex, pzErr);
215838 if( rc==SQLITE_OK ){
215839 rc = sqlite3Fts5StorageOpen(
215845 if( rc==SQLITE_OK ){
215846 rc = sqlite3Fts5ConfigDeclareVtab(pConfig);
215850 if( rc==SQLITE_OK ){
215853 rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
215858 if( rc!=SQLITE_OK ){
215865 return rc;
216083 int rc; /* Return code */
216085 rc = fts5NewTransaction(pTab);
216086 if( rc==SQLITE_OK ){
216097 rc = SQLITE_NOMEM;
216101 return rc;
216186 int rc;
216188 rc = sqlite3_step(pSorter->pStmt);
216189 if( rc==SQLITE_DONE ){
216190 rc = SQLITE_OK;
216192 }else if( rc==SQLITE_ROW ){
216198 rc = SQLITE_OK;
216219 return rc;
216251 int rc = SQLITE_OK;
216258 rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->p.pIndex, iRowid, bDesc);
216259 if( rc==SQLITE_OK && iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){
216270 return rc;
216284 int rc;
216293 if( (rc = fts5CursorReseek(pCsr, &bSkip)) || bSkip ) return rc;
216294 rc = sqlite3Fts5ExprNext(pCsr->pExpr, pCsr->iLastRowid);
216301 rc = SQLITE_OK;
216306 rc = fts5SorterNext(pCsr);
216311 rc = sqlite3_step(pCsr->pStmt);
216312 if( rc!=SQLITE_ROW ){
216314 rc = sqlite3_reset(pCsr->pStmt);
216316 rc = SQLITE_OK;
216322 return rc;
216333 int rc;
216340 rc = SQLITE_NOMEM;
216342 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
216344 if( rc!=SQLITE_OK ){
216352 return rc;
216364 int rc;
216382 rc = fts5PrepareStatement(&pSorter->pStmt, pConfig,
216391 if( rc==SQLITE_OK ){
216394 rc = fts5SorterNext(pCsr);
216398 if( rc!=SQLITE_OK ){
216404 return rc;
216408 int rc;
216410 rc = sqlite3Fts5ExprFirst(pExpr, pTab->p.pIndex, pCsr->iFirstRowid, bDesc);
216415 return rc;
216429 int rc = SQLITE_OK; /* Return code */
216448 rc = SQLITE_ERROR;
216451 return rc;
216474 int rc = SQLITE_OK;
216480 char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
216483 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
216486 assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
216487 if( rc==SQLITE_OK ){
216492 pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);
216493 if( rc==SQLITE_OK ){
216501 rc = sqlite3_finalize(pStmt);
216502 assert( rc!=SQLITE_OK );
216508 if( rc==SQLITE_OK ){
216513 rc = SQLITE_ERROR;
216518 return rc;
216527 int rc = SQLITE_OK;
216534 if( sqlite3_value_type(pRank)==SQLITE_NULL ) rc = SQLITE_ERROR;
216536 rc = sqlite3Fts5ConfigParseRank(z, &zRank, &zRankArgs);
216538 if( rc==SQLITE_OK ){
216542 }else if( rc==SQLITE_ERROR ){
216556 return rc;
216590 int rc = SQLITE_OK; /* Error code */
216671 rc = fts5CursorFirst(pTab, pCsr, bDesc);
216676 rc = fts5CursorParseRank(pConfig, pCsr, pRank);
216677 if( rc==SQLITE_OK ){
216682 rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]);
216685 rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr);
216686 if( rc==SQLITE_OK ){
216689 rc = fts5CursorFirstSorted(pTab, pCsr, bDesc);
216692 rc = fts5CursorFirst(pTab, pCsr, bDesc);
216701 rc = SQLITE_ERROR;
216706 rc = sqlite3Fts5StorageStmt(
216709 if( rc==SQLITE_OK ){
216716 rc = fts5NextMethod(pCursor);
216721 return rc;
216786 int rc = SQLITE_OK;
216792 rc = sqlite3Fts5StorageStmt(
216795 assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );
216799 if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){
216803 rc = sqlite3_step(pCsr->pStmt);
216804 if( rc==SQLITE_ROW ){
216805 rc = SQLITE_OK;
216808 rc = sqlite3_reset(pCsr->pStmt);
216809 if( rc==SQLITE_OK ){
216810 rc = FTS5_CORRUPT;
216814 return rc;
216846 int rc = SQLITE_OK;
216855 rc = SQLITE_ERROR;
216857 rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);
216864 rc = SQLITE_ERROR;
216866 rc = sqlite3Fts5StorageRebuild(pTab->pStorage);
216869 rc = sqlite3Fts5StorageOptimize(pTab->pStorage);
216872 rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge);
216874 rc = sqlite3Fts5StorageIntegrity(pTab->pStorage);
216880 rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
216881 if( rc==SQLITE_OK ){
216882 rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError);
216884 if( rc==SQLITE_OK ){
216886 rc = SQLITE_ERROR;
216888 rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0);
216892 return rc;
216899 int rc = SQLITE_OK;
216903 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2]);
216905 return rc;
216914 int rc = *pRc;
216915 if( rc==SQLITE_OK ){
216916 rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid);
216918 if( rc==SQLITE_OK ){
216919 rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid);
216921 *pRc = rc;
216947 int rc = SQLITE_OK; /* Return code */
216972 rc = fts5SpecialDelete(pTab, apVal);
216974 rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
217003 rc = SQLITE_ERROR;
217009 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);
217017 rc = SQLITE_MISMATCH;
217024 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
217026 fts5StorageInsert(&rc, pTab, apVal, pRowid);
217035 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
217036 if( rc==SQLITE_OK ){
217037 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
217039 fts5StorageInsert(&rc, pTab, apVal, pRowid);
217041 rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
217042 if( rc==SQLITE_OK ){
217043 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
217045 if( rc==SQLITE_OK ){
217046 rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);
217050 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
217051 fts5StorageInsert(&rc, pTab, apVal, pRowid);
217058 return rc;
217065 int rc;
217070 rc = sqlite3Fts5StorageSync(pTab->pStorage);
217072 return rc;
217100 int rc;
217103 rc = sqlite3Fts5StorageRollback(pTab->pStorage);
217104 return rc;
217164 int rc = SQLITE_OK;
217172 rc = fts5SeekCursor(pCsr, 0);
217173 if( rc==SQLITE_OK ){
217178 return rc;
217188 int rc = SQLITE_OK;
217197 if( aPopulator==0 ) rc = SQLITE_NOMEM;
217198 for(i=0; i<pConfig->nCol && rc==SQLITE_OK; i++){
217200 rc = fts5ApiColumnText((Fts5Context*)pCsr, i, &z, &n);
217201 if( rc==SQLITE_OK ){
217202 rc = sqlite3Fts5ExprPopulatePoslists(
217225 return rc;
217234 int rc = SQLITE_OK;
217242 pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);
217251 for(i=0; i<nIter && rc==SQLITE_OK; i++){
217254 rc = fts5CsrPoslist(pCsr, i, &a, &n);
217255 if( rc==SQLITE_OK ){
217260 if( rc==SQLITE_OK ){
217282 rc = SQLITE_NOMEM;
217292 rc = FTS5_CORRUPT;
217302 return rc;
217307 int rc = SQLITE_OK;
217309 || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) ){
217312 return rc;
217323 int rc = SQLITE_OK;
217325 || SQLITE_OK==(rc = fts5CacheInstArray(pCsr))
217328 rc = SQLITE_RANGE;
217341 return rc;
217369 int rc = SQLITE_OK;
217374 rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);
217384 for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
217389 rc = fts5ApiColumnText(pCtx, i, &z, &n);
217390 if( rc==SQLITE_OK ){
217391 rc = sqlite3Fts5Tokenize(
217410 rc = SQLITE_RANGE;
217412 return rc;
217437 int rc = SQLITE_OK;
217438 pData = (Fts5Auxdata*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Auxdata));
217441 return rc;
217503 int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);
217504 if( rc==SQLITE_OK ){
217510 return rc;
217549 int rc = SQLITE_OK;
217561 rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n);
217563 if( rc==SQLITE_OK ){
217570 rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);
217571 if( rc==SQLITE_OK ){
217583 return rc;
217625 int rc;
217628 rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);
217629 if( rc==SQLITE_OK ){
217634 rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr);
217637 if( rc==SQLITE_OK ){
217638 for(rc = fts5CursorFirst(pTab, pNew, 0);
217639 rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0;
217640 rc = fts5NextMethod((sqlite3_vtab_cursor*)pNew)
217642 rc = xCallback(&sFts5Api, (Fts5Context*)pNew, pUserData);
217643 if( rc!=SQLITE_OK ){
217644 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
217651 return rc;
217733 int rc = SQLITE_OK;
217745 sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);
217753 sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);
217760 for(i=0; rc==SQLITE_OK && i<(nPhrase-1); i++){
217763 rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &dummy, &nByte);
217764 sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);
217768 for(i=0; rc==SQLITE_OK && i<nPhrase; i++){
217771 rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &pPoslist, &nPoslist);
217772 sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);
217781 return rc;
217796 int rc = SQLITE_OK;
217821 if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){
217826 rc = fts5SeekCursor(pCsr, 1);
217827 if( rc==SQLITE_OK ){
217831 return rc;
217923 int rc = sqlite3_overload_function(pGlobal->db, zName, -1);
217924 if( rc==SQLITE_OK ){
217943 rc = SQLITE_NOMEM;
217947 return rc;
217965 int rc = SQLITE_OK;
217983 rc = SQLITE_NOMEM;
217986 return rc;
218016 int rc = SQLITE_OK;
218025 rc = SQLITE_ERROR;
218028 return rc;
218040 int rc = SQLITE_OK;
218045 rc = SQLITE_ERROR;
218048 rc = pMod->x.xCreate(pMod->pUserData, &azArg[1], (nArg?nArg-1:0), ppTok);
218050 if( rc!=SQLITE_OK && pzErr ){
218055 if( rc!=SQLITE_OK ){
218060 return rc;
218152 int rc;
218157 rc = SQLITE_NOMEM;
218166 rc = sqlite3_create_module_v2(db, "fts5", &fts5Mod, p, fts5ModuleDestroy);
218167 if( rc==SQLITE_OK ) rc = sqlite3Fts5IndexInit(db);
218168 if( rc==SQLITE_OK ) rc = sqlite3Fts5ExprInit(pGlobal, db);
218169 if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api);
218170 if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api);
218171 if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db);
218172 if( rc==SQLITE_OK ){
218173 rc = sqlite3_create_function(
218177 if( rc==SQLITE_OK ){
218178 rc = sqlite3_create_function(
218188 if( rc==SQLITE_OK ){
218190 rc = sqlite3Fts5TestRegisterMatchinfo(db);
218194 return rc;
218297 int rc = SQLITE_OK;
218374 rc = SQLITE_NOMEM;
218378 rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
218380 if( rc!=SQLITE_OK && pzErrMsg ){
218388 return rc;
218398 int rc;
218406 rc = SQLITE_NOMEM;
218408 rc = sqlite3_exec(db, zSql, 0, 0, pzErr);
218413 return rc;
218421 int rc = fts5ExecPrintf(pConfig->db, 0,
218429 if( rc==SQLITE_OK && pConfig->bColumnsize ){
218430 rc = fts5ExecPrintf(pConfig->db, 0,
218435 if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){
218436 rc = fts5ExecPrintf(pConfig->db, 0,
218441 return rc;
218460 int rc = sqlite3Fts5StorageSync(pStorage);
218462 fts5StorageRenameOne(pConfig, &rc, "data", zName);
218463 fts5StorageRenameOne(pConfig, &rc, "idx", zName);
218464 fts5StorageRenameOne(pConfig, &rc, "config", zName);
218466 fts5StorageRenameOne(pConfig, &rc, "docsize", zName);
218469 fts5StorageRenameOne(pConfig, &rc, "content", zName);
218471 return rc;
218485 int rc;
218488 rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
218503 return rc;
218520 int rc = SQLITE_OK;
218539 rc = SQLITE_NOMEM;
218549 rc = sqlite3Fts5CreateTable(pConfig, "content", zDefn, 0, pzErr);
218554 if( rc==SQLITE_OK && pConfig->bColumnsize ){
218555 rc = sqlite3Fts5CreateTable(
218559 if( rc==SQLITE_OK ){
218560 rc = sqlite3Fts5CreateTable(
218564 if( rc==SQLITE_OK ){
218565 rc = sqlite3Fts5StorageConfigValue(p, "version", 0, FTS5_CURRENT_VERSION);
218569 if( rc ){
218573 return rc;
218580 int rc = SQLITE_OK;
218591 return rc;
218634 int rc; /* Return code */
218640 rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP, &pSeek, 0);
218641 if( rc!=SQLITE_OK ) return rc;
218650 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel);
218651 for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){
218663 rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT,
218672 if( rc==SQLITE_OK ) rc = rc2;
218673 return rc;
218690 int rc = SQLITE_OK;
218693 rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);
218694 if( rc==SQLITE_OK ){
218698 rc = sqlite3_reset(pReplace);
218702 return rc;
218716 int rc = SQLITE_OK;
218718 rc = sqlite3Fts5IndexGetAverages(p->pIndex, &p->nTotalRow, p->aTotalSize);
218721 return rc;
218735 int rc = SQLITE_OK;
218738 sqlite3Fts5BufferAppendVarint(&rc, &buf, p->nTotalRow);
218740 sqlite3Fts5BufferAppendVarint(&rc, &buf, p->aTotalSize[i]);
218742 if( rc==SQLITE_OK ){
218743 rc = sqlite3Fts5IndexSetAverages(p->pIndex, buf.p, buf.n);
218747 return rc;
218755 int rc;
218759 rc = fts5StorageLoadTotals(p, 1);
218762 if( rc==SQLITE_OK ){
218763 rc = fts5StorageDeleteFromIndex(p, iDel, apVal);
218767 if( rc==SQLITE_OK && pConfig->bColumnsize ){
218768 rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_DOCSIZE, &pDel, 0);
218769 if( rc==SQLITE_OK ){
218772 rc = sqlite3_reset(pDel);
218778 if( rc==SQLITE_OK ){
218779 rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0);
218781 if( rc==SQLITE_OK ){
218784 rc = sqlite3_reset(pDel);
218788 return rc;
218796 int rc;
218799 rc = fts5ExecPrintf(pConfig->db, 0,
218805 if( rc==SQLITE_OK && pConfig->bColumnsize ){
218806 rc = fts5ExecPrintf(pConfig->db, 0,
218814 if( rc==SQLITE_OK ){
218815 rc = sqlite3Fts5IndexReinit(p->pIndex);
218817 if( rc==SQLITE_OK ){
218818 rc = sqlite3Fts5StorageConfigValue(p, "version", 0, FTS5_CURRENT_VERSION);
218820 return rc;
218828 int rc, rc2;
218832 rc = sqlite3Fts5StorageDeleteAll(p);
218833 if( rc==SQLITE_OK ){
218834 rc = fts5StorageLoadTotals(p, 1);
218837 if( rc==SQLITE_OK ){
218838 rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);
218841 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pScan) ){
218845 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
218846 for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
218849 rc = sqlite3Fts5Tokenize(pConfig,
218857 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
218862 if( rc==SQLITE_OK ){
218863 rc = fts5StorageInsertDocsize(p, iRowid, &buf);
218868 if( rc==SQLITE_OK ) rc = rc2;
218871 if( rc==SQLITE_OK ){
218872 rc = fts5StorageSaveTotals(p);
218874 return rc;
218899 int rc = SQLITE_MISMATCH;
218902 rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);
218903 if( rc==SQLITE_OK ){
218907 rc = sqlite3_reset(pReplace);
218909 if( rc==SQLITE_OK ){
218913 return rc;
218925 int rc = SQLITE_OK;
218932 rc = fts5StorageNewRowid(p, piRowid);
218937 rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0);
218938 for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){
218939 rc = sqlite3_bind_value(pInsert, i, apVal[i]);
218941 if( rc==SQLITE_OK ){
218943 rc = sqlite3_reset(pInsert);
218948 return rc;
218960 int rc = SQLITE_OK; /* Return code */
218966 rc = fts5StorageLoadTotals(p, 1);
218968 if( rc==SQLITE_OK ){
218969 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
218971 for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
218974 rc = sqlite3Fts5Tokenize(pConfig,
218982 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
218988 if( rc==SQLITE_OK ){
218989 rc = fts5StorageInsertDocsize(p, iRowid, &buf);
218993 return rc;
218999 int rc;
219005 rc = SQLITE_NOMEM;
219008 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pCnt, 0);
219009 if( rc==SQLITE_OK ){
219013 rc = sqlite3_finalize(pCnt);
219018 return rc;
219050 int rc = SQLITE_OK;
219079 rc = sqlite3Fts5TermsetAdd(pTermset, 0, pToken, nToken, &bPresent);
219080 if( rc==SQLITE_OK && bPresent==0 ){
219086 for(ii=0; rc==SQLITE_OK && ii<pCtx->pConfig->nPrefix; ii++){
219090 rc = sqlite3Fts5TermsetAdd(pTermset, ii+1, pToken, nByte, &bPresent);
219099 return rc;
219110 int rc; /* Return code */
219125 rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);
219126 if( rc==SQLITE_OK ){
219133 rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);
219135 if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){
219136 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
219138 for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
219143 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
219145 if( rc==SQLITE_OK ){
219146 rc = sqlite3Fts5Tokenize(pConfig,
219154 if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
219155 rc = FTS5_CORRUPT;
219166 if( rc!=SQLITE_OK ) break;
219169 if( rc==SQLITE_OK ) rc = rc2;
219173 if( rc==SQLITE_OK ){
219175 rc = fts5StorageLoadTotals(p, 0);
219176 for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
219177 if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;
219183 if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){
219185 rc = fts5StorageCount(p, "content", &nRow);
219186 if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
219188 if( rc==SQLITE_OK && pConfig->bColumnsize ){
219190 rc = fts5StorageCount(p, "docsize", &nRow);
219191 if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
219197 if( rc==SQLITE_OK ){
219198 rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum);
219202 return rc;
219215 int rc;
219220 rc = fts5StorageGetStmt(p, eStmt, pp, pzErrMsg);
219221 if( rc==SQLITE_OK ){
219225 return rc;
219274 int rc; /* Return Code */
219277 rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
219278 if( rc==SQLITE_OK ){
219288 rc = sqlite3_reset(pLookup);
219289 if( bCorrupt && rc==SQLITE_OK ){
219290 rc = FTS5_CORRUPT;
219294 return rc;
219298 int rc = fts5StorageLoadTotals(p, 0);
219299 if( rc==SQLITE_OK ){
219309 rc = SQLITE_RANGE;
219312 return rc;
219316 int rc = fts5StorageLoadTotals(p, 0);
219317 if( rc==SQLITE_OK ){
219324 if( p->nTotalRow<=0 ) rc = FTS5_CORRUPT;
219326 return rc;
219333 int rc = SQLITE_OK;
219336 rc = fts5StorageSaveTotals(p);
219339 if( rc==SQLITE_OK ){
219340 rc = sqlite3Fts5IndexSync(p->pIndex);
219343 return rc;
219358 int rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_CONFIG, &pReplace, 0);
219359 if( rc==SQLITE_OK ){
219367 rc = sqlite3_reset(pReplace);
219370 if( rc==SQLITE_OK && pVal ){
219372 rc = sqlite3Fts5IndexSetCookie(p->pIndex, iNew);
219373 if( rc==SQLITE_OK ){
219377 return rc;
219448 int rc = SQLITE_OK;
219452 rc = SQLITE_ERROR;
219456 rc = SQLITE_NOMEM;
219461 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
219469 rc = SQLITE_ERROR;
219472 if( rc!=SQLITE_OK ){
219480 return rc;
219504 int rc = SQLITE_OK;
219515 while( is<nText && rc==SQLITE_OK ){
219536 rc = SQLITE_NOMEM;
219544 rc = xToken(pCtx, 0, pFold, nByte, is, ie);
219549 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
219550 return rc;
219633 int rc = SQLITE_OK;
219668 rc = SQLITE_NOMEM;
219672 return rc;
219735 int rc = SQLITE_OK; /* Return code */
219741 rc = SQLITE_ERROR;
219753 rc = SQLITE_NOMEM;
219757 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
219763 if( rc==SQLITE_OK ){
219764 rc = unicodeSetCategories(p, zCat);
219767 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
219771 rc = SQLITE_ERROR;
219781 rc = fts5UnicodeAddExceptions(p, zArg, 1);
219784 rc = fts5UnicodeAddExceptions(p, zArg, 0);
219789 rc = SQLITE_ERROR;
219794 rc = SQLITE_NOMEM;
219796 if( rc!=SQLITE_OK ){
219802 return rc;
219825 int rc = SQLITE_OK;
219840 while( rc==SQLITE_OK ){
219875 rc = SQLITE_NOMEM;
219913 rc = xToken(pCtx, 0, aFold, zOut-aFold, is, ie);
219917 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
219918 return rc;
219958 int rc = SQLITE_OK;
219970 rc = pApi->xFindTokenizer(pApi, zBase, &pUserdata, &pRet->tokenizer);
219972 rc = SQLITE_NOMEM;
219974 if( rc==SQLITE_OK ){
219977 rc = pRet->tokenizer.xCreate(pUserdata, azArg2, nArg2, &pRet->pTokenizer);
219980 if( rc!=SQLITE_OK ){
219985 return rc;
220653 int rc = SQLITE_OK; /* Return code */
220656 for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){
220657 rc = pApi->xCreateTokenizer(pApi,
220665 return rc;
221892 int rc = SQLITE_OK;
221893 char *zCopy = sqlite3Fts5Strndup(&rc, zType, -1);
221894 if( rc==SQLITE_OK ){
221908 rc = SQLITE_ERROR;
221913 return rc;
221971 int rc = SQLITE_OK; /* Return code */
221978 rc = SQLITE_ERROR;
221988 rc = fts5VocabTableType(zType, pzErr, &eType);
221989 if( rc==SQLITE_OK ){
221991 rc = sqlite3_declare_vtab(db, azSchema[eType]);
221995 pRet = sqlite3Fts5MallocZero(&rc, nByte);
222010 return rc;
222120 int rc = SQLITE_OK;
222124 zSql = sqlite3Fts5Mprintf(&rc,
222129 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pStmt, 0);
222132 assert( rc==SQLITE_OK || pStmt==0 );
222133 if( rc==SQLITE_ERROR ) rc = SQLITE_OK;
222140 if( rc==SQLITE_OK ){
222142 rc = sqlite3_finalize(pStmt);
222144 if( rc==SQLITE_OK ){
222148 rc = SQLITE_ERROR;
222151 rc = sqlite3Fts5FlushToDisk(pFts5);
222155 if( rc==SQLITE_OK ){
222157 pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);
222170 return rc;
222197 int rc = SQLITE_OK;
222213 sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);
222215 return rc;
222220 int rc = SQLITE_OK;
222233 rc = sqlite3Fts5IterNextScan(pCsr->pIter);
222234 if( rc==SQLITE_OK ){
222235 rc = fts5VocabInstanceNewTerm(pCsr);
222238 if( rc ){
222244 return rc;
222253 int rc = SQLITE_OK;
222286 sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);
222292 while( rc==SQLITE_OK ){
222318 rc = FTS5_CORRUPT;
222330 rc = FTS5_CORRUPT;
222346 if( rc==SQLITE_OK ){
222347 rc = sqlite3Fts5IterNextScan(pCsr->pIter);
222351 if( rc==SQLITE_OK ){
222364 if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){
222368 return rc;
222384 int rc = SQLITE_OK;
222417 rc = SQLITE_NOMEM;
222424 if( rc==SQLITE_OK ){
222426 rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
222428 if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){
222429 rc = fts5VocabInstanceNewTerm(pCsr);
222431 if( rc==SQLITE_OK && !pCsr->bEof
222435 rc = fts5VocabNextMethod(pCursor);
222438 return rc;
222643 int rc;
222659 rc = sqlite3_declare_vtab(db,
222662 if( rc==SQLITE_OK ){
222669 return rc;
222843 int rc = SQLITE_OK;
222845 rc = sqlite3_create_module(db, "sqlite_stmt", &stmtModule, 0);
222847 return rc;
222859 int rc = SQLITE_OK;
222862 rc = sqlite3StmtVtabInit(db);
222864 return rc;