Fossil SCM

Avoid attaching a database file that already exists.

drh 2019-06-12 12:11 trunk
Commit 052c5f24a96937d8eca392bb0fa5e6657b739fd8917624ded03a7fcc2c055110
1 file changed +1
+1
--- src/db.c
+++ src/db.c
@@ -1257,10 +1257,11 @@
12571257
** zDbName is the name of a database file. Attach zDbName using
12581258
** the name zLabel.
12591259
*/
12601260
void db_attach(const char *zDbName, const char *zLabel){
12611261
Blob key;
1262
+ if( db_table_exists(zLabel,"sqlite_master") ) return;
12621263
blob_init(&key, 0, 0);
12631264
db_maybe_obtain_encryption_key(zDbName, &key);
12641265
if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
12651266
char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q",
12661267
zDbName, zLabel, blob_str(&key));
12671268
--- src/db.c
+++ src/db.c
@@ -1257,10 +1257,11 @@
1257 ** zDbName is the name of a database file. Attach zDbName using
1258 ** the name zLabel.
1259 */
1260 void db_attach(const char *zDbName, const char *zLabel){
1261 Blob key;
 
1262 blob_init(&key, 0, 0);
1263 db_maybe_obtain_encryption_key(zDbName, &key);
1264 if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
1265 char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q",
1266 zDbName, zLabel, blob_str(&key));
1267
--- src/db.c
+++ src/db.c
@@ -1257,10 +1257,11 @@
1257 ** zDbName is the name of a database file. Attach zDbName using
1258 ** the name zLabel.
1259 */
1260 void db_attach(const char *zDbName, const char *zLabel){
1261 Blob key;
1262 if( db_table_exists(zLabel,"sqlite_master") ) return;
1263 blob_init(&key, 0, 0);
1264 db_maybe_obtain_encryption_key(zDbName, &key);
1265 if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
1266 char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q",
1267 zDbName, zLabel, blob_str(&key));
1268

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button