2 Bacula® - The Network Backup Solution
4 Copyright (C) 2009-2011 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version three of the GNU Affero General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
25 The licensor of Bacula is the Free Software Foundation Europe
26 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
27 Switzerland, email:ftf@fsfeurope.org.
30 * Bacula Glue code for the catalog refactoring.
32 * Written by Marco van Wieringen, November 2009
37 #if HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL || HAVE_INGRES || HAVE_DBI
43 /* -----------------------------------------------------------------------
45 * Generic Glue Routines
47 * -----------------------------------------------------------------------
49 bool db_match_database(B_DB *mdb, const char *db_driver, const char *db_name,
50 const char *db_address, int db_port)
52 return mdb->db_match_database(db_driver, db_name, db_address, db_port);
55 B_DB *db_clone_database_connection(B_DB *mdb, JCR *jcr, bool mult_db_connections)
57 return mdb->db_clone_database_connection(jcr, mult_db_connections);
60 const char *db_get_type(B_DB *mdb)
62 return mdb->db_get_type();
65 int db_get_type_index(B_DB *mdb)
67 return mdb->db_get_type_index();
70 bool db_open_database(JCR *jcr, B_DB *mdb)
72 return mdb->db_open_database(jcr);
75 void db_close_database(JCR *jcr, B_DB *mdb)
78 mdb->db_close_database(jcr);
82 void db_thread_cleanup(B_DB *mdb)
84 mdb->db_thread_cleanup();
87 void db_escape_string(JCR *jcr, B_DB *mdb, char *snew, char *old, int len)
89 mdb->db_escape_string(jcr, snew, old, len);
92 char *db_escape_object(JCR *jcr, B_DB *mdb, char *old, int len)
94 return mdb->db_escape_object(jcr, old, len);
97 void db_unescape_object(JCR *jcr, B_DB *mdb,
98 char *from, int32_t expected_len,
99 POOLMEM **dest, int32_t *len)
101 mdb->db_unescape_object(jcr, from, expected_len, dest, len);
104 void db_start_transaction(JCR *jcr, B_DB *mdb)
106 mdb->db_start_transaction(jcr);
109 void db_end_transaction(JCR *jcr, B_DB *mdb)
111 mdb->db_end_transaction(jcr);
114 bool db_sql_query(B_DB *mdb, const char *query, int flags)
116 return mdb->db_sql_query(query, flags);
119 bool db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
121 return mdb->db_sql_query(query, result_handler, ctx);
124 bool db_big_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
126 return mdb->db_big_sql_query(query, result_handler, ctx);
129 void sql_free_result(B_DB *mdb)
131 ((B_DB_PRIV *)mdb)->sql_free_result();
134 SQL_ROW sql_fetch_row(B_DB *mdb)
136 return ((B_DB_PRIV *)mdb)->sql_fetch_row();
139 bool sql_query(B_DB *mdb, const char *query, int flags)
141 return ((B_DB_PRIV *)mdb)->sql_query(query, flags);
144 const char *sql_strerror(B_DB *mdb)
146 return ((B_DB_PRIV *)mdb)->sql_strerror();
149 int sql_num_rows(B_DB *mdb)
151 return ((B_DB_PRIV *)mdb)->sql_num_rows();
154 void sql_data_seek(B_DB *mdb, int row)
156 ((B_DB_PRIV *)mdb)->sql_data_seek(row);
159 int sql_affected_rows(B_DB *mdb)
161 return ((B_DB_PRIV *)mdb)->sql_affected_rows();
164 uint64_t sql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name)
166 return ((B_DB_PRIV *)mdb)->sql_insert_autokey_record(query, table_name);
169 void sql_field_seek(B_DB *mdb, int field)
171 ((B_DB_PRIV *)mdb)->sql_field_seek(field);
174 SQL_FIELD *sql_fetch_field(B_DB *mdb)
176 return ((B_DB_PRIV *)mdb)->sql_fetch_field();
179 int sql_num_fields(B_DB *mdb)
181 return ((B_DB_PRIV *)mdb)->sql_num_fields();
184 bool sql_field_is_not_null(B_DB *mdb, int field_type)
186 return ((B_DB_PRIV *)mdb)->sql_field_is_not_null(field_type);
189 bool sql_field_is_numeric(B_DB *mdb, int field_type)
191 return ((B_DB_PRIV *)mdb)->sql_field_is_numeric(field_type);
194 bool sql_batch_start(JCR *jcr, B_DB *mdb)
196 return ((B_DB_PRIV *)mdb)->sql_batch_start(jcr);
199 bool sql_batch_end(JCR *jcr, B_DB *mdb, const char *error)
201 return ((B_DB_PRIV *)mdb)->sql_batch_end(jcr, error);
204 bool sql_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
206 return ((B_DB_PRIV *)mdb)->sql_batch_insert(jcr, ar);
209 #endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL || HAVE_INGRES || HAVE_DBI */