MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / cleanup_database

Function cleanup_database

src/yvalve/user_dsql.cpp:995–1039  ·  view source on GitHub ↗

____________________________________________________________ the cleanup handler called when a database is closed

Source from the content-addressed store, hash-verified

993// the cleanup handler called when a database is closed
994//
995static void cleanup_database(FB_API_HANDLE* db_handle, void* /*dummy*/)
996{
997 if (!db_handle || !databases) {
998 return;
999 }
1000
1001 // for each of the statements in this database, remove it
1002 // from the local list and from the hash table
1003
1004 Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION);
1005
1006 dsql_stmt** stmt_ptr = &statements;
1007 dsql_stmt* p;
1008
1009 while ((p = *stmt_ptr))
1010 {
1011 if (p->stmt_db_handle == *db_handle)
1012 {
1013 *stmt_ptr = p->stmt_next;
1014 if (p->stmt_stmt) {
1015 remove_name(p->stmt_stmt, &statement_names);
1016 }
1017 if (p->stmt_cursor) {
1018 remove_name(p->stmt_cursor, &cursor_names);
1019 }
1020 gds__free(p);
1021 }
1022 else
1023 {
1024 stmt_ptr = &p->stmt_next;
1025 }
1026 }
1027
1028 dsql_dbb* dbb;
1029
1030 for (dsql_dbb** dbb_ptr = &databases; (dbb = *dbb_ptr); dbb_ptr = &dbb->dbb_next)
1031 {
1032 if (dbb->dbb_handle == *db_handle)
1033 {
1034 *dbb_ptr = dbb->dbb_next;
1035 gds__free(dbb);
1036 break;
1037 }
1038 }
1039}
1040
1041//____________________________________________________________
1042//

Callers

nothing calls this directly

Calls 1

remove_nameFunction · 0.85

Tested by

no test coverage detected