]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/bdb_postgresql.h
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / bacula / src / cats / bdb_postgresql.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2017 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many 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    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19
20 /* Postgresql driver specific definitions */
21
22 #ifdef __BDB_POSTGRESQL_H_
23
24 class BDB_POSTGRESQL: public BDB {
25 private:
26    PGconn *m_db_handle;
27    PGresult *m_result;
28    POOLMEM *m_buf;                /* Buffer to manipulate queries */
29
30 public:
31    BDB_POSTGRESQL();
32    ~BDB_POSTGRESQL();
33
34    /* Functions that we override */
35    bool bdb_open_database(JCR *jcr);
36    void bdb_close_database(JCR *jcr);
37    void bdb_thread_cleanup(void);
38    void bdb_escape_string(JCR *jcr, char *snew, char *old, int len);
39    char *bdb_escape_object(JCR *jcr, char *old, int len);
40    void bdb_unescape_object(JCR *jcr, char *from, int32_t expected_len,
41                            POOLMEM **dest, int32_t *len);
42    void bdb_start_transaction(JCR *jcr);
43    void bdb_end_transaction(JCR *jcr);
44    bool bdb_sql_query(const char *query, DB_RESULT_HANDLER *result_handler, void *ctx);
45    bool bdb_big_sql_query(const char *query, DB_RESULT_HANDLER *result_handler, void *ctx);
46    void sql_free_result(void);
47    SQL_ROW sql_fetch_row(void);
48    bool sql_query(const char *query, int flags=0);
49    const char *sql_strerror(void);
50    int sql_num_rows(void);
51    void sql_data_seek(int row);
52    int sql_affected_rows(void);
53    uint64_t sql_insert_autokey_record(const char *query, const char *table_name);
54    void sql_field_seek(int field);
55    SQL_FIELD *sql_fetch_field(void);
56    int sql_num_fields(void);
57    bool sql_field_is_not_null(int field_type);
58    bool sql_field_is_numeric(int field_type);
59    bool sql_batch_start(JCR *jcr);
60    bool sql_batch_end(JCR *jcr, const char *error);
61    bool sql_batch_insert(JCR *jcr, ATTR_DBR *ar);
62 };
63
64 #endif /* __BDB_POSTGRESQL_H_ */