]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/bdb_priv.h
Backport from BEE
[bacula/bacula] / bacula / src / cats / bdb_priv.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2011-2014 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from many
7    others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    Bacula® is a registered trademark of Kern Sibbald.
15 */
16 #ifndef __BDB_PRIV_H_
17 #define __BDB_PRIV_H_ 1
18
19 #ifndef _BDB_PRIV_INTERFACE_
20 #error "Illegal inclusion of catalog private interface"
21 #endif
22
23 /*
24  * Generic definition of a sql_row.
25  */
26 typedef char **SQL_ROW;
27
28 /*
29  * Generic definition of a a sql_field.
30  */
31 typedef struct sql_field {
32    char *name;                        /* name of column */
33    int max_length;                    /* max length */
34    uint32_t type;                     /* type */
35    uint32_t flags;                    /* flags */
36 } SQL_FIELD;
37
38 class B_DB_PRIV: public B_DB {
39 protected:
40    int m_status;                      /* status */
41    int m_num_rows;                    /* number of rows returned by last query */
42    int m_num_fields;                  /* number of fields returned by last query */
43    int m_rows_size;                   /* size of malloced rows */
44    int m_fields_size;                 /* size of malloced fields */
45    int m_row_number;                  /* row number from xx_data_seek */
46    int m_field_number;                /* field number from sql_field_seek */
47    SQL_ROW m_rows;                    /* defined rows */
48    SQL_FIELD *m_fields;               /* defined fields */
49    bool m_allow_transactions;         /* transactions allowed */
50    bool m_transaction;                /* transaction started */
51
52 public:
53    /* methods */
54    B_DB_PRIV() {};
55    virtual ~B_DB_PRIV() {};
56
57    int sql_num_rows(void) { return m_num_rows; };
58    void sql_field_seek(int field) { m_field_number = field; };
59    int sql_num_fields(void) { return m_num_fields; };
60    virtual void sql_free_result(void) = 0;
61    virtual SQL_ROW sql_fetch_row(void) = 0;
62    virtual bool sql_query(const char *query, int flags=0) = 0;
63    virtual const char *sql_strerror(void) = 0;
64    virtual void sql_data_seek(int row) = 0;
65    virtual int sql_affected_rows(void) = 0;
66    virtual uint64_t sql_insert_autokey_record(const char *query, const char *table_name) = 0;
67    virtual SQL_FIELD *sql_fetch_field(void) = 0;
68    virtual bool sql_field_is_not_null(int field_type) = 0;
69    virtual bool sql_field_is_numeric(int field_type) = 0;
70    virtual bool sql_batch_start(JCR *jcr) = 0;
71    virtual bool sql_batch_end(JCR *jcr, const char *error) = 0;
72    virtual bool sql_batch_insert(JCR *jcr, ATTR_DBR *ar) = 0;
73 };
74
75 #endif /* __BDB_PRIV_H_ */