/ Check-in [34a04836]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure the antipenultimate character of master-journal filenames is a "9" in order to avoid collisions with other files in 8+3 filename mode. Also, limit the number of attempts at finding a unique master-journal filename.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nx-devkit
Files: files | file ages | folders
SHA1: 34a0483605d36e6cf03065ed0df33fb1f7c8a272
User & Date: drh 2011-12-16 00:33:04
Context
2011-12-16
01:21
A better solution to being unable to find a unique master-journal filename: just delete an existing master-journal and reuse it. check-in: 2685c2b9 user: drh tags: nx-devkit
00:33
Make sure the antipenultimate character of master-journal filenames is a "9" in order to avoid collisions with other files in 8+3 filename mode. Also, limit the number of attempts at finding a unique master-journal filename. check-in: 34a04836 user: drh tags: nx-devkit
2011-12-15
17:00
When deleting a file with the multiplexor VFS, also delete any overflow files that exist. check-in: 3af1feaa user: dan tags: nx-devkit
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/util.c.

  1165   1165   ** do the suffix shortening regardless of URI parameter.
  1166   1166   **
  1167   1167   ** Examples:
  1168   1168   **
  1169   1169   **     test.db-journal    =>   test.nal
  1170   1170   **     test.db-wal        =>   test.wal
  1171   1171   **     test.db-shm        =>   test.shm
         1172  +**     test.db-mj7f3319fa =>   test.9fa
  1172   1173   */
  1173   1174   void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
  1174   1175   #if SQLITE_ENABLE_8_3_NAMES<2
  1175   1176     const char *zOk;
  1176   1177     zOk = sqlite3_uri_parameter(zBaseFilename, "8_3_names");
  1177   1178     if( zOk && sqlite3GetBoolean(zOk) )
  1178   1179   #endif

Changes to src/vdbeaux.c.

  1820   1820       sqlite3_vfs *pVfs = db->pVfs;
  1821   1821       int needSync = 0;
  1822   1822       char *zMaster = 0;   /* File-name for the master journal */
  1823   1823       char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);
  1824   1824       sqlite3_file *pMaster = 0;
  1825   1825       i64 offset = 0;
  1826   1826       int res;
         1827  +    int retryCount = 0;
  1827   1828   
  1828   1829       /* Select a master journal file name */
  1829   1830       do {
  1830   1831         u32 iRandom;
         1832  +      if( retryCount++>100 ){
         1833  +        sqlite3_log(SQLITE_FULL, "cannot create a master journal filename");
         1834  +        rc = SQLITE_FULL;
         1835  +        break;
         1836  +      }
  1831   1837         sqlite3DbFree(db, zMaster);
  1832   1838         sqlite3_randomness(sizeof(iRandom), &iRandom);
  1833         -      zMaster = sqlite3MPrintf(db, "%s-mj%08X", zMainFile, iRandom&0x7fffffff);
         1839  +      zMaster = sqlite3MPrintf(db, "%s-mj%06X9%02X", zMainFile,
         1840  +                               (iRandom>>8)&0xffffff, iRandom&0xff);
  1834   1841         if( !zMaster ){
  1835   1842           return SQLITE_NOMEM;
  1836   1843         }
         1844  +      /* The antipenultimate character of the master journal name must
         1845  +      ** be "9" to avoid name collisions when using 8+3 filenames. */
         1846  +      assert( zMaster[strlen(zMaster)-3]=='9' );
  1837   1847         sqlite3FileSuffix3(zMainFile, zMaster);
  1838   1848         rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);
  1839   1849       }while( rc==SQLITE_OK && res );
  1840   1850       if( rc==SQLITE_OK ){
  1841   1851         /* Open the master journal. */
  1842   1852         rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, 
  1843   1853             SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|