]> git.sur5r.net Git - bacula/bacula/commitdiff
A better fix for the WIN32_VSS bug that Kern discovered.
authorRobert Nelson <robertn@the-nelsons.org>
Sat, 5 Aug 2006 10:29:01 +0000 (10:29 +0000)
committerRobert Nelson <robertn@the-nelsons.org>
Sat, 5 Aug 2006 10:29:01 +0000 (10:29 +0000)
Create a separate DLL for each database interface.  Then rename it to
bacula_cats.dll during installation.

Move sql_cmd.c from src/dird to src/cats.

Create a header file for the constants exported from sql_cmd.c.

Removed local extern definitions from cats *.c files, put them in sql_cmd.h.

Added Windows version of the database scripts.  In some cases these scripts are placeholders and more work is needed to make them execute.

Eliminated the need to install the database dlls in a client only installation.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3240 91ce42f0-d328-0410-95d8-f526ca767f89

21 files changed:
bacula/src/baconfig.h
bacula/src/cats/Makefile.in
bacula/src/cats/bdb.c
bacula/src/cats/bdb_update.c
bacula/src/cats/cats.h
bacula/src/cats/sql_cmds.c [new file with mode: 0644]
bacula/src/cats/sql_cmds.h [new file with mode: 0644]
bacula/src/cats/sql_create.c
bacula/src/cats/sql_delete.c
bacula/src/cats/sql_find.c
bacula/src/cats/sql_get.c
bacula/src/cats/sql_list.c
bacula/src/cats/sql_update.c
bacula/src/cats/sqlite.c
bacula/src/dird/Makefile.in
bacula/src/dird/sql_cmds.c [deleted file]
bacula/src/dird/ua_dotcmds.c
bacula/src/dird/ua_prune.c
bacula/src/dird/ua_purge.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_update.c

index a4a839b6bb1c9589d900c93bc0926800702136f5..4debd4f4440d86d7c102ae2975a4601279ccbfb0 100644 (file)
@@ -71,6 +71,7 @@ void InitWinAPIWrapper();
 #define  OSDependentInit()    InitWinAPIWrapper()
 
 #undef ENABLE_NLS
+
 #if defined(BUILDING_DLL)
 #  define DLL_IMP_EXP   _declspec(dllexport)
 #elif defined(USING_DLL)
@@ -79,9 +80,16 @@ void InitWinAPIWrapper();
 #  define DLL_IMP_EXP
 #endif
 
+#if defined(USING_CATS)
+#  define CATS_IMP_EXP   _declspec(dllimport)
+#else
+#  define CATS_IMP_EXP
+#endif
+
 #else
 
 #define DLL_IMP_EXP
+#define CATS_IMP_EXP
 
 #define  OSDependentInit()
 #define  tape_open            open
index 0a3495610e09d908ebc7a9207c59a8fe4054a80d..564d503ce1eefb29c7126b3272d091071b1c06db 100644 (file)
@@ -25,12 +25,12 @@ SVROBJS = cats.o sql.o
 
 LIBSRCS = mysql.c bdb.c bdb_create.c bdb_get.c bdb_update.c \
          bdb_delete.c bdb_find.c bdb_list.c \
-         sql.c sql_create.c sql_delete.c sql_find.c \
+         sql.c sql_cmds.c sql_create.c sql_delete.c sql_find.c \
          sql_get.c sql_list.c sql_update.c sqlite.c \
          postgresql.c
 LIBOBJS = mysql.o bdb.o bdb_create.o bdb_get.o bdb_update.o \
          bdb_delete.o bdb_find.o bdb_list.o \
-         sql.o sql_create.o sql_delete.o sql_find.o \
+         sql.o sql_cmds.o sql_create.o sql_delete.o sql_find.o \
          sql_get.o sql_list.o sql_update.o sqlite.o \
          postgresql.o
 
index 3aa57c220da3fcc3ef086cd47e68641d0450d04c..ddf659fd37f959480e352a12859ed41bf6d5e8f5 100644 (file)
 
 uint32_t bacula_db_version = 0;
 
-/* Forward referenced functions */
-
-extern const char *working_directory;
-
 /* List of open databases */
 static BQUEUE db_list = {&db_list, &db_list};
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
index 35fa610a89bfa3b6d9a5c38fdbc76c70835fa5a3..c6ee9fd57eaa75ac6c1d0ceb0b1b5e6c3eb8228a 100755 (executable)
@@ -41,8 +41,6 @@
 
 #ifdef HAVE_BACULA_DB
 
-/* Forward referenced functions */
-
 /* -----------------------------------------------------------------------
  *
  *   Bacula specific defines and subroutines
@@ -217,5 +215,9 @@ int db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    return 1;
 }
 
+void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
+{
+  return;
+}
 
 #endif /* HAVE_BACULA_DB */
index 1d47ae6d060b2047f8cfd5568240565df544492c..2eda36734b8f9c7a73f7281b5ef1a8b9e0c66598 100644 (file)
@@ -795,16 +795,24 @@ struct db_int64_ctx {
 
 #include "protos.h"
 #include "jcr.h"
+#include "sql_cmds.h"
 
 /*
  * Some functions exported by sql.c for use within the
  *   cats directory.
  */
-void list_result(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type);
+void list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type);
 void list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx);
 int get_sql_record_max(JCR *jcr, B_DB *mdb);
 bool check_tables_version(JCR *jcr, B_DB *mdb);
 void _db_unlock(const char *file, int line, B_DB *mdb);
 void _db_lock(const char *file, int line, B_DB *mdb);
 
+void print_dashes(B_DB *mdb);
+void print_result(B_DB *mdb);
+int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+int InsertDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+int DeleteDB(const char *file, int line, JCR *jcr, B_DB *db, char *delete_cmd);
+int UpdateDB(const char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
+void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname);
 #endif /* __SQL_H_ */
diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c
new file mode 100644 (file)
index 0000000..1525fff
--- /dev/null
@@ -0,0 +1,395 @@
+/*
+ *
+ *  This file contains all the SQL commands issued by the Director
+ *
+ *     Kern Sibbald, July MMII
+ *
+ *   Version $Id$
+ */
+/*
+   Copyright (C) 2002-2006 Kern Sibbald
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
+
+ */
+
+#include "bacula.h"
+#include "cats.h"
+
+/* For ua_cmds.c */
+const char *list_pool = "SELECT * FROM Pool WHERE PoolId=%s";
+
+/* For ua_dotcmds.c */
+const char *client_backups =
+   "SELECT DISTINCT Job.JobId,Client.Name as Client,Level,StartTime,"
+   "JobFiles,JobBytes,VolumeName,MediaType,FileSet"
+   " FROM Client,Job,JobMedia,Media,FileSet"
+   " WHERE Client.Name='%s'"
+   " AND FileSet='%s'"
+   " AND Client.ClientId=Job.ClientId"
+   " AND JobStatus='T' AND Type='B'" 
+   " AND JobMedia.JobId=Job.JobId AND JobMedia.MediaId=Media.MediaId"
+   " AND Job.FileSetId=FileSet.FileSetId"
+   " ORDER BY Job.StartTime";
+
+
+/* ====== ua_prune.c */
+
+const char *del_File     = "DELETE FROM File WHERE JobId=%s";
+const char *upd_Purged   = "UPDATE Job Set PurgedFiles=1 WHERE JobId=%s";
+const char *cnt_DelCand  = "SELECT count(*) FROM DelCandidates";
+const char *del_Job      = "DELETE FROM Job WHERE JobId=%s";
+const char *del_MAC      = "DELETE FROM MAC WHERE JobId=%s";
+const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%s";
+const char *cnt_JobMedia = "SELECT count(*) FROM JobMedia WHERE MediaId=%s";
+const char *sel_JobMedia = "SELECT JobId FROM JobMedia WHERE MediaId=%s";
+
+/* Select JobIds for File deletion. */
+const char *select_job =
+   "SELECT JobId from Job "
+   "WHERE JobTDate<%s "
+   "AND ClientId=%s "
+   "AND PurgedFiles=0";
+
+/* Delete temp tables and indexes  */
+const char *drop_deltabs[] = {
+   "DROP TABLE DelCandidates",
+   "DROP INDEX DelInx1",
+   NULL};
+
+
+/* List of SQL commands to create temp table and indicies  */
+const char *create_deltabs[] = {
+   "CREATE TEMPORARY TABLE DelCandidates ("
+#if defined(HAVE_MYSQL)
+      "JobId INTEGER UNSIGNED NOT NULL, "
+      "PurgedFiles TINYINT, "
+      "FileSetId INTEGER UNSIGNED, "
+      "JobFiles INTEGER UNSIGNED, "
+      "JobStatus BINARY(1))",
+#elif defined(HAVE_POSTGRESQL)
+      "JobId INTEGER NOT NULL, "
+      "PurgedFiles SMALLINT, "
+      "FileSetId INTEGER, "
+      "JobFiles INTEGER, "
+      "JobStatus char(1))",
+#else
+      "JobId INTEGER UNSIGNED NOT NULL, "
+      "PurgedFiles TINYINT, "
+      "FileSetId INTEGER UNSIGNED, "
+      "JobFiles INTEGER UNSIGNED, "
+      "JobStatus CHAR)",
+#endif
+   "CREATE INDEX DelInx1 ON DelCandidates (JobId)",
+   NULL};
+
+/* Fill candidates table with all Jobs subject to being deleted.
+ *  This is used for pruning Jobs (first the files, then the Jobs).
+ */
+const char *insert_delcand =
+   "INSERT INTO DelCandidates "
+   "SELECT JobId,PurgedFiles,FileSetId,JobFiles,JobStatus FROM Job "
+   "WHERE Type='%c' "
+   "AND JobTDate<%s "
+   "AND ClientId=%s";
+
+/* Select Jobs from the DelCandidates table that have a
+ * more recent backup -- i.e. are not the only backup.
+ * This is the list of Jobs to delete for a Backup Job.
+ * At the same time, we select "orphanned" jobs
+ * (i.e. no files, ...) for deletion.
+ */
+const char *select_backup_del =
+   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
+   "FROM Job,DelCandidates "
+   "WHERE (Job.JobTDate<%s AND ((DelCandidates.JobFiles=0) OR "
+   "(DelCandidates.JobStatus!='T'))) OR "
+   "(Job.JobTDate>%s "
+   "AND Job.ClientId=%s "
+   "AND Job.Level='F' AND Job.JobStatus='T' AND Job.Type='B' "
+   "AND Job.FileSetId=DelCandidates.FileSetId)";
+
+/* Select Jobs from the DelCandidates table that have a
+ * more recent InitCatalog -- i.e. are not the only InitCatalog
+ * This is the list of Jobs to delete for a Verify Job.
+ */
+const char *select_verify_del =
+   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
+   "FROM Job,DelCandidates "
+   "WHERE (Job.JobTdate<%s AND DelCandidates.JobStatus!='T') OR "
+   "(Job.JobTDate>%s "
+   "AND Job.ClientId=%s "
+   "AND Job.Type='V' AND Job.Level='V' AND Job.JobStatus='T' "
+   "AND Job.FileSetId=DelCandidates.FileSetId)";
+
+
+/* Select Jobs from the DelCandidates table.
+ * This is the list of Jobs to delete for a Restore Job.
+ */
+const char *select_restore_del =
+   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
+   "FROM Job,DelCandidates "
+   "WHERE (Job.JobTdate<%s AND DelCandidates.JobStatus!='T') OR "
+   "(Job.JobTDate>%s "
+   "AND Job.ClientId=%s "
+   "AND Job.Type='R')";
+
+/* Select Jobs from the DelCandidates table.
+ * This is the list of Jobs to delete for an Admin Job.
+ */
+const char *select_admin_del =
+   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
+   "FROM Job,DelCandidates "
+   "WHERE (Job.JobTdate<%s AND DelCandidates.JobStatus!='T') OR "
+   "(Job.JobTDate>%s "
+   "AND Job.ClientId=%s "
+   "AND Job.Type='D')";
+
+
+/* ======= ua_restore.c */
+const char *uar_count_files =
+   "SELECT JobFiles FROM Job WHERE JobId=%s";
+
+/* List last 20 Jobs */
+const char *uar_list_jobs =
+   "SELECT JobId,Client.Name as Client,StartTime,Level as "
+   "JobLevel,JobFiles,JobBytes "
+   "FROM Client,Job WHERE Client.ClientId=Job.ClientId AND JobStatus='T' "
+   "AND Type='B' ORDER BY StartTime DESC LIMIT 20";
+
+#ifdef HAVE_MYSQL
+/*  MYSQL IS NOT STANDARD SQL !!!!! */
+/* List Jobs where a particular file is saved */
+const char *uar_file =
+   "SELECT Job.JobId as JobId,"
+   "CONCAT(Path.Path,Filename.Name) as Name, "
+   "StartTime,Type as JobType,JobStatus,JobFiles,JobBytes "
+   "FROM Client,Job,File,Filename,Path WHERE Client.Name='%s' "
+   "AND Client.ClientId=Job.ClientId "
+   "AND Job.JobId=File.JobId "
+   "AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId "
+   "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20";
+#else
+/* List Jobs where a particular file is saved */
+const char *uar_file =
+   "SELECT Job.JobId as JobId,"
+   "Path.Path||Filename.Name as Name, "
+   "StartTime,Type as JobType,JobStatus,JobFiles,JobBytes "
+   "FROM Client,Job,File,Filename,Path WHERE Client.Name='%s' "
+   "AND Client.ClientId=Job.ClientId "
+   "AND Job.JobId=File.JobId "
+   "AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId "
+   "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20";
+#endif
+
+
+/*
+ * Find all files for a particular JobId and insert them into
+ *  the tree during a restore.
+ */
+const char *uar_sel_files =
+   "SELECT Path.Path,Filename.Name,FileIndex,JobId,LStat "
+   "FROM File,Filename,Path "
+   "WHERE File.JobId=%s AND Filename.FilenameId=File.FilenameId "
+   "AND Path.PathId=File.PathId";
+
+const char *uar_del_temp  = "DROP TABLE temp";
+const char *uar_del_temp1 = "DROP TABLE temp1";
+
+const char *uar_create_temp =
+   "CREATE TEMPORARY TABLE temp ("
+#ifdef HAVE_POSTGRESQL
+   "JobId INTEGER NOT NULL,"
+   "JobTDate BIGINT,"
+   "ClientId INTEGER,"
+   "Level CHAR,"
+   "JobFiles INTEGER,"
+   "JobBytes BIGINT,"
+   "StartTime TEXT,"
+   "VolumeName TEXT,"
+   "StartFile INTEGER,"
+   "VolSessionId INTEGER,"
+   "VolSessionTime INTEGER)";
+#else
+   "JobId INTEGER UNSIGNED NOT NULL,"
+   "JobTDate BIGINT UNSIGNED,"
+   "ClientId INTEGER UNSIGNED,"
+   "Level CHAR,"
+   "JobFiles INTEGER UNSIGNED,"
+   "JobBytes BIGINT UNSIGNED,"
+   "StartTime TEXT,"
+   "VolumeName TEXT,"
+   "StartFile INTEGER UNSIGNED,"
+   "VolSessionId INTEGER UNSIGNED,"
+   "VolSessionTime INTEGER UNSIGNED)";
+#endif
+
+const char *uar_create_temp1 =
+   "CREATE TEMPORARY TABLE temp1 ("
+#ifdef HAVE_POSTGRESQL
+   "JobId INTEGER NOT NULL,"
+   "JobTDate BIGINT)";
+#else
+   "JobId INTEGER UNSIGNED NOT NULL,"
+   "JobTDate BIGINT UNSIGNED)";
+#endif
+
+const char *uar_last_full =
+   "INSERT INTO temp1 SELECT Job.JobId,JobTdate "
+   "FROM Client,Job,JobMedia,Media,FileSet WHERE Client.ClientId=%s "
+   "AND Job.ClientId=%s "
+   "AND Job.StartTime<'%s' "
+   "AND Level='F' AND JobStatus='T' AND Type='B' "
+   "AND JobMedia.JobId=Job.JobId "
+   "AND JobMedia.MediaId=Media.MediaId "
+   "AND Job.FileSetId=FileSet.FileSetId "
+   "AND FileSet.FileSet='%s' "
+   "%s"
+   "ORDER BY Job.JobTDate DESC LIMIT 1";
+
+const char *uar_full =
+   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,"
+   "Job.ClientId,Job.Level,Job.JobFiles,Job.JobBytes,"
+   "StartTime,VolumeName,JobMedia.StartFile,VolSessionId,VolSessionTime "
+   "FROM temp1,Job,JobMedia,Media WHERE temp1.JobId=Job.JobId "
+   "AND Level='F' AND JobStatus='T' AND Type='B' "
+   "AND JobMedia.JobId=Job.JobId "
+   "AND JobMedia.MediaId=Media.MediaId";
+
+const char *uar_dif =
+   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
+   "Job.Level,Job.JobFiles,Job.JobBytes,"
+   "Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
+   "Job.VolSessionId,Job.VolSessionTime "
+   "FROM Job,JobMedia,Media,FileSet "
+   "WHERE Job.JobTDate>%s AND Job.StartTime<'%s' "
+   "AND Job.ClientId=%s "
+   "AND JobMedia.JobId=Job.JobId "
+   "AND JobMedia.MediaId=Media.MediaId "
+   "AND Job.Level='D' AND JobStatus='T' AND Type='B' "
+   "AND Job.FileSetId=FileSet.FileSetId "
+   "AND FileSet.FileSet='%s' "
+   "%s"
+   "ORDER BY Job.JobTDate DESC LIMIT 1";
+
+const char *uar_inc =
+   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
+   "Job.Level,Job.JobFiles,Job.JobBytes,"
+   "Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
+   "Job.VolSessionId,Job.VolSessionTime "
+   "FROM Job,JobMedia,Media,FileSet "
+   "WHERE Job.JobTDate>%s AND Job.StartTime<'%s' "
+   "AND Job.ClientId=%s "
+   "AND JobMedia.JobId=Job.JobId "
+   "AND JobMedia.MediaId=Media.MediaId "
+   "AND Job.Level='I' AND JobStatus='T' AND Type='B' "
+   "AND Job.FileSetId=FileSet.FileSetId "
+   "AND FileSet.FileSet='%s' "
+   "%s";
+
+#ifdef HAVE_POSTGRESQL
+/* Note, the PostgreSQL will have a much uglier looking
+ * list since it cannot do GROUP BY of different values.
+ */
+const char *uar_list_temp =
+   "SELECT JobId,Level,JobFiles,JobBytes,StartTime,VolumeName,StartFile"
+   " FROM temp"
+   " ORDER BY StartTime,StartFile ASC";
+#else
+const char *uar_list_temp =
+   "SELECT JobId,Level,JobFiles,JobBytes,StartTime,VolumeName,StartFile"
+   " FROM temp"
+   " GROUP BY JobId ORDER BY StartTime,StartFile ASC";
+#endif
+
+
+const char *uar_sel_jobid_temp = "SELECT JobId FROM temp ORDER BY StartTime ASC";
+
+const char *uar_sel_all_temp1 = "SELECT * FROM temp1";
+
+const char *uar_sel_all_temp = "SELECT * FROM temp";
+
+
+
+/* Select FileSet names for this Client */
+const char *uar_sel_fileset =
+   "SELECT DISTINCT FileSet.FileSet FROM Job,"
+   "Client,FileSet WHERE Job.FileSetId=FileSet.FileSetId "
+   "AND Job.ClientId=%s AND Client.ClientId=%s "
+   "ORDER BY FileSet.FileSet";
+
+/* Find MediaType used by this Job */
+const char *uar_mediatype =
+   "SELECT MediaType FROM JobMedia,Media WHERE JobMedia.JobId=%s "
+   "AND JobMedia.MediaId=Media.MediaId";
+
+/*
+ *  Find JobId, FileIndex for a given path/file and date
+ *  for use when inserting individual files into the tree.
+ */
+const char *uar_jobid_fileindex =
+   "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
+   "WHERE Job.JobId=File.JobId "
+   "AND Job.StartTime<'%s' "
+   "AND Path.Path='%s' "
+   "AND Filename.Name='%s' "
+   "AND Client.Name='%s' "
+   "AND Job.ClientId=Client.ClientId "
+   "AND Path.PathId=File.PathId "
+   "AND Filename.FilenameId=File.FilenameId "
+   "ORDER BY Job.StartTime DESC LIMIT 1";
+
+const char *uar_jobids_fileindex =
+   "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
+   "WHERE Job.JobId IN (%s) "
+   "AND Job.JobId=File.JobId "
+   "AND Job.StartTime<'%s' "
+   "AND Path.Path='%s' "
+   "AND Filename.Name='%s' "
+   "AND Client.Name='%s' "
+   "AND Job.ClientId=Client.ClientId "
+   "AND Path.PathId=File.PathId "
+   "AND Filename.FilenameId=File.FilenameId "
+   "ORDER BY Job.StartTime DESC LIMIT 1";
+
+/* Query to get all files in a directory -- no recursing   
+ *  Note, for PostgreSQL since it respects the "Single Value
+ *  rule", the results of the SELECT will be unoptimized.
+ *  I.e. the same file will be restored multiple times, once
+ *  for each time it was backed up.
+ */
+
+#ifdef HAVE_POSTGRESQL
+const char *uar_jobid_fileindex_from_dir = 
+   "SELECT Job.JobId,File.FileIndex FROM Job,File,Path,Filename,Client "
+   "WHERE Job.JobId IN (%s) "
+   "AND Job.JobId=File.JobId "
+   "AND Path.Path='%s' "
+   "AND Client.Name='%s' "
+   "AND Job.ClientId=Client.ClientId "
+   "AND Path.PathId=File.Pathid "
+   "AND Filename.FilenameId=File.FilenameId"; 
+#else
+const char *uar_jobid_fileindex_from_dir = 
+   "SELECT Job.JobId,File.FileIndex FROM Job,File,Path,Filename,Client "
+   "WHERE Job.JobId IN (%s) "
+   "AND Job.JobId=File.JobId "
+   "AND Path.Path='%s' "
+   "AND Client.Name='%s' "
+   "AND Job.ClientId=Client.ClientId "
+   "AND Path.PathId=File.Pathid "
+   "AND Filename.FilenameId=File.FilenameId "
+   "GROUP BY File.FileIndex ";
+#endif
+/* Query to get list of files from table -- presuably built by an external program */
+const char *uar_jobid_fileindex_from_table = 
+   "SELECT JobId, FileIndex from %s";
diff --git a/bacula/src/cats/sql_cmds.h b/bacula/src/cats/sql_cmds.h
new file mode 100644 (file)
index 0000000..40b8498
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+   Copyright (C) 2000-2006 Kern Sibbald
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
+
+ */
+
+extern const char CATS_IMP_EXP *client_backups;
+extern const char CATS_IMP_EXP *list_pool;
+extern const char CATS_IMP_EXP *drop_deltabs[];
+extern const char CATS_IMP_EXP *create_deltabs[];
+extern const char CATS_IMP_EXP *insert_delcand;
+extern const char CATS_IMP_EXP *select_backup_del;
+extern const char CATS_IMP_EXP *select_verify_del;
+extern const char CATS_IMP_EXP *select_restore_del;
+extern const char CATS_IMP_EXP *select_admin_del;
+extern const char CATS_IMP_EXP *select_job;
+extern const char CATS_IMP_EXP *del_File;
+extern const char CATS_IMP_EXP *cnt_File;
+extern const char CATS_IMP_EXP *cnt_DelCand;
+extern const char CATS_IMP_EXP *del_Job;
+extern const char CATS_IMP_EXP *del_MAC;
+extern const char CATS_IMP_EXP *del_JobMedia;
+extern const char CATS_IMP_EXP *cnt_JobMedia;
+extern const char CATS_IMP_EXP *sel_JobMedia;
+extern const char CATS_IMP_EXP *upd_Purged;
+
+extern const char CATS_IMP_EXP *uar_list_jobs;
+extern const char CATS_IMP_EXP *uar_file;
+extern const char CATS_IMP_EXP *uar_count_files;
+extern const char CATS_IMP_EXP *uar_sel_files;
+extern const char CATS_IMP_EXP *uar_del_temp;
+extern const char CATS_IMP_EXP *uar_del_temp1;
+extern const char CATS_IMP_EXP *uar_create_temp;
+extern const char CATS_IMP_EXP *uar_create_temp1;
+extern const char CATS_IMP_EXP *uar_last_full;
+extern const char CATS_IMP_EXP *uar_full;
+extern const char CATS_IMP_EXP *uar_inc;
+extern const char CATS_IMP_EXP *uar_list_temp;
+extern const char CATS_IMP_EXP *uar_sel_all_temp1;
+extern const char CATS_IMP_EXP *uar_sel_fileset;
+extern const char CATS_IMP_EXP *uar_mediatype;
+extern const char CATS_IMP_EXP *uar_jobid_fileindex;
+extern const char CATS_IMP_EXP *uar_dif;
+extern const char CATS_IMP_EXP *uar_sel_all_temp;
+extern const char CATS_IMP_EXP *uar_count_files;
+extern const char CATS_IMP_EXP *uar_jobids_fileindex;
+extern const char CATS_IMP_EXP *uar_jobid_fileindex_from_dir;
+extern const char CATS_IMP_EXP *uar_jobid_fileindex_from_table;
+extern const char CATS_IMP_EXP *uar_sel_jobid_temp;
index 43d22aabd94e33bdac0b88d79910f030905b6f30..d38043aa45c4217649583625320bf4f12e9811e6 100644 (file)
@@ -45,15 +45,6 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
 static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
 
 
