* 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
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 */
free(mdb->db_driver);
}
free(mdb);
+ if (db_list->size() == 0) {
+ delete db_list;
+ db_list = NULL;
+ }
}
V(mutex);
}
*/
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");
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;
}
}
#ifdef HAVE_BATCH_FILE_INSERT
-const char *my_dbi_batch_lock_path_query[4] = {
+const char *my_dbi_batch_lock_path_query[5] = {
/* Mysql */
"LOCK TABLES Path write, batch write, Path as p write",
/* Postgresql */
/* SQLite */
"BEGIN",
/* SQLite3 */
- "BEGIN"};
+ "BEGIN",
+ /* Ingres */
+ "BEGIN"
+};
-const char *my_dbi_batch_lock_filename_query[4] = {
+const char *my_dbi_batch_lock_filename_query[5] = {
/* Mysql */
"LOCK TABLES Filename write, batch write, Filename as f write",
/* Postgresql */
/* SQLite */
"BEGIN",
/* SQLite3 */
- "BEGIN"};
+ "BEGIN",
+ /* Ingres */
+ "BEGIN"
+};
-const char *my_dbi_batch_unlock_tables_query[4] = {
+const char *my_dbi_batch_unlock_tables_query[5] = {
/* Mysql */
"UNLOCK TABLES",
/* Postgresql */
/* SQLite */
"COMMIT",
/* SQLite3 */
- "COMMIT"};
+ "COMMIT",
+ /* Ingres */
+ "COMMIT"
+};
-const char *my_dbi_batch_fill_path_query[4] = {
+const char *my_dbi_batch_fill_path_query[5] = {
/* Mysql */
"INSERT INTO Path (Path) "
"SELECT a.Path FROM "
/* SQLite3 */
"INSERT INTO Path (Path)"
" SELECT DISTINCT Path FROM batch"
- " EXCEPT SELECT Path FROM Path"};
+ " EXCEPT SELECT Path FROM Path",
+ /* Ingres */
+ "INSERT INTO Path (Path) "
+ "SELECT a.Path FROM "
+ "(SELECT DISTINCT Path FROM batch) AS a "
+ "WHERE NOT EXISTS (SELECT Path FROM Path WHERE Path = a.Path) "
+};
-const char *my_dbi_batch_fill_filename_query[4] = {
+const char *my_dbi_batch_fill_filename_query[5] = {
/* Mysql */
"INSERT INTO Filename (Name) "
"SELECT a.Name FROM "
/* SQLite3 */
"INSERT INTO Filename (Name)"
" SELECT DISTINCT Name FROM batch "
- " EXCEPT SELECT Name FROM Filename"};
+ " EXCEPT SELECT Name FROM Filename",
+ /* Ingres */
+ "INSERT INTO Filename (Name) "
+ "SELECT a.Name FROM "
+ "(SELECT DISTINCT Name FROM batch) as a "
+ "WHERE NOT EXISTS "
+ "(SELECT Name FROM Filename WHERE Name = a.Name)"
+};
#endif /* HAVE_BATCH_FILE_INSERT */
-const char *my_dbi_match[4] = {
+const char *my_dbi_match[5] = {
/* Mysql */
"MATCH",
/* Postgresql */
/* SQLite */
"MATCH",
/* SQLite3 */
- "MATCH"
+ "MATCH",
+ /* Ingres */
+ "~"
};
#endif /* HAVE_DBI */