@@ -77,20 +77,29 @@ inline std::mutex& vec0_registry_mutex() {
7777 static std::mutex m;
7878 return m;
7979}
80- inline void vec0_registry_put (const std::string& key, Vec0Table* t) {
80+ inline std::string vec0_registry_key (sqlite3* db, std::string_view schema_name,
81+ std::string_view table_name) {
82+ std::ostringstream key;
83+ key << static_cast <const void *>(db) << ' |' << schema_name << ' |' << table_name;
84+ return key.str ();
85+ }
86+ inline void vec0_registry_put (sqlite3* db, std::string_view schema_name,
87+ std::string_view table_name, Vec0Table* t) {
8188 std::lock_guard<std::mutex> lk (vec0_registry_mutex ());
82- vec0_table_registry ()[key ] = t;
89+ vec0_table_registry ()[vec0_registry_key (db, schema_name, table_name) ] = t;
8390}
84- inline void vec0_registry_remove (const std::string& key) {
91+ inline void vec0_registry_remove (sqlite3* db, std::string_view schema_name,
92+ std::string_view table_name) {
8593 std::lock_guard<std::mutex> lk (vec0_registry_mutex ());
86- vec0_table_registry ().erase (key );
94+ vec0_table_registry ().erase (vec0_registry_key (db, schema_name, table_name) );
8795}
8896template <typename Fn>
89- inline auto vec0_with_table (sqlite3* /* db*/ , const std::string& table_name, Fn&& fn)
97+ inline auto vec0_with_table (sqlite3* db, std::string_view schema_name,
98+ std::string_view table_name, Fn&& fn)
9099 -> decltype(fn(static_cast <Vec0Table*>(nullptr ))) {
91100 std::lock_guard<std::mutex> lk (vec0_registry_mutex ());
92101 auto & reg = vec0_table_registry ();
93- auto it = reg.find (table_name);
102+ auto it = reg.find (vec0_registry_key (db, schema_name, table_name) );
94103 if (it == reg.end ()) {
95104 return fn (nullptr );
96105 }
@@ -618,7 +627,7 @@ inline int vec0Create(sqlite3* db, void* pAux, int argc, const char* const* argv
618627 }
619628
620629 *ppVTab = &table->base ;
621- vec0_registry_put (table->table_name , table);
630+ vec0_registry_put (table->db , table-> schema_name , table-> table_name , table);
622631 return SQLITE_OK ;
623632}
624633
@@ -633,15 +642,15 @@ inline int vec0Connect(sqlite3* db, void* pAux, int argc, const char* const* arg
633642// xDisconnect: Called when disconnecting from table
634643inline int vec0Disconnect (sqlite3_vtab* pVTab) {
635644 auto * table = reinterpret_cast <Vec0Table*>(pVTab);
636- vec0_registry_remove (table->table_name );
645+ vec0_registry_remove (table->db , table-> schema_name , table-> table_name );
637646 delete table;
638647 return SQLITE_OK ;
639648}
640649
641650// xDestroy: Called when DROP TABLE is executed
642651inline int vec0Destroy (sqlite3_vtab* pVTab) {
643652 auto * table = reinterpret_cast <Vec0Table*>(pVTab);
644- vec0_registry_remove (table->table_name );
653+ vec0_registry_remove (table->db , table-> schema_name , table-> table_name );
645654
646655 // Drop shadow tables
647656 std::ostringstream drop_meta;
0 commit comments