diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-31T16·05+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-31T16·05+0000 |
commit | 06d3d7355d1b0ec05e61d2e7fe67f8d7153c1ff9 (patch) | |
tree | 424a162babe37ef113f8f908715e095f180d001f /src/globals.cc | |
parent | 177a7782aee4c4789ad5377b5993bfa0b692282e (diff) |
* Enclose most operations that update the database in transactions.
* Open all database tables (Db objects) at initialisation time, not every time they are used. This is necessary because tables have to outlive all transactions that refer to them.
Diffstat (limited to 'src/globals.cc')
-rw-r--r-- | src/globals.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/globals.cc b/src/globals.cc index 8c3ec38283ec..1ec0c4f9ba21 100644 --- a/src/globals.cc +++ b/src/globals.cc @@ -5,10 +5,10 @@ Database nixDB; -string dbPath2Id = "path2id"; -string dbId2Paths = "id2paths"; -string dbSuccessors = "successors"; -string dbSubstitutes = "substitutes"; +TableId dbPath2Id; +TableId dbId2Paths; +TableId dbSuccessors; +TableId dbSubstitutes; string nixStore = "/UNINIT"; @@ -20,13 +20,13 @@ string nixDBPath = "/UNINIT"; void openDB() { nixDB.open(nixDBPath); + dbPath2Id = nixDB.openTable("path2id"); + dbId2Paths = nixDB.openTable("id2paths"); + dbSuccessors = nixDB.openTable("successors"); + dbSubstitutes = nixDB.openTable("substitutes"); } void initDB() { - nixDB.createTable(dbPath2Id); - nixDB.createTable(dbId2Paths); - nixDB.createTable(dbSuccessors); - nixDB.createTable(dbSubstitutes); } |