-/* Imported subroutines */
-extern void print_dashes(B_DB *mdb);
-extern void print_result(B_DB *mdb);
-extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-extern int InsertDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-extern int UpdateDB(const char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
-extern void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname);
-
-
 /* Create a new record for the Job
  * Returns: false on failure
  *          true  on success
index c4641ff4f665f922a928c5bd7492fca79c83d0a3..ef5904b8409c2894b5b4c24e6f4d1dd61ebfd2dd 100644 (file)
  * -----------------------------------------------------------------------
  */
 
-/* Imported subroutines */
-extern void print_dashes(B_DB *mdb);
-extern void print_result(B_DB *mdb);
-extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-extern int DeleteDB(const char *file, int line, JCR *jcr, B_DB *db, char *delete_cmd);
-
 /*
  * Delete Pool record, must also delete all associated
  *  Media records.
index e11a0e0c5fa3d0588606fe4b106e7d4abeeacdac..8d7c9d442ffc8204d0c04629efdca84ef5281e83 100644 (file)
  * -----------------------------------------------------------------------
  */
 
-/* Imported subroutines */
-extern void print_result(B_DB *mdb);
-extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-
 /*
  * Find job start time if JobId specified, otherwise
  * find last full save for Incremental and Differential saves.
index 0fcc2dabd52d59a51d10612f1d59d0bdb6b6d335..74c03435e2feab1f0bcf67e1c56a0184b9008184 100644 (file)
@@ -48,13 +48,6 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb);
 static int db_get_path_record(JCR *jcr, B_DB *mdb);
 
 
-/* Imported subroutines */
-extern void print_result(B_DB *mdb);
-extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-extern void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname);
-
-
-
 /*
  * Given a full filename (with path), look up the File record
  * (with attributes) in the database.
index 2eff15952affc5a9712b0146545a4624dc4dfe27..b9a138a16f76718dc8380ade03171ca057b0a7c7 100644 (file)
  * -----------------------------------------------------------------------
  */
 
