Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -542,21 +542,26 @@ ** "main" and "temp") for a single database connection. */ void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){ int i; sqlite3BtreeEnterAll(db); - assert( db->nSchemaLock==0 ); for(i=0; inDb; i++){ Db *pDb = &db->aDb[i]; if( pDb->pSchema ){ - sqlite3SchemaClear(pDb->pSchema); + if( db->nSchemaLock==0 ){ + sqlite3SchemaClear(pDb->pSchema); + }else{ + DbSetProperty(db, i, DB_ResetWanted); + } } } db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk); sqlite3VtabUnlockList(db); sqlite3BtreeLeaveAll(db); - sqlite3CollapseDatabaseArray(db); + if( db->nSchemaLock==0 ){ + sqlite3CollapseDatabaseArray(db); + } } /* ** This routine is called when a commit occurs. */ Index: test/vtab_err.test ================================================================== --- test/vtab_err.test +++ test/vtab_err.test @@ -18,11 +18,10 @@ finish_test return } - unset -nocomplain echo_module_begin_fail do_ioerr_test vtab_err-1 -tclprep { register_echo_module [sqlite3_connection_pointer db] } -sqlbody { BEGIN; @@ -60,7 +59,29 @@ INSERT INTO e SELECT a||'x', b, c FROM r2; COMMIT; } sqlite3_memdebug_fail -1 + +reset_db +register_echo_module [sqlite3_connection_pointer db] +do_execsql_test vtab_err-3.0 { + CREATE TABLE r(a PRIMARY KEY, b, c); + CREATE VIRTUAL TABLE e USING echo(r); +} +faultsim_save_and_close + +do_faultsim_test vtab_err-3 -faults oom-t* -prep { + faultsim_restore_and_reopen + register_echo_module [sqlite3_connection_pointer db] +} -body { + execsql { + BEGIN; + CREATE TABLE xyz(x); + SELECT a FROM e; + COMMIT; + } +} -test { + faultsim_test_result {0 {}} +} finish_test