aboutsummaryrefslogtreecommitdiff
path: root/src/attach.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-02-02 15:59:49 +0000
committerdrh <drh@noemail.net>2019-02-02 15:59:49 +0000
commite5989723ba9b6510728d8a50f35347dc8aa4ee6b (patch)
tree0cf2697e5e478696897f50d4a8928962e3476948 /src/attach.c
parent9b2bd91d9a4bf91c3dff1caf1ec2687ed9b54873 (diff)
downloadsqlite-e5989723ba9b6510728d8a50f35347dc8aa4ee6b.tar.gz
sqlite-e5989723ba9b6510728d8a50f35347dc8aa4ee6b.zip
Honor key query parameters for SEE on the URI filename for ATTACH
and VACUUM INTO. FossilOrigin-Name: 2e01096b8933a2315e3dffcd7d0de84c744c1b4be1d909388c61f0fd636ddb99
Diffstat (limited to 'src/attach.c')
-rw-r--r--src/attach.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/attach.c b/src/attach.c
index 0b87d24cf..224d120b6 100644
--- a/src/attach.c
+++ b/src/attach.c
@@ -155,8 +155,8 @@ static void attachFunc(
assert( pVfs );
flags |= SQLITE_OPEN_MAIN_DB;
rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
- sqlite3_free( zPath );
db->nDb++;
+ pNew->zDbSName = sqlite3DbStrDup(db, zName);
}
db->noSharedCache = 0;
if( rc==SQLITE_CONSTRAINT ){
@@ -184,7 +184,6 @@ static void attachFunc(
sqlite3BtreeLeave(pNew->pBt);
}
pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
- if( !REOPEN_AS_MEMDB(db) ) pNew->zDbSName = sqlite3DbStrDup(db, zName);
if( rc==SQLITE_OK && pNew->zDbSName==0 ){
rc = SQLITE_NOMEM_BKPT;
}
@@ -212,15 +211,19 @@ static void attachFunc(
break;
case SQLITE_NULL:
- /* No key specified. Use the key from the main database */
- sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
- if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
- rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+ /* No key specified. Use the key from URI filename, or if none,
+ ** use the key from the main database. */
+ if( sqlite3CodecQueryParameters(db, zName, zPath)==0 ){
+ sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
+ if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
+ rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+ }
}
break;
}
}
#endif
+ sqlite3_free( zPath );
/* If the file was opened successfully, read the schema for the new database.
** If this fails, or if opening the file failed, then close the file and