From: Kern Sibbald Date: Tue, 9 Jul 2002 07:06:21 +0000 (+0000) Subject: SQLite optimizations and corrections X-Git-Tag: Release-1.23~15 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=65366008262cd143fd89e9a51123f6a0e5b76193;p=bacula%2Fbacula SQLite optimizations and corrections git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@55 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index 5cd52b9a05..d02c9e128a 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -148,14 +148,13 @@ CREATE TABLE Version ( -- Initialize Version INSERT INTO Version (VersionId) VALUES (2); -CREATE TABLE Counters { +CREATE TABLE Counters ( Counter TINYBLOB NOT NULL, - PoolId INTEGER UNSIGNED REFERENCES Pool NOT NULL, + PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool, MinValue INTEGER, MaxValue INTEGER, CurrentValue INTEGER, - WrapCounter TINYBLOB NOT NULL, - PRIMARY KEY (Counter) + WrapCounter TINYBLOB NOT NULL ); ## Experimental diff --git a/bacula/src/cats/make_sqlite_tables.in b/bacula/src/cats/make_sqlite_tables.in index 57bd9b6c35..70bcda9fa7 100644 --- a/bacula/src/cats/make_sqlite_tables.in +++ b/bacula/src/cats/make_sqlite_tables.in @@ -147,7 +147,7 @@ INSERT INTO Version (VersionId) VALUES (2); CREATE TABLE Counters ( Counter TEXT NOT NULL, - PoolId INTEGER UNSIGNED REFERENCES Pool NOT NULL, + PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, MinValue INTEGER DEFAULT 0, MaxValue INTEGER DEFAULT 0, CurrentValue INTEGER DEFAULT 0, @@ -155,5 +155,7 @@ CREATE TABLE Counters ( PRIMARY KEY (Counter) ); +PRAGMA default_synchronous=OFF; + END-OF-DATA exit 0 diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 1707a84b55..84811d554d 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -107,6 +107,9 @@ ClientId=%d, JobTDate=%s WHERE JobId=%d", (char)(jr->Level), dt, jr->ClientId, edit_uint64(JobTDate, ed1), jr->JobId); stat = UPDATE_DB(mdb, mdb->cmd); db_unlock(mdb); +#ifdef HAVE_SQLITE + my_sqlite_query(mdb, "BEGIN"); /* begin transaction */ +#endif return stat; } @@ -143,6 +146,9 @@ VolSessionTime=%d, PoolId=%d, FileSetId=%d, JobTDate=%s WHERE JobId=%d", jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2), jr->JobId); stat = UPDATE_DB(mdb, mdb->cmd); +#ifdef HAVE_SQLITE + my_sqlite_query(mdb, "COMMIT"); /* end transaction */ +#endif db_unlock(mdb); return stat; }