1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Fix a race condition that can occur when reloading the database schema in shared-cache mode. (CVS 4643)

FossilOrigin-Name: b37babef913fcceae7f0bd461a3105e184518d62
This commit is contained in:
danielk1977
2007-12-27 15:12:16 +00:00
parent 641b0f4ffa
commit 4eab8b7b41
5 changed files with 21 additions and 13 deletions

View File

@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.450 2007/12/04 16:54:53 drh Exp $
** $Id: build.c,v 1.451 2007/12/27 15:12:17 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -403,17 +403,22 @@ void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){
*/
void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
int i, j;
assert( iDb>=0 && iDb<db->nDb );
if( iDb==0 ){
sqlite3BtreeEnterAll(db);
}
for(i=iDb; i<db->nDb; i++){
Db *pDb = &db->aDb[i];
if( pDb->pSchema ){
assert(i==1 || (pDb->pBt && sqlite3BtreeHoldsMutex(pDb->pBt)));
sqlite3SchemaFree(pDb->pSchema);
}
if( iDb>0 ) return;
}
assert( iDb==0 );
db->flags &= ~SQLITE_InternChanges;
sqlite3BtreeLeaveAll(db);
/* If one or more of the auxiliary database files has been closed,
** then remove them from the auxiliary database list. We take the