From: drh Date: Fri, 30 Apr 2010 02:13:26 +0000 (+0000) Subject: The first 6 WAL tests now work. It's a start. X-Git-Tag: version-3.7.2~455^2~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79e6c78ccce39af048334f7fb0ad12bdab82d3af;p=thirdparty%2Fsqlite.git The first 6 WAL tests now work. It's a start. FossilOrigin-Name: a92c1851da10acf51e7f6f086b8a23bd731940b3 --- diff --git a/manifest b/manifest index 4e258ea0da..d3df686025 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Refactor\swal.c\sto\suse\sthe\sVFS.\s\sThis\scheck-in\scompiles\sand\slinks\sand\sworks\nok\sas\slong\sas\syou\sleave\sWAL\sturned\soff,\sbut\sWAL\sdoes\snot\swork. -D 2010-04-29T22:34:08 +C The\sfirst\s6\sWAL\stests\snow\swork.\s\sIt's\sa\sstart. +D 2010-04-30T02:13:27 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -153,7 +153,7 @@ F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306 F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c F src/os_common.h 0d6ee583b6ee3185eb9d951f890c6dd03021a08d F src/os_os2.c 8ad77a418630d7dee91d1bb04f79c2096301d3a0 -F src/os_unix.c bf4cc543fcb32dbcb25a88cf817c761ceef14fdd +F src/os_unix.c d9b2b017216075bba93cd4cb38f23396d3d02eb1 F src/os_win.c a8fc01d8483be472e495793c01064fd87e56a5c1 F src/pager.c 07c3522319a449db9dc732da828a09c4c55c41a4 F src/pager.h 934b598583a9d936bb13c37d62a2fe68ac48781c @@ -224,7 +224,7 @@ F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda -F src/wal.c 1c984ba3bba07a9efb4974837d12daef8f0d80c4 +F src/wal.c d9d76a8189a9ac670cd2d5d5dd0c5019194727d7 F src/wal.h d0a7048e68a86d3fe4639858d7f592606545d224 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c faadd9c2bf08868e5135192b44e0d753e363a885 @@ -811,14 +811,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 706611283ea2575c2942543391026b36061cfc1c -R d5f4a8af6d2162b2c802208b97207bbd +P 62db5fa3b61be885b2d94e9b9ce3877b2c588350 +R aef0120cea29fe330250fe68f6819085 U drh -Z eca35982e551d3fde58c618a2bb3d812 +Z 4fcebc28f74cfe3c8cf3e566a4608163 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFL2glkoxKgR168RlERAm4BAJ9/6BoUJM0bQ0jccd1czYE2rrEefgCfYnyN -XCr+jA+ZIb6AheCdZkTnnE4= -=Dx/c +iD8DBQFL2jzNoxKgR168RlERAgWeAJ95gf+z42nfTDpmaeXk9ZGzWPlbxwCdFTJp ++xaXsShNpvEvsgzl2lnGlxE= +=76cZ -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 78f7afdb38..da28f90e44 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -62db5fa3b61be885b2d94e9b9ce3877b2c588350 \ No newline at end of file +a92c1851da10acf51e7f6f086b8a23bd731940b3 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 0e525c0732..8480b5f447 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4710,7 +4710,7 @@ static int unixShmSystemLock( u8 mask; /* Mask of bits in lockMask */ /* Access to the unixShmFile object is serialized by the caller */ - assert( sqlite3_mutex_held(pFile->mutex) ); + assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 ); /* Initialize the locking parameters */ memset(&f, 0, sizeof(f)); @@ -4732,13 +4732,15 @@ static int unixShmSystemLock( mask <<= 1; while( mask!=0 && (lockMask & mask)!=0 ){ f.l_len++; + mask <<= 1; } /* Verify that all bits set in lockMask are contiguous */ assert( mask==0 || (lockMask & ~(mask | (mask-1)))==0 ); /* Acquire the system-level lock */ - rc = (fcntl(pFile->h, lockOp, &f)==0) ? SQLITE_OK : SQLITE_BUSY; + rc = fcntl(pFile->h, lockOp, &f); + rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY; /* Update the global lock state and do debug tracing */ #ifdef SQLITE_DEBUG @@ -4793,9 +4795,6 @@ static int unixShmUnlock( /* Access to the unixShmFile object is serialized by the caller */ assert( sqlite3_mutex_held(pFile->mutex) ); - /* We never try to unlock locks that we do not hold */ - assert( ((p->exclMask|p->sharedMask) & unlockMask)==unlockMask ); - /* Compute locks held by sibling connections */ for(pX=pFile->pFirst; pX; pX=pX->pNext){ if( pX==p ) continue; @@ -4960,7 +4959,7 @@ static int unixShmOpen( rc = SQLITE_NOMEM; goto shm_open_err; } - memset(pFile, 0, sizeof(pFile)); + memset(pFile, 0, sizeof(*pFile)); pFile->zFilename = (char*)&pFile[1]; memcpy(pFile->zFilename, zName, nName+1); pFile->h = -1; @@ -4983,7 +4982,7 @@ static int unixShmOpen( goto shm_open_err; } - pFile->h = open(zName, O_CREAT, 0664); + pFile->h = open(zName, O_RDWR|O_CREAT, 0664); if( pFile->h<0 ){ rc = SQLITE_CANTOPEN; goto shm_open_err; diff --git a/src/wal.c b/src/wal.c index 2de53b8b18..0e44e561f3 100644 --- a/src/wal.c +++ b/src/wal.c @@ -378,25 +378,26 @@ static void walIndexUnmap(Wal *pWal){ } /* -** Map the wal-index file into memory if it isn't already. +** Resize the wal-index file. If newSize is negative, leave the size +** unchanged. */ -static int walIndexMap(Wal *pWal){ - int rc = SQLITE_OK; - if( pWal->pWiData==0 ){ - rc = pWal->pVfs->xShmSize(pWal->pWIndex, -1, - &pWal->szWIndex, (void**)(char*)&pWal->pWiData); +static int walIndexRemap(Wal *pWal, int newSize){ + int rc; + walIndexUnmap(pWal); + rc = pWal->pVfs->xShmSize(pWal->pWIndex, newSize, + &pWal->szWIndex, (void**)(char*)&pWal->pWiData); + if( rc==SQLITE_OK && pWal->pWiData==0 ){ + assert( pWal->szWIndex==0 ); + pWal->pWiData = &pWal->iCallback; } return rc; } /* -** Resize the wal-index file. +** Map the wal-index file into memory if it isn't already. */ -static int walIndexRemap(Wal *pWal, int newSize){ - int rc; - walIndexUnmap(pWal); - rc = pWal->pVfs->xShmSize(pWal->pWIndex, newSize, - &pWal->szWIndex, (void**)(char*)&pWal->pWiData); +static int walIndexMap(Wal *pWal){ + int rc = walIndexRemap(pWal, -1); return rc; } @@ -576,12 +577,12 @@ int sqlite3WalOpen( pRet->pVfs = pVfs; pRet->pFd = (sqlite3_file *)&pRet[1]; zWal = pVfs->szOsFile + (char*)pRet->pFd; - sqlite3_snprintf(nWal, zWal, "%s-wal-index", zDb); + sqlite3_snprintf(nWal+11, zWal, "%s-wal-index", zDb); rc = pVfs->xShmOpen(pVfs, zWal, &pRet->pWIndex); if( rc ) goto wal_open_out; /* Open file handle on the write-ahead log file. */ - zWal[nWal-6] = 0; + zWal[nWal+4] = 0; flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL); rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags); @@ -787,11 +788,18 @@ int walIndexTryHdr(Wal *pWal, int *pChanged){ u32 aCksum[2] = {1, 1}; u32 aHdr[WALINDEX_HDR_NFIELD+2]; + if( pWal->szWIndex==0 ){ + int rc = walIndexRemap(pWal, WALINDEX_MMAP_INCREMENT); + if( rc ) return rc; + } + /* Read the header. The caller may or may not have locked the wal-index ** file, meaning it is possible that an inconsistent snapshot is read ** from the file. If this happens, return SQLITE_ERROR. The caller will ** retry. Or, if the caller has already locked the file and the header ** still looks inconsistent, it will run recovery. + ** + ** FIX-ME: It is no longer possible to have not locked the wal-index. */ memcpy(aHdr, pWal->pWiData, sizeof(aHdr)); walChecksumBytes((u8*)aHdr, sizeof(u32)*WALINDEX_HDR_NFIELD, aCksum);