1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-21 13:38:01 +03:00

Honor key query parameters for SEE on the URI filename for ATTACH

and VACUUM INTO.

FossilOrigin-Name: 2e01096b8933a2315e3dffcd7d0de84c744c1b4be1d909388c61f0fd636ddb99
This commit is contained in:
drh
2019-02-02 15:59:49 +00:00
parent 9b2bd91d9a
commit e5989723ba
5 changed files with 59 additions and 30 deletions

View File

@@ -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