summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/sqldbm.h
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2010-06-15 00:11:14 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2010-06-15 00:16:38 +0530
commit0686a9b9f2d039108ea4a430194644e1b0ee87c0 (patch)
tree212aa2d3e22703b749755919432e4bb75a8e7a8e /crawl-ref/source/sqldbm.h
parent174cd80b10743e99a1017e97a5f6ad7998ccaa3e (diff)
downloadcrawl-ref-0686a9b9f2d039108ea4a430194644e1b0ee87c0.tar.gz
crawl-ref-0686a9b9f2d039108ea4a430194644e1b0ee87c0.zip
Make Crawl open sqlite dbs using readonly connections where possible, and don't create SQLite transactions unless updating the db.
Crawl can now correctly handle the case where one or more Crawl processes are running, the database source text files are modified, and a new Crawl is started. The new Crawl will update the db with the new data, which the old Crawl processes will also see immediately.
Diffstat (limited to 'crawl-ref/source/sqldbm.h')
-rw-r--r--crawl-ref/source/sqldbm.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/crawl-ref/source/sqldbm.h b/crawl-ref/source/sqldbm.h
index 15123b4945..35cff068d0 100644
--- a/crawl-ref/source/sqldbm.h
+++ b/crawl-ref/source/sqldbm.h
@@ -49,7 +49,8 @@ private:
class SQL_DBM
{
public:
- SQL_DBM(const std::string &db = "", bool open = false);
+ SQL_DBM(const std::string &db = "", bool readonly = true,
+ bool open = false);
~SQL_DBM();
bool is_open() const;
@@ -62,6 +63,7 @@ public:
std::string query(const std::string &key);
int insert(const std::string &key, const std::string &value);
+ int remove(const std::string &key);
public:
std::string error;
@@ -73,15 +75,22 @@ private:
int init_query();
int init_iterator();
int init_insert();
+ int init_remove();
int init_schema();
int ec(int err);
+ int try_insert(const std::string &key, const std::string &value);
+ int do_insert(const std::string &key, const std::string &value);
+ int do_query(const std::string &key, std::string *result);
+
private:
sqlite3 *db;
sqlite3_stmt *s_insert;
+ sqlite3_stmt *s_remove;
sqlite3_stmt *s_query;
sqlite3_stmt *s_iterator;
std::string dbfile;
+ bool readonly;
};
SQL_DBM *dbm_open(const char *filename, int open_mode, int permissions);