-/* Imported subroutines */
-extern void list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
-extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-
-
 /*
  * Submit general SQL query
  */
index b276c671bded9b29efa0a94b8eecf128f3af48a8..d526ad2845976627c5c4738988977038726fe025 100644 (file)
  * -----------------------------------------------------------------------
  */
 
-/* Imported subroutines */
-extern void print_result(B_DB *mdb);
-extern int UpdateDB(const char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
-
 /* -----------------------------------------------------------------------
  *
  *   Generic Routines (or almost generic)
@@ -445,13 +441,4 @@ db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    }
 }
 
-#else
-
-void
-db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
-{
-  /* DUMMY func for Bacula_DB */
-  return;
-}
-
 #endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_SQLITE || HAVE_POSTGRESQL*/
index edc465d37a004d3fe48aabde41527fd0a4a0996c..34f2c136e87f5974f945291ad7c94f014357a0bd 100644 (file)
@@ -39,8 +39,6 @@
  * -----------------------------------------------------------------------
  */
 
-extern const char *working_directory;
-
 /* List of open databases */
 static BQUEUE db_list = {&db_list, &db_list};
 
index f1218a141417f1f7b9c8b2f5fd9c41f4fe183456..7e417b07fbb40e0c334b567873560b8a18937a54 100644 (file)
@@ -38,7 +38,7 @@ SVRSRCS = dird.c admin.c authenticate.c \
          mountreq.c msgchan.c next_vol.c newvol.c \
          pythondir.c \
          recycle.c restore.c run_conf.c \
