Index: third_party/sqlite/src/src/attach.c |
diff --git a/third_party/sqlite/src/src/attach.c b/third_party/sqlite/src/src/attach.c |
index cf52bb24b126f84efde80f77f51c8fcaeaa992b7..2ab55e6ed62ab4acb3bae0de5177e3bc79c703ec 100644 |
--- a/third_party/sqlite/src/src/attach.c |
+++ b/third_party/sqlite/src/src/attach.c |
@@ -150,6 +150,7 @@ static void attachFunc( |
"attached databases must use the same text encoding as main database"); |
rc = SQLITE_ERROR; |
} |
+ sqlite3BtreeEnter(aNew->pBt); |
pPager = sqlite3BtreePager(aNew->pBt); |
sqlite3PagerLockingMode(pPager, db->dfltLockMode); |
sqlite3BtreeSecureDelete(aNew->pBt, |
@@ -157,6 +158,7 @@ static void attachFunc( |
#ifndef SQLITE_OMIT_PAGER_PRAGMAS |
sqlite3BtreeSetPagerFlags(aNew->pBt, 3 | (db->flags & PAGER_FLAGS_MASK)); |
#endif |
+ sqlite3BtreeLeave(aNew->pBt); |
} |
aNew->safety_level = 3; |
aNew->zName = sqlite3DbStrDup(db, zName); |
@@ -189,7 +191,7 @@ static void attachFunc( |
case SQLITE_NULL: |
/* No key specified. Use the key from the main database */ |
sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey); |
- if( nKey>0 || sqlite3BtreeGetReserve(db->aDb[0].pBt)>0 ){ |
+ if( nKey>0 || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){ |
rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey); |
} |
break; |
@@ -296,7 +298,7 @@ static void detachFunc( |
sqlite3BtreeClose(pDb->pBt); |
pDb->pBt = 0; |
pDb->pSchema = 0; |
- sqlite3ResetAllSchemasOfConnection(db); |
+ sqlite3CollapseDatabaseArray(db); |
return; |
detach_error: |
@@ -330,7 +332,6 @@ static void codeAttach( |
SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) || |
SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey)) |
){ |
- pParse->nErr++; |
goto attach_end; |
} |
@@ -358,7 +359,7 @@ static void codeAttach( |
assert( v || db->mallocFailed ); |
if( v ){ |
- sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs+3-pFunc->nArg, regArgs+3); |
+ sqlite3VdbeAddOp3(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3); |
assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg ); |
sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg)); |
sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF); |