From b2df60889338ba89879911ea5d45f087d7dc4de1 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 23 Sep 2007 20:08:13 +0000 Subject: [PATCH] Turn off some code when batch insert not enabled. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5634 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/mysql.c | 2 ++ bacula/src/cats/postgresql.c | 3 +++ bacula/src/cats/sql_create.c | 3 ++- bacula/src/cats/sqlite.c | 3 ++- bacula/technotes-2.3 | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index 631e6a474f..98bd085a26 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -350,6 +350,7 @@ void my_mysql_free_result(B_DB *mdb) db_unlock(mdb); } +#ifdef HAVE_BATCH_FILE_INSERT char *my_mysql_batch_lock_path_query = "LOCK TABLES Path write, " " batch write, " " Path as p write "; @@ -378,5 +379,6 @@ char *my_mysql_batch_fill_filename_query = "INSERT INTO Filename (Name) " " (SELECT Name " " FROM Filename AS f " " WHERE f.Name = a.Name) "; +#endif /* HAVE_BATCH_FILE_INSERT */ #endif /* HAVE_MYSQL */ diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 82d4e09112..ad3ba5e5ac 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -799,6 +799,7 @@ char *my_postgresql_copy_escape(char *dest, char *src, size_t len) return dest; } +#ifdef HAVE_BATCH_FILE_INSERT char *my_pg_batch_lock_path_query = "BEGIN; LOCK TABLE Path IN SHARE ROW EXCLUSIVE MODE"; @@ -817,4 +818,6 @@ char *my_pg_batch_fill_filename_query = "INSERT INTO Filename (Name) " " (SELECT DISTINCT Name FROM batch) as a " " WHERE NOT EXISTS " " (SELECT Name FROM Filename WHERE Name = a.Name)"; +#endif /* HAVE_BATCH_FILE_INSERT */ + #endif /* HAVE_POSTGRESQL */ diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index b3b37726e2..65dc222497 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -668,6 +668,8 @@ bool db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) * }; */ +#ifdef HAVE_BATCH_FILE_INSERT + /* All sql_batch_* functions are used to do bulk batch insert in File/Filename/Path * tables. This code can be activated by adding "#define HAVE_BATCH_FILE_INSERT 1" * in baconfig.h @@ -746,7 +748,6 @@ bool my_batch_end(JCR *jcr, B_DB *mdb, const char *error) return true; } -#ifdef HAVE_BATCH_FILE_INSERT /* * Returns 1 if OK * 0 if failed diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 460fafe452..0fd4d0d7e2 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -448,6 +448,7 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb) return mdb->fields[mdb->field++]; } +#ifdef HAVE_BATCH_FILE_INSERT char *my_sqlite_batch_lock_query = "BEGIN"; char *my_sqlite_batch_unlock_query = "COMMIT"; char *my_sqlite_batch_fill_path_query = "INSERT INTO Path (Path) " @@ -457,7 +458,7 @@ char *my_sqlite_batch_fill_path_query = "INSERT INTO Path (Path) " char *my_sqlite_batch_fill_filename_query = "INSERT INTO Filename (Name) " " SELECT DISTINCT Name FROM batch " " EXCEPT SELECT Name FROM Filename "; - +#endif /* HAVE_BATCH_FILE_INSERT */ #endif /* HAVE_SQLITE */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index e3e7b26029..33cd3fe787 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,7 @@ General: 23Sep07 +kes Turn off some code when batch insert not enabled. kes Edit FD name in connect error messages. kes Rework the reservation system to take into account that the Director might give us a Volume that is different from the current one being -- 2.39.5