Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | If an ATTACH command fails due to OP_JournalMode but still attaches the database, make sure VACUUM still detaches it when done. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6ecdc7ba2b5e79e8b5862fb49cf6c2b9 |
User & Date: | drh 2010-05-10 14:10:58.000 |
Original Comment: | If an ATTACH command files due to OP_JournalMode but still attaches the database, make sure VACUUM still detaches it when done. |
Context
2010-05-10
| ||
17:29 | Fix an uninitialized variable in OSX proxy locking. (check-in: 96d6eaf4d2 user: drh tags: trunk) | |
14:46 | Modify the format of the wal-index to use a hash table to index log file segments. (check-in: 40b0a6357b user: dan tags: trunk) | |
14:10 | If an ATTACH command fails due to OP_JournalMode but still attaches the database, make sure VACUUM still detaches it when done. (check-in: 6ecdc7ba2b user: drh tags: trunk) | |
11:20 | Enhance the OP_JournalMode opcode with an ignore-errors option and use that option the ATTACH command. (check-in: 0bdea4cfbd user: drh tags: trunk) | |
Changes
Changes to src/vacuum.c.
︙ | ︙ | |||
99 100 101 102 103 104 105 | char *zSql = 0; /* SQL statements */ int saved_flags; /* Saved value of the db->flags */ int saved_nChange; /* Saved value of db->nChange */ int saved_nTotalChange; /* Saved value of db->nTotalChange */ void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ Db *pDb = 0; /* Database to detach at end of vacuum */ int isMemDb; /* True if vacuuming a :memory: database */ | | > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | char *zSql = 0; /* SQL statements */ int saved_flags; /* Saved value of the db->flags */ int saved_nChange; /* Saved value of db->nChange */ int saved_nTotalChange; /* Saved value of db->nTotalChange */ void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ Db *pDb = 0; /* Database to detach at end of vacuum */ int isMemDb; /* True if vacuuming a :memory: database */ int nRes; /* Bytes of reserved space at the end of each page */ int nDb; /* Number of attached databases */ if( !db->autoCommit ){ sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction"); return SQLITE_ERROR; } /* Save the current value of the database flags so that it can be |
︙ | ︙ | |||
134 135 136 137 138 139 140 141 142 143 144 145 146 | ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but ** that actually made the VACUUM run slower. Very little journalling ** actually occurs when doing a vacuum since the vacuum_db is initially ** empty. Only the journal header is written. Apparently it takes more ** time to parse and run the PRAGMA to turn journalling off than it does ** to write the journal header file. */ if( sqlite3TempInMemory(db) ){ zSql = "ATTACH ':memory:' AS vacuum_db;"; }else{ zSql = "ATTACH '' AS vacuum_db;"; } rc = execSql(db, pzErrMsg, zSql); | > | | | > > | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but ** that actually made the VACUUM run slower. Very little journalling ** actually occurs when doing a vacuum since the vacuum_db is initially ** empty. Only the journal header is written. Apparently it takes more ** time to parse and run the PRAGMA to turn journalling off than it does ** to write the journal header file. */ nDb = db->nDb; if( sqlite3TempInMemory(db) ){ zSql = "ATTACH ':memory:' AS vacuum_db;"; }else{ zSql = "ATTACH '' AS vacuum_db;"; } rc = execSql(db, pzErrMsg, zSql); if( db->nDb>nDb ){ pDb = &db->aDb[db->nDb-1]; assert( strcmp(pDb->zName,"vacuum_db")==0 ); } if( rc!=SQLITE_OK ) goto end_of_vacuum; pTemp = db->aDb[db->nDb-1].pBt; /* The call to execSql() to attach the temp database has left the file ** locked (as there was more than one active statement when the transaction ** to read the schema was concluded. Unlock it here so that this doesn't ** cause problems for the call to BtreeSetPageSize() below. */ sqlite3BtreeCommit(pTemp); |
︙ | ︙ |