diff --git a/manifest b/manifest index b83976fa57..5911e5026a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunused\sOP_UtfXX\sopcodes.\s(CVS\s1650) -D 2004-06-21T11:30:56 +C Fix\san\suninitialized\svariable.\s\sThe\svariable\swas\sharmless,\sbut\spedantic\nerror\schecking\sin\sMSVC\sraised\san\sexception\son\sit.\s(CVS\s1651) +D 2004-06-21T18:14:46 F Makefile.in d69d53c543518c1572ee0a8e8723d7e00bdb2266 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -28,9 +28,9 @@ F src/attach.c 05102e2e8ac43ce639d07b47a99c7772a62420e6 F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217 F src/btree.c 0cf8a52a57a7eb13d50719114ee1fa353e89d7d3 F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5 -F src/build.c ffcd0cd8cd8aac1a45d852c6364c6b5b07cd9dc4 +F src/build.c ee7548a4dfc446d4312c217d74badbd2898a7eef F src/date.c b3e8b2bef1e3f2ce24e5b057203036defb18c3f1 -F src/delete.c 19287dd204569519636a04eca2b66c49c26e9266 +F src/delete.c e81545e546f6bc87d7508a93a09ca70695265af3 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37 F src/expr.c a0372aa8d27ce9a82f6419c066b47f0500ec50a6 F src/func.c 3d32878eeb4c6a9977c72ec19984d329b6954c7e @@ -44,11 +44,11 @@ F src/os.h 1cb5f0293a30288451fe3c0c73815cf208212ed1 F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8 F src/os_mac.c 3d31e26be1411acfb7961033098631b4f3486fdf F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4 -F src/os_unix.c 47176c8e9b90ba751b2c110b6384936572ff3abc -F src/os_unix.h 1cd6133cf66dea704b8646b70b2dfdcbdd9b3738 -F src/os_win.c 337e973ee77797aaab4787e3477a5945fcd97266 -F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c -F src/pager.c d627c5e46084b0c757a16cec2c17adcc8046f8ee +F src/os_unix.c 3d3553d71cbf1430a40985a7581ca27b85723ee1 +F src/os_unix.h 00c1f82b526ab2fb7ee5ddd555ea4ed68363c93a +F src/os_win.c 84549f6cc815237533c5d0eb3697352b03478d96 +F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44 +F src/pager.c f42526a134d56f5ee4b4217211dd36b3c8f00963 F src/pager.h bc58d32a9dee464f7268fb68652c130a4216e438 F src/parse.y 097438674976355a10cf177bd97326c548820b86 F src/pragma.c 0750e1c360647dbe0a991f16133b0fe5e42e5039 @@ -61,7 +61,7 @@ F src/sqliteInt.h b379bc549c9d812090d6c33ff5f229b34346ac0c F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2 F src/tclsqlite.c 8d093146332b2f0cbf2a8ebe8597d481619308a3 F src/test1.c ee426e026ad9223483e7a84bb68849fc6e9f542e -F src/test2.c db0a0c30b59f1639cb8c2572be06439402833cc8 +F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40 F src/test3.c 7247090d15a5a43823079b6fd8dad1ed3cccdedf F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2 F src/test5.c 1b7c275b2929dbd034a567255d2aca339410d1d6 @@ -75,12 +75,12 @@ F src/vdbe.c 5da73f61016b1874d935b522bab6ca8b5aa15216 F src/vdbe.h 2d87155e31e84bb00cdc48cc1ce6987a3a484250 F src/vdbeInt.h c0740932621a8d4aac20e0c4235ce44eb5e8dce6 F src/vdbeapi.c 8a9421341e09b506a934132c9015f26362ae8c0e -F src/vdbeaux.c b89e05d8a1be4a27ba98c0ae369642c12a2cb44f +F src/vdbeaux.c bf1f5a48b4d2f4f0ee6e5f00dca491855e81cd02 F src/vdbemem.c 9359c53386e070fea9f5403cab0c6f0cfe36496b F src/where.c 6507074d8ce3f78e7a4cd33f667f11e62020553e F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 F test/attach.test 3acdffccbf5f78b07746771b9490758718e28856 -F test/attach2.test 4462c2e652e3d3ac2a9c86d08eebcd648038ae7d +F test/attach2.test 3cd1d4a69e0ec307d0b68a44a96c9c8e1e253d65 F test/attach3.test c4cc0b806783ce3d860af6b80c947f93ffb14270 F test/auth.test a211eab0542ec024b578d771b09242dd9bb1aba3 F test/bigfile.test a1101b46528ad7282fb9b323d25da18672a3bd0a @@ -225,7 +225,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl af528563442e3039928f9018327a18157e53a44f F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 4d02df63496091a1e643601f84313f42130d6282 -R a5c7b81b886ce0dc51fd23c906f18801 -U danielk1977 -Z 7e03b6c5873537e5aac7ef83e2a8f46a +P 84d6354fce8332b2fb4365ee23b9c9b7c012db9f +R cb4496210314b23d636b73b949f5346a +U drh +Z f5c808fd6c82bca1e41b10c166ff7e8f diff --git a/manifest.uuid b/manifest.uuid index 230ccb85cc..865bdff7dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -84d6354fce8332b2fb4365ee23b9c9b7c012db9f \ No newline at end of file +afc398c2ca97ff165ea8242a5ffb8b6374b7fa8f \ No newline at end of file diff --git a/src/build.c b/src/build.c index 8b43092869..b1ff5016d3 100644 --- a/src/build.c +++ b/src/build.c @@ -23,7 +23,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.229 2004/06/21 10:45:07 danielk1977 Exp $ +** $Id: build.c,v 1.230 2004/06/21 18:14:46 drh Exp $ */ #include "sqliteInt.h" #include @@ -991,45 +991,25 @@ static void callCollNeeded(sqlite *db, const char *zName, int nName){ ** possible. */ static int synthCollSeq(Parse *pParse, CollSeq *pColl){ - CollSeq *pColl2 = 0; + CollSeq *pColl2; char *z = pColl->zName; int n = strlen(z); - switch( pParse->db->enc ){ - case SQLITE_UTF16LE: - pColl2 = sqlite3FindCollSeq(pParse->db, SQLITE_UTF16BE, z, n, 0); - assert( pColl2 ); - if( pColl2->xCmp ) break; - pColl2 = sqlite3FindCollSeq(pParse->db, SQLITE_UTF8, z, n, 0); - assert( pColl2 ); - break; - - case SQLITE_UTF16BE: - pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF16LE, z, n, 0); - assert( pColl2 ); - if( pColl2->xCmp ) break; - pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF8, z, n, 0); - assert( pColl2 ); - break; - - case SQLITE_UTF8: - pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF16BE, z, n, 0); - assert( pColl2 ); - if( pColl2->xCmp ) break; - pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF16LE, z, n, 0); - assert( pColl2 ); - break; - } - if( pColl2->xCmp ){ - memcpy(pColl, pColl2, sizeof(CollSeq)); - }else{ - if( pParse->nErr==0 ){ - sqlite3SetNString(&pParse->zErrMsg, "no such collation sequence: ", - -1, z, n, 0); + sqlite *db = pParse->db; + int i; + static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 }; + for(i=0; i<3; i++){ + pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, n, 0); + if( pColl2->xCmp!=0 ){ + memcpy(pColl, pColl2, sizeof(CollSeq)); + return SQLITE_OK; } - pParse->nErr++; - return SQLITE_ERROR; } - return SQLITE_OK; + if( pParse->nErr==0 ){ + sqlite3SetNString(&pParse->zErrMsg, "no such collation sequence: ", + -1, z, n, 0); + } + pParse->nErr++; + return SQLITE_ERROR; } /* @@ -1056,6 +1036,11 @@ int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){ return SQLITE_OK; } +/* +** Call sqlite3CheckCollSeq() for all collating sequences in an index, +** in order to verify that all the necessary collating sequences are +** loaded. +*/ int sqlite3CheckIndexCollSeq(Parse *pParse, Index *pIdx){ if( pIdx ){ int i; @@ -1124,7 +1109,7 @@ char sqlite3AffinityType(const char *zType, int nType){ int n, i; struct { const char *zSub; /* Keywords substring to search for */ - int nSub; /* length of zSub */ + char nSub; /* length of zSub */ char affinity; /* Affinity to return if it matches */ } substrings[] = { {"INT", 3, SQLITE_AFF_INTEGER}, @@ -1295,12 +1280,6 @@ void sqlite3EndTable(Parse *pParse, Token *pEnd, Select *pSelect){ assert( !db->init.busy || !pSelect ); - /* If the table is generated from a SELECT, then construct the - ** list of columns and the text of the table. - */ - if( pSelect ){ - } - /* If the db->init.busy is 1 it means we are reading the SQL off the ** "sqlite_master" or "sqlite_temp_master" table on the disk. ** So do not write to the disk again. Extract the root page number diff --git a/src/delete.c b/src/delete.c index ec105cbf35..7308eb817e 100644 --- a/src/delete.c +++ b/src/delete.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle DELETE FROM statements. ** -** $Id: delete.c,v 1.76 2004/06/21 06:50:27 danielk1977 Exp $ +** $Id: delete.c,v 1.77 2004/06/21 18:14:47 drh Exp $ */ #include "sqliteInt.h" @@ -44,7 +44,7 @@ int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){ return 1; } if( !viewOk && pTab->pSelect ){ - sqlite3ErrorMsg(pParse, "cannot modify %s because it is a view",pTab->zName); + sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName); return 1; } return 0; diff --git a/src/os_unix.c b/src/os_unix.c index c434007a35..8276c9e0b3 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -341,6 +341,7 @@ int sqlite3OsOpenReadWrite( int *pReadonly ){ int rc; + assert( !id->isOpen ); id->dirfd = -1; id->h = open(zFilename, O_RDWR|O_CREAT|O_LARGEFILE|O_BINARY, 0644); if( id->h<0 ){ @@ -360,6 +361,7 @@ int sqlite3OsOpenReadWrite( return SQLITE_NOMEM; } id->locktype = 0; + id->isOpen = 1; TRACE3("OPEN %-3d %s\n", id->h, zFilename); OpenCounter(+1); return SQLITE_OK; @@ -382,6 +384,7 @@ int sqlite3OsOpenReadWrite( */ int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ int rc; + assert( !id->isOpen ); if( access(zFilename, 0)==0 ){ return SQLITE_CANTOPEN; } @@ -400,6 +403,7 @@ int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ return SQLITE_NOMEM; } id->locktype = 0; + id->isOpen = 1; if( delFlag ){ unlink(zFilename); } @@ -417,6 +421,7 @@ int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ */ int sqlite3OsOpenReadOnly(const char *zFilename, OsFile *id){ int rc; + assert( !id->isOpen ); id->dirfd = -1; id->h = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY); if( id->h<0 ){ @@ -430,6 +435,7 @@ int sqlite3OsOpenReadOnly(const char *zFilename, OsFile *id){ return SQLITE_NOMEM; } id->locktype = 0; + id->isOpen = 1; TRACE3("OPEN-RO %-3d %s\n", id->h, zFilename); OpenCounter(+1); return SQLITE_OK; @@ -455,7 +461,7 @@ int sqlite3OsOpenDirectory( const char *zDirname, OsFile *id ){ - if( id->h<0 ){ + if( !id->isOpen ){ /* Do not open the directory if the corresponding file is not already ** open. */ return SQLITE_CANTOPEN; @@ -510,6 +516,7 @@ int sqlite3OsTempFileName(char *zBuf){ ** Close a file. */ int sqlite3OsClose(OsFile *id){ + if( !id->isOpen ) return SQLITE_OK; sqlite3OsUnlock(id, NO_LOCK); if( id->dirfd>=0 ) close(id->dirfd); id->dirfd = -1; @@ -537,6 +544,7 @@ int sqlite3OsClose(OsFile *id){ releaseLockInfo(id->pLock); releaseOpenCnt(id->pOpen); sqlite3OsLeaveMutex(); + id->isOpen = 0; TRACE2("CLOSE %-3d\n", id->h); OpenCounter(-1); return SQLITE_OK; @@ -549,6 +557,7 @@ int sqlite3OsClose(OsFile *id){ */ int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ int got; + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TIMER_START; got = read(id->h, pBuf, amt); @@ -569,6 +578,7 @@ int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ */ int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ int wrote = 0; + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TIMER_START; while( amt>0 && (wrote = write(id->h, pBuf, amt))>0 ){ @@ -588,6 +598,7 @@ int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ ** Move the read/write pointer in a file. */ int sqlite3OsSeek(OsFile *id, off_t offset){ + assert( id->isOpen ); SEEK(offset/1024 + 1); lseek(id->h, offset, SEEK_SET); return SQLITE_OK; @@ -605,6 +616,7 @@ int sqlite3OsSeek(OsFile *id, off_t offset){ ** will not roll back - possibly leading to database corruption. */ int sqlite3OsSync(OsFile *id){ + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE2("SYNC %-3d\n", id->h); if( fsync(id->h) ){ @@ -641,6 +653,7 @@ int sqlite3OsSyncDirectory(const char *zDirname){ ** Truncate an open file to a specified size */ int sqlite3OsTruncate(OsFile *id, off_t nByte){ + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); return ftruncate(id->h, nByte)==0 ? SQLITE_OK : SQLITE_IOERR; } @@ -650,6 +663,7 @@ int sqlite3OsTruncate(OsFile *id, off_t nByte){ */ int sqlite3OsFileSize(OsFile *id, off_t *pSize){ struct stat buf; + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); if( fstat(id->h, &buf)!=0 ){ return SQLITE_IOERR; @@ -667,6 +681,7 @@ int sqlite3OsFileSize(OsFile *id, off_t *pSize){ int sqlite3OsCheckReservedLock(OsFile *id){ int r = 0; + assert( id->isOpen ); sqlite3OsEnterMutex(); /* Needed because id->pLock is shared across threads */ /* Check if a thread in this process holds such a lock */ @@ -724,6 +739,7 @@ int sqlite3OsLock(OsFile *id, int locktype){ struct flock lock; int s; + assert( id->isOpen ); TRACE6("LOCK %d %d was %d(%d,%d)\n", id->h, locktype, id->locktype, pLock->locktype, pLock->cnt); @@ -869,6 +885,7 @@ int sqlite3OsUnlock(OsFile *id, int locktype){ struct lockInfo *pLock; struct flock lock; + assert( id->isOpen ); TRACE6("UNLOCK %d %d was %d(%d,%d)\n", id->h, locktype, id->locktype, id->pLock->locktype, id->pLock->cnt); diff --git a/src/os_unix.h b/src/os_unix.h index b42b87bdc8..ae16a9ac64 100644 --- a/src/os_unix.h +++ b/src/os_unix.h @@ -65,7 +65,8 @@ struct OsFile { struct openCnt *pOpen; /* Info about all open fd's on this inode */ struct lockInfo *pLock; /* Info about locks on this inode */ int h; /* The file descriptor */ - int locktype; /* The type of lock held on this fd */ + unsigned char locktype; /* The type of lock held on this fd */ + unsigned char isOpen; /* True if needs to be closed */ int dirfd; /* File descriptor for the directory */ }; diff --git a/src/os_win.c b/src/os_win.c index 9947ea7c01..9404859fe4 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -64,7 +64,9 @@ int sqlite3OsOpenReadWrite( OsFile *id, int *pReadonly ){ - HANDLE h = CreateFile(zFilename, + HANDLE h; + assert( !id->isOpen ); + h = CreateFile(zFilename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, @@ -91,6 +93,7 @@ int sqlite3OsOpenReadWrite( id->h = h; id->locktype = NO_LOCK; id->sharedLockByte = 0; + id->isOpen = 1; OpenCounter(+1); TRACE3("OPEN R/W %d \"%s\"\n", h, zFilename); return SQLITE_OK; @@ -114,6 +117,7 @@ int sqlite3OsOpenReadWrite( int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ HANDLE h; int fileflags; + assert( !id->isOpen ); if( delFlag ){ fileflags = FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_DELETE_ON_CLOSE; @@ -134,6 +138,7 @@ int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ id->h = h; id->locktype = NO_LOCK; id->sharedLockByte = 0; + id->isOpen = 1; OpenCounter(+1); TRACE3("OPEN EX %d \"%s\"\n", h, zFilename); return SQLITE_OK; @@ -147,7 +152,9 @@ int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ ** On failure, return SQLITE_CANTOPEN. */ int sqlite3OsOpenReadOnly(const char *zFilename, OsFile *id){ - HANDLE h = CreateFile(zFilename, + HANDLE h; + assert( !id->isOpen ); + h = CreateFile(zFilename, GENERIC_READ, 0, NULL, @@ -161,6 +168,7 @@ int sqlite3OsOpenReadOnly(const char *zFilename, OsFile *id){ id->h = h; id->locktype = NO_LOCK; id->sharedLockByte = 0; + id->isOpen = 1; OpenCounter(+1); TRACE3("OPEN RO %d \"%s\"\n", h, zFilename); return SQLITE_OK; @@ -221,9 +229,12 @@ int sqlite3OsTempFileName(char *zBuf){ ** Close a file. */ int sqlite3OsClose(OsFile *id){ - TRACE2("CLOSE %d\n", id->h); - CloseHandle(id->h); - OpenCounter(-1); + if( id->isOpen ){ + TRACE2("CLOSE %d\n", id->h); + CloseHandle(id->h); + OpenCounter(-1); + id->isOpen = 0; + } return SQLITE_OK; } @@ -234,6 +245,7 @@ int sqlite3OsClose(OsFile *id){ */ int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ DWORD got; + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE3("READ %d lock=%d\n", id->h, id->locktype); if( !ReadFile(id->h, pBuf, amt, &got, 0) ){ @@ -253,6 +265,7 @@ int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ int rc; DWORD wrote; + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE3("WRITE %d lock=%d\n", id->h, id->locktype); while( amt>0 && (rc = WriteFile(id->h, pBuf, amt, &wrote, 0))!=0 && wrote>0 ){ @@ -272,6 +285,7 @@ int sqlite3OsSeek(OsFile *id, off_t offset){ LONG upperBits = offset>>32; LONG lowerBits = offset & 0xffffffff; DWORD rc; + assert( id->isOpen ); SEEK(offset/1024 + 1); rc = SetFilePointer(id->h, lowerBits, &upperBits, FILE_BEGIN); TRACE3("SEEK %d %lld\n", id->h, offset); @@ -282,6 +296,7 @@ int sqlite3OsSeek(OsFile *id, off_t offset){ ** Make sure all writes to a particular file are committed to disk. */ int sqlite3OsSync(OsFile *id){ + assert( id->isOpen ); TRACE3("SYNC %d lock=%d\n", id->h, id->locktype); if( FlushFileBuffers(id->h) ){ return SQLITE_OK; @@ -304,6 +319,7 @@ int sqlite3OsSyncDirectory(const char *zDirname){ */ int sqlite3OsTruncate(OsFile *id, off_t nByte){ LONG upperBits = nByte>>32; + assert( id->isOpen ); TRACE3("TRUNCATE %d %lld\n", id->h, nByte); SimulateIOError(SQLITE_IOERR); SetFilePointer(id->h, nByte, &upperBits, FILE_BEGIN); @@ -316,6 +332,7 @@ int sqlite3OsTruncate(OsFile *id, off_t nByte){ */ int sqlite3OsFileSize(OsFile *id, off_t *pSize){ DWORD upperBits, lowerBits; + assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); lowerBits = GetFileSize(id->h, &upperBits); *pSize = (((off_t)upperBits)<<32) + lowerBits; @@ -408,6 +425,7 @@ int sqlite3OsLock(OsFile *id, int locktype){ int newLocktype; /* Set id->locktype to this value before exiting */ int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */ + assert( id->isOpen ); TRACE5("LOCK %d %d was %d(%d)\n", id->h, locktype, id->locktype, id->sharedLockByte); @@ -520,6 +538,7 @@ int sqlite3OsLock(OsFile *id, int locktype){ */ int sqlite3OsCheckReservedLock(OsFile *id){ int rc; + assert( id->isOpen ); if( id->locktype>=RESERVED_LOCK ){ rc = 1; TRACE3("TEST WR-LOCK %d %d (local)\n", id->h, rc); @@ -545,6 +564,7 @@ int sqlite3OsCheckReservedLock(OsFile *id){ */ int sqlite3OsUnlock(OsFile *id, int locktype){ int rc, type; + assert( id->isOpen ); assert( locktype<=SHARED_LOCK ); TRACE5("UNLOCK %d to %d was %d(%d)\n", id->h, locktype, id->locktype, id->sharedLockByte); diff --git a/src/os_win.h b/src/os_win.h index 614a0ea5e7..c85e231126 100644 --- a/src/os_win.h +++ b/src/os_win.h @@ -38,8 +38,9 @@ typedef struct OsFile OsFile; struct OsFile { HANDLE h; /* Handle for accessing the file */ - int locktype; /* Type of lock currently held on this file */ - int sharedLockByte; /* Randomly chosen byte used as a shared lock */ + unsigned char locktype; /* Type of lock currently held on this file */ + unsigned char isOpen; /* True if needs to be closed */ + short sharedLockByte; /* Randomly chosen byte used as a shared lock */ }; diff --git a/src/pager.c b/src/pager.c index 4e67454225..d3e3863fb0 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.132 2004/06/18 23:21:47 dougcurrie Exp $ +** @(#) $Id: pager.c,v 1.133 2004/06/21 18:14:47 drh Exp $ */ #include "os.h" /* Must be first to enable large file support */ #include "sqliteInt.h" @@ -613,6 +613,7 @@ static int pager_delmaster(const char *zMaster){ /* Open the master journal file exclusively in case some other process ** is running this routine also. Not that it makes too much difference. */ + memset(&master, 0, sizeof(master)); rc = sqlite3OsOpenExclusive(zMaster, &master, 0); if( rc!=SQLITE_OK ) goto delmaster_out; master_open = 1; @@ -652,6 +653,7 @@ static int pager_delmaster(const char *zMaster){ int nMaster; off_t jsz; + memset(&journal, 0, sizeof(journal)); rc = sqlite3OsOpenReadOnly(zJournal, &journal); if( rc!=SQLITE_OK ){ sqlite3OsClose(&journal); @@ -1095,14 +1097,14 @@ int sqlite3pager_open( char zTemp[SQLITE_TEMPNAME_SIZE]; *ppPager = 0; + memset(&fd, 0, sizeof(fd)); if( sqlite3_malloc_failed ){ return SQLITE_NOMEM; } if( zFilename && zFilename[0] ){ if( strcmp(zFilename,":memory:")==0 ){ memDb = 1; - zFullPathname = sqliteMalloc(4); - if( zFullPathname ) strcpy(zFullPathname, ""); + zFullPathname = sqliteStrDup(""); rc = SQLITE_OK; }else{ zFullPathname = sqlite3OsFullPathname(zFilename); @@ -1122,15 +1124,15 @@ int sqlite3pager_open( return SQLITE_NOMEM; } if( rc!=SQLITE_OK ){ - if( tempFile ) sqlite3OsClose(&fd); - if( zFullPathname ) sqliteFree(zFullPathname); + sqlite3OsClose(&fd); + sqliteFree(zFullPathname); return rc; } nameLen = strlen(zFullPathname); pPager = sqliteMalloc( sizeof(*pPager) + nameLen*3 + 30 ); if( pPager==0 ){ - if( tempFile ) sqlite3OsClose(&fd); - if( zFullPathname ) sqliteFree(zFullPathname); + sqlite3OsClose(&fd); + sqliteFree(zFullPathname); return SQLITE_NOMEM; } SET_PAGER(pPager); @@ -1371,9 +1373,7 @@ int sqlite3pager_close(Pager *pPager){ pNext = pPg->pNextAll; sqliteFree(pPg); } - if( !pPager->memDb ){ - sqlite3OsClose(&pPager->fd); - } + sqlite3OsClose(&pPager->fd); assert( pPager->journalOpen==0 ); /* Temp files are automatically deleted by the OS ** if( pPager->tempFile ){ diff --git a/src/test2.c b/src/test2.c index b1660d8f77..074dc4796f 100644 --- a/src/test2.c +++ b/src/test2.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test2.c,v 1.22 2004/06/15 11:40:09 danielk1977 Exp $ +** $Id: test2.c,v 1.23 2004/06/21 18:14:47 drh Exp $ */ #include "os.h" #include "sqliteInt.h" @@ -499,6 +499,7 @@ static int fake_big_file( return TCL_ERROR; } if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR; + memset(&fd, 0, sizeof(fd)); rc = sqlite3OsOpenReadWrite(argv[2], &fd, &readOnly); if( rc ){ Tcl_AppendResult(interp, "open failed: ", errorName(rc), 0); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 823c0972f1..a033812f86 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1036,6 +1036,7 @@ static int vdbeCommit(sqlite *db){ /* Open the master journal. */ assert( strlen(zMaster)nMaster ); + memset(&master, 0, sizeof(master)); rc = sqlite3OsOpenExclusive(zMaster, &master, 0); if( rc!=SQLITE_OK ){ sqliteFree(zMaster); @@ -1789,6 +1790,3 @@ void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){ void sqlite3VdbeCountChanges(Vdbe *p){ p->changeCntOn = 1; } - - - diff --git a/test/attach2.test b/test/attach2.test index e95ca48280..566a292228 100644 --- a/test/attach2.test +++ b/test/attach2.test @@ -12,7 +12,7 @@ # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # -# $Id: attach2.test,v 1.20 2004/06/19 09:08:16 danielk1977 Exp $ +# $Id: attach2.test,v 1.21 2004/06/21 18:14:47 drh Exp $ # set testdir [file dirname $argv0] @@ -366,9 +366,3 @@ do_test attach2-6.4 { db close finish_test - - - - - -