]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/bdb_sqlite.h
87f469dc21a1e8481d4abe72837367ec7f260b3c
[bacula/bacula] / bacula / src / cats / bdb_sqlite.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2015 Kern Sibbald
5    Copyright (C) 2009-2014 Free Software Foundation Europe e.V.
6
7    The original author of Bacula is Kern Sibbald, with contributions
8    from many others, a complete list can be found in the file AUTHORS.
9
10    You may use this file and others of this release according to the
11    license defined in the LICENSE file, which includes the Affero General
12    Public License, v3.0 ("AGPLv3") and some additional permissions and
13    terms pursuant to its AGPLv3 Section 7.
14
15    This notice must be preserved when any source code is 
16    conveyed and/or propagated.
17
18    Bacula(R) is a registered trademark of Kern Sibbald.
19 */
20
21 /* SQLite driver specific definitions */
22
23 #ifdef __BDB_SQLITE_H_
24
25 class BDB_SQLITE: public BDB {
26 private:
27    struct sqlite3 *m_db_handle;
28    char **m_result;             /* sql_store_results() and sql_query() */
29    char **m_col_names;          /* used to access fields when using db_sql_query() */
30    char *m_sqlite_errmsg;
31    SQL_FIELD m_sql_field;       /* used when using db_sql_query() and sql_fetch_field() */
32
33 public:
34    BDB_SQLITE();
35    ~BDB_SQLITE();
36
37    /* Used internaly by sqlite.c to access fields in db_sql_query() */
38    void set_column_names(char **res, int nb) {
39       m_col_names = res;
40       m_num_fields = nb;
41       m_field_number = 0;
42    }
43
44    /* Functions that we override */
45    bool bdb_open_database(JCR *jcr);
46    void bdb_close_database(JCR *jcr);
47    void bdb_thread_cleanup(void);
48    void bdb_escape_string(JCR *jcr, char *snew, char *old, int len);
49    char *bdb_escape_object(JCR *jcr, char *old, int len);
50    void bdb_unescape_object(JCR *jcr, char *from, int32_t expected_len,
51                            POOLMEM **dest, int32_t *len);
52    void bdb_start_transaction(JCR *jcr);
53    void bdb_end_transaction(JCR *jcr);
54    bool bdb_sql_query(const char *query, DB_RESULT_HANDLER *result_handler, void *ctx);
55    void sql_free_result(void);
56    SQL_ROW sql_fetch_row(void);
57    bool sql_query(const char *query, int flags=0);
58    const char *sql_strerror(void);
59    int sql_num_rows(void);
60    void sql_data_seek(int row);
61    int sql_affected_rows(void);
62    uint64_t sql_insert_autokey_record(const char *query, const char *table_name);
63    void sql_field_seek(int field);
64    SQL_FIELD *sql_fetch_field(void);
65    int sql_num_fields(void);
66    bool sql_field_is_not_null(int field_type);
67    bool sql_field_is_numeric(int field_type);
68    bool sql_batch_start(JCR *jcr);
69    bool sql_batch_end(JCR *jcr, const char *error);
70    bool sql_batch_insert(JCR *jcr, ATTR_DBR *ar);
71 };
72
73 #endif /* __BDB_SQLITE_H_ */