-         scheduler.c sql_cmds.c \
+         scheduler.c \
          ua_acl.c ua_cmds.c ua_dotcmds.c \
          ua_query.c \
          ua_input.c ua_label.c ua_output.c ua_prune.c \
@@ -53,7 +53,7 @@ SVROBJS = dird.o admin.o authenticate.o \
          mountreq.o msgchan.o next_vol.o newvol.o \
          pythondir.o \
          recycle.o restore.o run_conf.o \
-         scheduler.o sql_cmds.o \
+         scheduler.o \
          ua_acl.o ua_cmds.o ua_dotcmds.o \
          ua_query.o \
          ua_input.o ua_label.o ua_output.o ua_prune.o \
diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c
deleted file mode 100644 (file)
index e0f9719..0000000
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- *
- *  This file contains all the SQL commands issued by the Director
- *
- *     Kern Sibbald, July MMII
- *
- *   Version $Id$
- */
-/*
-   Copyright (C) 2002-2006 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
-
- */
-
-#include "bacula.h"
-#include "dird.h"
-
-/* For ua_cmds.c */
-const char *list_pool = "SELECT * FROM Pool WHERE PoolId=%s";
-
-/* For ua_dotcmds.c */
-const char *client_backups =
-   "SELECT DISTINCT Job.JobId,Client.Name as Client,Level,StartTime,"
-   "JobFiles,JobBytes,VolumeName,MediaType,FileSet"
-   " FROM Client,Job,JobMedia,Media,FileSet"
-   " WHERE Client.Name='%s'"
-   " AND FileSet='%s'"
-   " AND Client.ClientId=Job.ClientId"
-   " AND JobStatus='T' AND Type='B'" 
-   " AND JobMedia.JobId=Job.JobId AND JobMedia.MediaId=Media.MediaId"
-   " AND Job.FileSetId=FileSet.FileSetId"
-   " ORDER BY Job.StartTime";
-
-
-/* ====== ua_prune.c */
-
-const char *del_File     = "DELETE FROM File WHERE JobId=%s";
-const char *upd_Purged   = "UPDATE Job Set PurgedFiles=1 WHERE JobId=%s";
-const char *cnt_DelCand  = "SELECT count(*) FROM DelCandidates";
-const char *del_Job      = "DELETE FROM Job WHERE JobId=%s";
-const char *del_MAC      = "DELETE FROM MAC WHERE JobId=%s";
-const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%s";
-const char *cnt_JobMedia = "SELECT count(*) FROM JobMedia WHERE MediaId=%s";
-const char *sel_JobMedia = "SELECT JobId FROM JobMedia WHERE MediaId=%s";
-
-/* Select JobIds for File deletion. */
-const char *select_job =
-   "SELECT JobId from Job "
-   "WHERE JobTDate<%s "
-   "AND ClientId=%s "
-   "AND PurgedFiles=0";
-
-/* Delete temp tables and indexes  */
-const char *drop_deltabs[] = {
-   "DROP TABLE DelCandidates",
-   "DROP INDEX DelInx1",
-   NULL};
-
-
-/* List of SQL commands to create temp table and indicies  */
-const char *create_deltabs[] = {
-   "CREATE TEMPORARY TABLE DelCandidates ("
-#if defined(HAVE_MYSQL)
-      "JobId INTEGER UNSIGNED NOT NULL, "
-      "PurgedFiles TINYINT, "
-      "FileSetId INTEGER UNSIGNED, "
-      "JobFiles INTEGER UNSIGNED, "
-      "JobStatus BINARY(1))",
-#elif defined(HAVE_POSTGRESQL)
-      "JobId INTEGER NOT NULL, "
-      "PurgedFiles SMALLINT, "
-      "FileSetId INTEGER, "
-      "JobFiles INTEGER, "
-      "JobStatus char(1))",
-#else
-      "JobId INTEGER UNSIGNED NOT NULL, "
-      "PurgedFiles TINYINT, "
-      "FileSetId INTEGER UNSIGNED, "
-      "JobFiles INTEGER UNSIGNED, "
-      "JobStatus CHAR)",
-#endif
-   "CREATE INDEX DelInx1 ON DelCandidates (JobId)",
-   NULL};
-
-/* Fill candidates table with all Jobs subject to being deleted.
- *  This is used for pruning Jobs (first the files, then the Jobs).
- */
-const char *insert_delcand =
-   "INSERT INTO DelCandidates "
-   "SELECT JobId,PurgedFiles,FileSetId,JobFiles,JobStatus FROM Job "
-   "WHERE Type='%c' "
-   "AND JobTDate<%s "
-   "AND ClientId=%s";
-
-/* Select Jobs from the DelCandidates table that have a
- * more recent backup -- i.e. are not the only backup.
- * This is the list of Jobs to delete for a Backup Job.
- * At the same time, we select "orphanned" jobs
- * (i.e. no files, ...) for deletion.
- */
-const char *select_backup_del =
-   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
-   "FROM Job,DelCandidates "
-   "WHERE (Job.JobTDate<%s AND ((DelCandidates.JobFiles=0) OR "
-   "(DelCandidates.JobStatus!='T'))) OR "
-   "(Job.JobTDate>%s "
-   "AND Job.ClientId=%s "
-   "AND Job.Level='F' AND Job.JobStatus='T' AND Job.Type='B' "
-   "AND Job.FileSetId=DelCandidates.FileSetId)";
-
-/* Select Jobs from the DelCandidates table that have a
- * more recent InitCatalog -- i.e. are not the only InitCatalog
- * This is the list of Jobs to delete for a Verify Job.
- */
-const char *select_verify_del =
-   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
-   "FROM Job,DelCandidates "
-   "WHERE (Job.JobTdate<%s AND DelCandidates.JobStatus!='T') OR "
-   "(Job.JobTDate>%s "
-   "AND Job.ClientId=%s "
-   "AND Job.Type='V' AND Job.Level='V' AND Job.JobStatus='T' "
-   "AND Job.FileSetId=DelCandidates.FileSetId)";
-
-
-/* Select Jobs from the DelCandidates table.
- * This is the list of Jobs to delete for a Restore Job.
- */
-const char *select_restore_del =
-   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
-   "FROM Job,DelCandidates "
-   "WHERE (Job.JobTdate<%s AND DelCandidates.JobStatus!='T') OR "
-   "(Job.JobTDate>%s "
-   "AND Job.ClientId=%s "
-   "AND Job.Type='R')";
-
-/* Select Jobs from the DelCandidates table.
- * This is the list of Jobs to delete for an Admin Job.
- */
-const char *select_admin_del =
-   "SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles "
-   "FROM Job,DelCandidates "
-   "WHERE (Job.JobTdate<%s AND DelCandidates.JobStatus!='T') OR "
-   "(Job.JobTDate>%s "
-   "AND Job.ClientId=%s "
-   "AND Job.Type='D')";
-
-
-/* ======= ua_restore.c */
-const char *uar_count_files =
-   "SELECT JobFiles FROM Job WHERE JobId=%s";
-
-/* List last 20 Jobs */
-const char *uar_list_jobs =
-   "SELECT JobId,Client.Name as Client,StartTime,Level as "
-   "JobLevel,JobFiles,JobBytes "
-   "FROM Client,Job WHERE Client.ClientId=Job.ClientId AND JobStatus='T' "
-   "AND Type='B' ORDER BY StartTime DESC LIMIT 20";
-
-#ifdef HAVE_MYSQL
-/*  MYSQL IS NOT STANDARD SQL !!!!! */
-/* List Jobs where a particular file is saved */
-const char *uar_file =
-   "SELECT Job.JobId as JobId,"
-   "CONCAT(Path.Path,Filename.Name) as Name, "
-   "StartTime,Type as JobType,JobStatus,JobFiles,JobBytes "
-   "FROM Client,Job,File,Filename,Path WHERE Client.Name='%s' "
-   "AND Client.ClientId=Job.ClientId "
-   "AND Job.JobId=File.JobId "
-   "AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId "
-   "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20";
-#else
-/* List Jobs where a particular file is saved */
-const char *uar_file =
-   "SELECT Job.JobId as JobId,"
-   "Path.Path||Filename.Name as Name, "
-   "StartTime,Type as JobType,JobStatus,JobFiles,JobBytes "
-   "FROM Client,Job,File,Filename,Path WHERE Client.Name='%s' "
-   "AND Client.ClientId=Job.ClientId "
-   "AND Job.JobId=File.JobId "
-   "AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId "
-   "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20";
-#endif
-
-
-/*
- * Find all files for a particular JobId and insert them into
- *  the tree during a restore.
- */
-const char *uar_sel_files =
-   "SELECT Path.Path,Filename.Name,FileIndex,JobId,LStat "
-   "FROM File,Filename,Path "
-   "WHERE File.JobId=%s AND Filename.FilenameId=File.FilenameId "
-   "AND Path.PathId=File.PathId";
-
-const char *uar_del_temp  = "DROP TABLE temp";
-const char *uar_del_temp1 = "DROP TABLE temp1";
-
-const char *uar_create_temp =
-   "CREATE TEMPORARY TABLE temp ("
-#ifdef HAVE_POSTGRESQL
-   "JobId INTEGER NOT NULL,"
-   "JobTDate BIGINT,"
-   "ClientId INTEGER,"
-   "Level CHAR,"
-   "JobFiles INTEGER,"
-   "JobBytes BIGINT,"
-   "StartTime TEXT,"
-   "VolumeName TEXT,"
-   "StartFile INTEGER,"
-   "VolSessionId INTEGER,"
-   "VolSessionTime INTEGER)";
-#else
-   "JobId INTEGER UNSIGNED NOT NULL,"
-   "JobTDate BIGINT UNSIGNED,"
-   "ClientId INTEGER UNSIGNED,"
-   "Level CHAR,"
-   "JobFiles INTEGER UNSIGNED,"
-   "JobBytes BIGINT UNSIGNED,"
-   "StartTime TEXT,"
-   "VolumeName TEXT,"
-   "StartFile INTEGER UNSIGNED,"
-   "VolSessionId INTEGER UNSIGNED,"
-   "VolSessionTime INTEGER UNSIGNED)";
-#endif
-
-const char *uar_create_temp1 =
-   "CREATE TEMPORARY TABLE temp1 ("
-#ifdef HAVE_POSTGRESQL
-   "JobId INTEGER NOT NULL,"
-   "JobTDate BIGINT)";
-#else
-   "JobId INTEGER UNSIGNED NOT NULL,"
-   "JobTDate BIGINT UNSIGNED)";
-#endif
-
-const char *uar_last_full =
-   "INSERT INTO temp1 SELECT Job.JobId,JobTdate "
-   "FROM Client,Job,JobMedia,Media,FileSet WHERE Client.ClientId=%s "
-   "AND Job.ClientId=%s "
-   "AND Job.StartTime<'%s' "
-   "AND Level='F' AND JobStatus='T' AND Type='B' "
-   "AND JobMedia.JobId=Job.JobId "
-   "AND JobMedia.MediaId=Media.MediaId "
-   "AND Job.FileSetId=FileSet.FileSetId "
-   "AND FileSet.FileSet='%s' "
-   "%s"
-   "ORDER BY Job.JobTDate DESC LIMIT 1";
-
-const char *uar_full =
-   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,"
-   "Job.ClientId,Job.Level,Job.JobFiles,Job.JobBytes,"
-   "StartTime,VolumeName,JobMedia.StartFile,VolSessionId,VolSessionTime "
-   "FROM temp1,Job,JobMedia,Media WHERE temp1.JobId=Job.JobId "
-   "AND Level='F' AND JobStatus='T' AND Type='B' "
-   "AND JobMedia.JobId=Job.JobId "
-   "AND JobMedia.MediaId=Media.MediaId";
-
-const char *uar_dif =
-   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
-   "Job.Level,Job.JobFiles,Job.JobBytes,"
-   "Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
-   "Job.VolSessionId,Job.VolSessionTime "
-   "FROM Job,JobMedia,Media,FileSet "
-   "WHERE Job.JobTDate>%s AND Job.StartTime<'%s' "
-   "AND Job.ClientId=%s "
-   "AND JobMedia.JobId=Job.JobId "
-   "AND JobMedia.MediaId=Media.MediaId "
-   "AND Job.Level='D' AND JobStatus='T' AND Type='B' "
-   "AND Job.FileSetId=FileSet.FileSetId "
-   "AND FileSet.FileSet='%s' "
-   "%s"
-   "ORDER BY Job.JobTDate DESC LIMIT 1";
-
-const char *uar_inc =
-   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
-   "Job.Level,Job.JobFiles,Job.JobBytes,"
-   "Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
-   "Job.VolSessionId,Job.VolSessionTime "
-   "FROM Job,JobMedia,Media,FileSet "
-   "WHERE Job.JobTDate>%s AND Job.StartTime<'%s' "
-   "AND Job.ClientId=%s "
-   "AND JobMedia.JobId=Job.JobId "
-   "AND JobMedia.MediaId=Media.MediaId "
-   "AND Job.Level='I' AND JobStatus='T' AND Type='B' "
-   "AND Job.FileSetId=FileSet.FileSetId "
-   "AND FileSet.FileSet='%s' "
-   "%s";
-
-#ifdef HAVE_POSTGRESQL
-/* Note, the PostgreSQL will have a much uglier looking
- * list since it cannot do GROUP BY of different values.
- */
-const char *uar_list_temp =
-   "SELECT JobId,Level,JobFiles,JobBytes,StartTime,VolumeName,StartFile"
-   " FROM temp"
-   " ORDER BY StartTime,StartFile ASC";
-#else
-const char *uar_list_temp =
-   "SELECT JobId,Level,JobFiles,JobBytes,StartTime,VolumeName,StartFile"
-   " FROM temp"
-   " GROUP BY JobId ORDER BY StartTime,StartFile ASC";
-#endif
-
-
-const char *uar_sel_jobid_temp = "SELECT JobId FROM temp ORDER BY StartTime ASC";
-
-const char *uar_sel_all_temp1 = "SELECT * FROM temp1";
-
-const char *uar_sel_all_temp = "SELECT * FROM temp";
-
-
-
-/* Select FileSet names for this Client */
-const char *uar_sel_fileset =
-   "SELECT DISTINCT FileSet.FileSet FROM Job,"
-   "Client,FileSet WHERE Job.FileSetId=FileSet.FileSetId "
-   "AND Job.ClientId=%s AND Client.ClientId=%s "
-   "ORDER BY FileSet.FileSet";
-
-/* Find MediaType used by this Job */
-const char *uar_mediatype =
-   "SELECT MediaType FROM JobMedia,Media WHERE JobMedia.JobId=%s "
-   "AND JobMedia.MediaId=Media.MediaId";
-
-/*
- *  Find JobId, FileIndex for a given path/file and date
- *  for use when inserting individual files into the tree.
- */
-const char *uar_jobid_fileindex =
-   "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
-   "WHERE Job.JobId=File.JobId "
-   "AND Job.StartTime<'%s' "
-   "AND Path.Path='%s' "
-   "AND Filename.Name='%s' "
-   "AND Client.Name='%s' "
-   "AND Job.ClientId=Client.ClientId "
-   "AND Path.PathId=File.PathId "
-   "AND Filename.FilenameId=File.FilenameId "
-   "ORDER BY Job.StartTime DESC LIMIT 1";
-
-const char *uar_jobids_fileindex =
-   "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
-   "WHERE Job.JobId IN (%s) "
-   "AND Job.JobId=File.JobId "
-   "AND Job.StartTime<'%s' "
-   "AND Path.Path='%s' "
-   "AND Filename.Name='%s' "
-   "AND Client.Name='%s' "
-   "AND Job.ClientId=Client.ClientId "
-   "AND Path.PathId=File.PathId "
-   "AND Filename.FilenameId=File.FilenameId "
-   "ORDER BY Job.StartTime DESC LIMIT 1";
-
-/* Query to get all files in a directory -- no recursing   
- *  Note, for PostgreSQL since it respects the "Single Value
- *  rule", the results of the SELECT will be unoptimized.
- *  I.e. the same file will be restored multiple times, once
- *  for each time it was backed up.
- */
-
-#ifdef HAVE_POSTGRESQL
-const char *uar_jobid_fileindex_from_dir = 
-   "SELECT Job.JobId,File.FileIndex FROM Job,File,Path,Filename,Client "
-   "WHERE Job.JobId IN (%s) "
-   "AND Job.JobId=File.JobId "
-   "AND Path.Path='%s' "
-   "AND Client.Name='%s' "
-   "AND Job.ClientId=Client.ClientId "
-   "AND Path.PathId=File.Pathid "
-   "AND Filename.FilenameId=File.FilenameId"; 
-#else
-const char *uar_jobid_fileindex_from_dir = 
-   "SELECT Job.JobId,File.FileIndex FROM Job,File,Path,Filename,Client "
-   "WHERE Job.JobId IN (%s) "
-   "AND Job.JobId=File.JobId "
-   "AND Path.Path='%s' "
-   "AND Client.Name='%s' "
-   "AND Job.ClientId=Client.ClientId "
-   "AND Path.PathId=File.Pathid "
-   "AND Filename.FilenameId=File.FilenameId "
-   "GROUP BY File.FileIndex ";
-#endif
-/* Query to get list of files from table -- presuably built by an external program */
-const char *uar_jobid_fileindex_from_table = 
-   "SELECT JobId, FileIndex from %s";
index f39d3a5d0644a24052531d31cb72a8eb7ea7006a..420003181749615c7bab29fe493ef43513127473 100644 (file)
@@ -32,7 +32,6 @@
 extern int r_first;
 extern int r_last;
 extern struct s_res resources[];
