]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/sql_glue.c
Update version date
[bacula/bacula] / bacula / src / cats / sql_glue.c
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2009-2011 Free Software Foundation Europe e.V.
5
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
11    in the file LICENSE.
12
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.
17
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
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24
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.
28 */
29 /*
30  * Bacula Glue code for the catalog refactoring.
31  *
32  * Written by Marco van Wieringen, November 2009
33  */
34
35 #include "bacula.h"
36
37 #if HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL || HAVE_INGRES || HAVE_DBI
38
39 #include "cats.h"
40 #include "bdb_priv.h"
41 #include "sql_glue.h"
42
43 /* -----------------------------------------------------------------------
44  *
45  *   Generic Glue Routines
46  *
47  * -----------------------------------------------------------------------
48  */
49 bool db_match_database(B_DB *mdb, const char *db_driver, const char *db_name,
50                        const char *db_address, int db_port)
51 {
52    return mdb->db_match_database(db_driver, db_name, db_address, db_port);
53 }
54
55 B_DB *db_clone_database_connection(B_DB *mdb, JCR *jcr, bool mult_db_connections)
56 {
57    return mdb->db_clone_database_connection(jcr, mult_db_connections);
58 }
59
60 const char *db_get_type(B_DB *mdb)
61 {
62    return mdb->db_get_type();
63 }
64
65 int db_get_type_index(B_DB *mdb)
66 {
67    return mdb->db_get_type_index();
68 }
69
70 bool db_open_database(JCR *jcr, B_DB *mdb)
71 {
72    return mdb->db_open_database(jcr);
73 }
74
75 void db_close_database(JCR *jcr, B_DB *mdb)
76 {
77    if (mdb) {
78       mdb->db_close_database(jcr);
79    }
80 }
81
82 void db_thread_cleanup(B_DB *mdb)
83 {
84    mdb->db_thread_cleanup();
85 }
86
87 void db_escape_string(JCR *jcr, B_DB *mdb, char *snew, char *old, int len)
88 {
89    mdb->db_escape_string(jcr, snew, old, len);
90 }
91
92 char *db_escape_object(JCR *jcr, B_DB *mdb, char *old, int len)
93 {
94    return mdb->db_escape_object(jcr, old, len);
95 }
96
97 void db_unescape_object(JCR *jcr, B_DB *mdb, 
98                         char *from, int32_t expected_len, 
99                         POOLMEM **dest, int32_t *len)
100 {
101    mdb->db_unescape_object(jcr, from, expected_len, dest, len);
102 }
103
104 void db_start_transaction(JCR *jcr, B_DB *mdb)
105 {
106    mdb->db_start_transaction(jcr);
107 }
108
109 void db_end_transaction(JCR *jcr, B_DB *mdb)
110 {
111    mdb->db_end_transaction(jcr);
112 }
113
114 bool db_sql_query(B_DB *mdb, const char *query, int flags)
115 {
116    return mdb->db_sql_query(query, flags);
117 }
118
119 bool db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
120 {
121    return mdb->db_sql_query(query, result_handler, ctx);
122 }
123
124 bool db_big_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
125 {
126    return mdb->db_big_sql_query(query, result_handler, ctx);
127 }
128
129 void sql_free_result(B_DB *mdb)
130 {
131    ((B_DB_PRIV *)mdb)->sql_free_result();
132 }
133
134 SQL_ROW sql_fetch_row(B_DB *mdb)
135 {
136    return ((B_DB_PRIV *)mdb)->sql_fetch_row();
137 }
138
139 bool sql_query(B_DB *mdb, const char *query, int flags)
140 {
141    return ((B_DB_PRIV *)mdb)->sql_query(query, flags);
142 }
143
144 const char *sql_strerror(B_DB *mdb)
145 {
146    return ((B_DB_PRIV *)mdb)->sql_strerror();
147 }
148
149 int sql_num_rows(B_DB *mdb)
150 {
151    return ((B_DB_PRIV *)mdb)->sql_num_rows();
152 }
153
154 void sql_data_seek(B_DB *mdb, int row)
155 {
156    ((B_DB_PRIV *)mdb)->sql_data_seek(row);
157 }
158
159 int sql_affected_rows(B_DB *mdb)
160 {
161    return ((B_DB_PRIV *)mdb)->sql_affected_rows();
162 }
163
164 uint64_t sql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name)
165 {
166    return ((B_DB_PRIV *)mdb)->sql_insert_autokey_record(query, table_name);
167 }
168
169 void sql_field_seek(B_DB *mdb, int field)
170 {
171    ((B_DB_PRIV *)mdb)->sql_field_seek(field);
172 }
173
174 SQL_FIELD *sql_fetch_field(B_DB *mdb)
175 {
176    return ((B_DB_PRIV *)mdb)->sql_fetch_field();
177 }
178
179 int sql_num_fields(B_DB *mdb)
180 {
181    return ((B_DB_PRIV *)mdb)->sql_num_fields();
182 }
183
184 bool sql_field_is_not_null(B_DB *mdb, int field_type)
185 {
186    return ((B_DB_PRIV *)mdb)->sql_field_is_not_null(field_type);
187 }
188
189 bool sql_field_is_numeric(B_DB *mdb, int field_type)
190 {
191    return ((B_DB_PRIV *)mdb)->sql_field_is_numeric(field_type);
192 }
193
194 bool sql_batch_start(JCR *jcr, B_DB *mdb)
195 {
196    return ((B_DB_PRIV *)mdb)->sql_batch_start(jcr);
197 }
198
199 bool sql_batch_end(JCR *jcr, B_DB *mdb, const char *error)
200 {
201    return ((B_DB_PRIV *)mdb)->sql_batch_end(jcr, error);
202 }
203
204 bool sql_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
205 {
206    return ((B_DB_PRIV *)mdb)->sql_batch_insert(jcr, ar);
207 }
208
209 #endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL || HAVE_INGRES || HAVE_DBI */