]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/dbi.c
Lets call it COMMIT and not END as that seems to be the counterpart of BEGIN for...
[bacula/bacula] / bacula / src / cats / dbi.c
index 0b1472b48bc5d2d8bba2a22824911ad31216c13f..f3c360ad7195363865fafa8d5de1f596b623ce25 100644 (file)
  *    by Kern Sibbald, March 2000
  *
  */
+/*
+ * This code only compiles against a recent version of libdbi. The current
+ * release found on the libdbi website (0.8.3) won't work for this code.
+ *
+ * You find the libdbi library on http://sourceforge.net/projects/libdbi
+ *
+ * A fairly recent version of libdbi from CVS works, so either make sure
+ * your distribution has a fairly recent version of libdbi installed or
+ * clone the CVS repositories from sourceforge and compile that code and
+ * install it.
+ *
+ * You need:
+ * cvs co :pserver:anonymous@libdbi.cvs.sourceforge.net:/cvsroot/libdbi
+ * cvs co :pserver:anonymous@libdbi-drivers.cvs.sourceforge.net:/cvsroot/libdbi-drivers
+ */
 
 
 /* The following is necessary so that we do not include
@@ -118,7 +133,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char
    P(mutex);                          /* lock DB queue */
    if (db_list == NULL) {
       db_list = New(dlist(mdb, &mdb->link));
-      db_getvalue_list = New(dlist(field, field->link));
+      dbi_getvalue_list = New(dlist(field, &field->link));
    }
    if (!mult_db_connections) {
       /* Look to see if DB already open */
@@ -376,6 +391,10 @@ db_close_database(JCR *jcr, B_DB *mdb)
           free(mdb->db_driver);
       }
       free(mdb);
+      if (db_list->size() == 0) {
+         delete db_list;
+         db_list = NULL;
+      }
    }
    V(mutex);
 }
@@ -731,7 +750,7 @@ const char *my_dbi_strerror(B_DB *mdb)
  */
 int my_dbi_batch_start(JCR *jcr, B_DB *mdb)
 {
-   char *query = "COPY batch FROM STDIN";
+   const char *query = "COPY batch FROM STDIN";
 
    Dmsg0(500, "my_dbi_batch_start started\n");
 
@@ -927,7 +946,7 @@ int my_dbi_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
    mdb->esc_path = check_pool_memory_size(mdb->esc_path, mdb->pnl*2+1);
 
    if (ar->Digest == NULL || ar->Digest[0] == 0) {
-      digest = "0";
+      *digest = '\0';
    } else {
       digest = ar->Digest;
    }
@@ -1264,7 +1283,7 @@ const char *my_dbi_batch_lock_path_query[5] = {
    "BEGIN",
    /* SQLite3 */
    "BEGIN",
-   /* Ingres (TODO) */
+   /* Ingres */
    "BEGIN"
 };
 
@@ -1277,7 +1296,7 @@ const char *my_dbi_batch_lock_filename_query[5] = {
    "BEGIN",
    /* SQLite3 */
    "BEGIN",
-   /* Ingres (TODO) */
+   /* Ingres */
    "BEGIN"
 };
 
@@ -1313,7 +1332,7 @@ const char *my_dbi_batch_fill_path_query[5] = {
    "INSERT INTO Path (Path)"
    " SELECT DISTINCT Path FROM batch"
    " EXCEPT SELECT Path FROM Path",
-   /* Ingres (TODO) */
+   /* Ingres */
    "INSERT INTO Path (Path) "
    "SELECT a.Path FROM "
    "(SELECT DISTINCT Path FROM batch) AS a "
@@ -1340,7 +1359,7 @@ const char *my_dbi_batch_fill_filename_query[5] = {
    "INSERT INTO Filename (Name)"
    " SELECT DISTINCT Name FROM batch "
    " EXCEPT SELECT Name FROM Filename",
-   /* Ingres (TODO) */
+   /* Ingres */
    "INSERT INTO Filename (Name) "
    "SELECT a.Name FROM "
    "(SELECT DISTINCT Name FROM batch) as a "
@@ -1350,7 +1369,7 @@ const char *my_dbi_batch_fill_filename_query[5] = {
 
 #endif /* HAVE_BATCH_FILE_INSERT */
 
-const char *my_dbi_match[4] = {
+const char *my_dbi_match[5] = {
    /* Mysql */
    "MATCH",
    /* Postgresql */
@@ -1358,7 +1377,9 @@ const char *my_dbi_match[4] = {
    /* SQLite */
    "MATCH",
    /* SQLite3 */
-   "MATCH"
+   "MATCH",
+   /* Ingres */
+   "~"
 };
 
 #endif /* HAVE_DBI */