From: Eric Bollengier Date: Mon, 24 Sep 2007 20:45:10 +0000 (+0000) Subject: ebl Cleanup batch code X-Git-Tag: Release-7.0.0~5616 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3c0ee8a1e54d65a9552750c66a92e641ccf846ac;p=bacula%2Fbacula ebl Cleanup batch code git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5642 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index 98bd085a26..cc5aee701b 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -351,34 +351,34 @@ void my_mysql_free_result(B_DB *mdb) } #ifdef HAVE_BATCH_FILE_INSERT -char *my_mysql_batch_lock_path_query = "LOCK TABLES Path write, " - " batch write, " - " Path as p write "; +char *my_mysql_batch_lock_path_query = "LOCK TABLES Path write," + "batch write," + "Path as p write"; -char *my_mysql_batch_lock_filename_query = "LOCK TABLES Filename write, " - " batch write, " - " Filename as f write "; +char *my_mysql_batch_lock_filename_query = "LOCK TABLES Filename write," + "batch write," + "Filename as f write"; char *my_mysql_batch_unlock_tables_query = "UNLOCK TABLES"; -char *my_mysql_batch_fill_path_query = "INSERT INTO Path (Path) " - " SELECT a.Path FROM " - " (SELECT DISTINCT Path " - " FROM batch) AS a " - " WHERE NOT EXISTS " - " (SELECT Path " - " FROM Path AS p " - " WHERE p.Path = a.Path) "; - -char *my_mysql_batch_fill_filename_query = "INSERT INTO Filename (Name) " - " SELECT a.Name FROM " - " (SELECT DISTINCT Name " - " FROM batch) AS a " - " WHERE NOT EXISTS " - " (SELECT Name " - " FROM Filename AS f " - " WHERE f.Name = a.Name) "; +char *my_mysql_batch_fill_path_query = "INSERT INTO Path (Path) " + "SELECT a.Path FROM " + "(SELECT DISTINCT Path " + "FROM batch) AS a " + "WHERE NOT EXISTS " + "(SELECT Path " + "FROM Path AS p " + "WHERE p.Path = a.Path)"; + +char *my_mysql_batch_fill_filename_query = "INSERT INTO Filename (Name) " + "SELECT a.Name FROM " + "(SELECT DISTINCT Name " + "FROM batch) AS a " + "WHERE NOT EXISTS " + "(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 ad3ba5e5ac..dc0467041d 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -619,13 +619,13 @@ int my_postgresql_batch_start(JCR *jcr, B_DB *mdb) Dmsg0(500, "my_postgresql_batch_start started\n"); if (my_postgresql_query(mdb, - " CREATE TEMPORARY TABLE batch " - " (fileindex int, " - " jobid int, " - " path varchar, " - " name varchar, " - " lstat varchar, " - " md5 varchar)") == 1) + "CREATE TEMPORARY TABLE batch (" + "fileindex int," + "jobid int," + "path varchar," + "name varchar," + "lstat varchar," + "md5 varchar)") == 1) { Dmsg0(500, "my_postgresql_batch_start failed\n"); return 1; @@ -807,17 +807,17 @@ char *my_pg_batch_lock_filename_query = "BEGIN; LOCK TABLE Filename IN SHARE ROW char *my_pg_batch_unlock_tables_query = "COMMIT"; -char *my_pg_batch_fill_path_query = "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) "; +char *my_pg_batch_fill_path_query = "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) "; -char *my_pg_batch_fill_filename_query = "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)"; +char *my_pg_batch_fill_filename_query = "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 */ #endif /* HAVE_POSTGRESQL */ diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 65dc222497..e2811e827b 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -692,13 +692,13 @@ bool my_batch_start(JCR *jcr, B_DB *mdb) db_lock(mdb); ok = db_sql_query(mdb, - " CREATE TEMPORARY TABLE batch " - " (fileindex integer, " - " jobid integer, " - " path blob, " - " name blob, " - " lstat tinyblob, " - " md5 tinyblob) ",NULL, NULL); + "CREATE TEMPORARY TABLE batch (" + "FileIndex integer," + "JobId integer," + "Path blob," + "Name blob," + "LStat tinyblob," + "MD5 tinyblob)",NULL, NULL); db_unlock(mdb); return ok; } @@ -805,12 +805,12 @@ bool db_write_batch_file_records(JCR *jcr) } if (!db_sql_query(jcr->db_batch, - " INSERT INTO File (FileIndex, JobId, PathId, FilenameId, LStat, MD5)" - " SELECT batch.FileIndex, batch.JobId, Path.PathId, " - " Filename.FilenameId,batch.LStat, batch.MD5 " - " FROM batch " - " JOIN Path ON (batch.Path = Path.Path) " - " JOIN Filename ON (batch.Name = Filename.Name) ", + "INSERT INTO File (FileIndex, JobId, PathId, FilenameId, LStat, MD5)" + "SELECT batch.FileIndex, batch.JobId, Path.PathId, " + "Filename.FilenameId,batch.LStat, batch.MD5 " + "FROM batch " + "JOIN Path ON (batch.Path = Path.Path) " + "JOIN Filename ON (batch.Name = Filename.Name)", NULL,NULL)) { Jmsg(jcr, M_FATAL, 0, "Can't fill File table %s\n", jcr->db_batch->errmsg); diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index cd7be4926a..1f8f18c495 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,7 @@ General: 24Sep07 +ebl Cleanup batch code. kes Back out one small change to the reservation system (reserving a volume). kes Rework how a Volume is mounted. It is now much more intelligent and will always attempt to use any mounted volume if possible and reduces