2 * Bacula Catalog Database Get record interface routines
3 * Note, these routines generally get a record by id or
4 * by name. If more logic is involved, the routine
7 * Bacula Catalog Database routines written specifically
8 * for Bacula. Note, these routines are VERY dumb and
9 * do not provide all the functionality of an SQL database.
10 * The purpose of these routines is to ensure that Bacula
11 * can limp along if no real database is loaded on the
14 * Kern Sibbald, January MMI
19 Bacula® - The Network Backup Solution
21 Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
23 The main author of Bacula is Kern Sibbald, with contributions from
24 many others, a complete list can be found in the file AUTHORS.
25 This program is Free Software; you can redistribute it and/or
26 modify it under the terms of version two of the GNU General Public
27 License as published by the Free Software Foundation and included
30 This program is distributed in the hope that it will be useful, but
31 WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 General Public License for more details.
35 You should have received a copy of the GNU General Public License
36 along with this program; if not, write to the Free Software
37 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
40 Bacula® is a registered trademark of Kern Sibbald.
41 The licensor of Bacula is the Free Software Foundation Europe
42 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
43 Switzerland, email:ftf@fsfeurope.org.
47 /* The following is necessary so that we do not include
48 * the dummy external definition of DB.
50 #define __SQL_C /* indicate that this is sql.c */
58 /* Forward referenced functions */
61 /* -----------------------------------------------------------------------
63 * Bacula specific defines and subroutines
65 * -----------------------------------------------------------------------
70 * Get Job record for given JobId
71 * Returns: 0 on failure
75 bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
82 * Get the number of pool records
84 * Returns: -1 on failure
87 int db_get_num_pool_records(JCR *jcr, B_DB *mdb)
93 * This function returns a list of all the Pool record ids.
94 * The caller must free ids if non-NULL.
96 * Returns 0: on failure
99 int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
107 * If the PoolId is non-zero, we get its record,
108 * otherwise, we search on the PoolName
110 * Returns: false on failure
113 bool db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
119 * Get the number of Media records
121 * Returns: -1 on failure
124 int db_get_num_media_records(JCR *jcr, B_DB *mdb)
130 * This function returns a list of all the Media record ids
131 * for a specified PoolId
132 * The caller must free ids if non-NULL.
134 * Returns false: on failure
137 bool db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_t *ids[])
144 * If the MediaId is non-zero, we get its record,
145 * otherwise, we search on the MediaName
147 * Returns: false on failure
150 bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
156 * Find VolumeNames for a give JobId
157 * Returns: 0 on error or no Volumes found
158 * number of volumes on success
159 * Volumes are concatenated in VolumeNames
160 * separated by a vertical bar (|).
162 int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **VolumeNames)
169 * If the ClientId is non-zero, we get its record,
170 * otherwise, we search on the Name
172 * Returns: 0 on failure
175 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
181 * Get FileSet Record (We read the FILESET_DBR structure)
182 * If the FileSetId is non-zero, we get its record,
183 * otherwise, we search on the FileSet (its name).
185 * Returns: 0 on failure
188 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
193 bool db_get_query_dbids(JCR *jcr, B_DB *mdb, POOL_MEM &query, dbid_list &ids)
196 int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, FILE_DBR *fdbr)
199 int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS **VolParams)
202 int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
205 int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
209 #endif /* HAVE_BACULA_DB */