-extern const char *client_backups;
 
 /* Imported functions */
 extern void do_messages(UAContext *ua, const char *cmd);
index 4e83cc50b7a4dcbc3579aefbfe03eb3c94c2c5d8..39fc3b3989994bf04f2f5f247482047ea4223744 100644 (file)
 
 #define MAX_DEL_LIST_LEN 2000000
 
-/* Imported variables */
-extern const char *select_job;
-extern const char *drop_deltabs[];
-extern const char *create_deltabs[];
-extern const char *insert_delcand;
-extern const char *select_backup_del;
-extern const char *select_verify_del;
-extern const char *select_restore_del;
-extern const char *select_admin_del;
-extern const char *cnt_File;
-extern const char *cnt_DelCand;
-extern const char *del_Job;
-extern const char *del_MAC;
-extern const char *del_JobMedia;
-extern const char *cnt_JobMedia;
-extern const char *sel_JobMedia;
-
-
 /* In memory list of JobIds */
 struct s_file_del_ctx {
    JobId_t *JobId;
index fd4bc81a69423cef897dfc5bfcfb790ea74cc482..f55e63f1099034f82cd16d866d028fb9b39f1fcd 100644 (file)
@@ -28,9 +28,6 @@
 #include "bacula.h"
 #include "dird.h"
 
-extern const char *del_File;
-extern const char *upd_Purged;
-
 /* Forward referenced functions */
 static int purge_files_from_client(UAContext *ua, CLIENT *client);
 static int purge_jobs_from_client(UAContext *ua, CLIENT *client);
index 24d0aba7b7a258c31ef2d994669879cbc88bad57..0ada4cf794c9c26fd9abfc03500afd7448f4aeb0 100644 (file)
 /* Imported functions */
 extern void print_bsr(UAContext *ua, RBSR *bsr);
 
-/* Imported variables */
-extern const char *uar_list_jobs,      *uar_file,        *uar_sel_files;
-extern const char *uar_del_temp,       *uar_del_temp1,   *uar_create_temp;
-extern const char *uar_create_temp1,   *uar_last_full,   *uar_full;
-extern const char *uar_inc,            *uar_list_temp,   *uar_sel_jobid_temp;
-extern const char *uar_sel_all_temp1,  *uar_sel_fileset, *uar_mediatype;
-extern const char *uar_jobid_fileindex, *uar_dif,        *uar_sel_all_temp;
-extern const char *uar_count_files,     *uar_jobids_fileindex;
-extern const char *uar_jobid_fileindex_from_dir;
-extern const char *uar_jobid_fileindex_from_table;
-
 
 
 /* Forward referenced functions */
index 58788a8b9c950f82eb81e347fd41bf97fb986023..c3191e377f33a32483eca16e558222ccbc3ae087 100644 (file)
@@ -25,9 +25,6 @@
 #include "bacula.h"
 #include "dird.h"
 
-/* External variables */
-extern const char *list_pool;               /* in sql_cmds.c */
-
 /* Imported functions */
 void update_slots(UAContext *ua);