]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Cleanup batch code
authorEric Bollengier <eric@eb.homelinux.org>
Mon, 24 Sep 2007 20:45:10 +0000 (20:45 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 24 Sep 2007 20:45:10 +0000 (20:45 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5642 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/mysql.c
bacula/src/cats/postgresql.c
bacula/src/cats/sql_create.c
bacula/technotes-2.3

index 98bd085a268b34f9b186f6c18148e746b29e4551..cc5aee701b8f431967b7003ca31d0ca1abed7793 100644 (file)
@@ -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 */
index ad3ba5e5ac7d09df0b91067e21196343ee54a373..dc0467041dfa2d322c885278901557597d284e5e 100644 (file)
@@ -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 */
index 65dc2224975e224259af4dbf6ca67632986a4974..e2811e827b64e3e2e0b8f8c3d211576b99d335fb 100644 (file)
@@ -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);
index cd7be4926a7e79ebcfe0188b6499690f4a42c070..1f8f18c4952e4f7c63827cbac69dc4ab779c7ceb 100644 (file)
@@ -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