@@ -624,7 +624,7 @@ Status attachTableInternal(const std::string& name,
624624
625625 // Note, if the clientData API is used then this will save a registry call
626626 // within xCreate.
627- RecursiveLock lock (kAttachMutex );
627+ auto lock (instance-> attachLock () );
628628 int rc = sqlite3_create_module (
629629 instance->db (), name.c_str (), &module , (void *)&(*instance));
630630 if (rc == SQLITE_OK || rc == SQLITE_MISUSE ) {
@@ -637,10 +637,11 @@ Status attachTableInternal(const std::string& name,
637637 return Status (rc, getStringForSQLiteReturnCode (rc));
638638}
639639
640- Status detachTableInternal (const std::string& name, sqlite3* db) {
641- RecursiveLock lock (kAttachMutex );
640+ Status detachTableInternal (const std::string& name,
641+ const SQLiteDBInstanceRef& instance) {
642+ auto lock (instance->attachLock ());
642643 auto format = " DROP TABLE IF EXISTS temp." + name;
643- int rc = sqlite3_exec (db , format.c_str (), nullptr , nullptr , 0 );
644+ int rc = sqlite3_exec (instance-> db () , format.c_str (), nullptr , nullptr , 0 );
644645 if (rc != SQLITE_OK ) {
645646 LOG (ERROR ) << " Error detaching table: " << name << " (" << rc << " )" ;
646647 }
@@ -655,7 +656,7 @@ Status attachFunctionInternal(
655656 // Hold the manager connection instance again in callbacks.
656657 auto dbc = SQLiteDBManager::get ();
657658 // Add some shell-specific functions to the instance.
658- RecursiveLock lock (kAttachMutex );
659+ auto lock (dbc-> attachLock () );
659660 int rc = sqlite3_create_function (
660661 dbc->db (),
661662 name.c_str (),
0 commit comments