1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2009-2011 Free Software Foundation Europe e.V. 5 Copyright (C) 2016-2016 Planets Communications B.V. 6 Copyright (C) 2016-2016 Bareos GmbH & Co. KG 7 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 Affero 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 #ifndef BAREOS_CATS_BDB_POSTGRESQL_H_ 24 #define BAREOS_CATS_BDB_POSTGRESQL_H_ 1 25 26 class BareosDbPostgresql: public BareosDbPrivateInterface { 27 private: 28 /* 29 * Members. 30 */ 31 PGconn *db_handle_; 32 PGresult *result_; 33 POOLMEM *buf_; /**< Buffer to manipulate queries */ 34 static const char *query_definitions[]; /**< table of predefined sql queries */ 35 36 private: 37 /* 38 * Methods. 39 */ 40 bool OpenDatabase(JobControlRecord *jcr) override; 41 void CloseDatabase(JobControlRecord *jcr) override; 42 bool ValidateConnection(void) override; 43 void EscapeString(JobControlRecord *jcr, char *snew, char *old, int len) override; 44 char *EscapeObject(JobControlRecord *jcr, char *old, int len) override; 45 void UnescapeObject(JobControlRecord *jcr, char *from, int32_t expected_len, POOLMEM *&dest, int32_t *len) override; 46 void StartTransaction(JobControlRecord *jcr) override; 47 void EndTransaction(JobControlRecord *jcr) override; 48 bool BigSqlQuery(const char *query, DB_RESULT_HANDLER *ResultHandler, void *ctx) override; 49 bool SqlQueryWithHandler(const char *query, DB_RESULT_HANDLER *ResultHandler, void *ctx) override; 50 bool SqlQueryWithoutHandler(const char *query, int flags = 0) override; 51 void SqlFreeResult(void) override; 52 SQL_ROW SqlFetchRow(void) override; 53 const char *sql_strerror(void) override; 54 void SqlDataSeek(int row) override; 55 int SqlAffectedRows(void) override; 56 uint64_t SqlInsertAutokeyRecord(const char *query, const char *table_name) override; 57 SQL_FIELD *SqlFetchField(void) override; 58 bool SqlFieldIsNotNull(int field_type) override; 59 bool SqlFieldIsNumeric(int field_type) override; 60 bool SqlBatchStart(JobControlRecord *jcr) override; 61 bool SqlBatchEnd(JobControlRecord *jcr, const char *error) override; 62 bool SqlBatchInsert(JobControlRecord *jcr, AttributesDbRecord *ar) override; 63 64 bool CheckDatabaseEncoding(JobControlRecord *jcr); 65 66 public: 67 /* 68 * Methods. 69 */ 70 BareosDbPostgresql(JobControlRecord *jcr, 71 const char *db_driver, 72 const char *db_name, 73 const char *db_user, 74 const char *db_password, 75 const char *db_address, 76 int db_port, 77 const char *db_socket, 78 bool mult_db_connections, 79 bool disable_batch_insert, 80 bool try_reconnect, 81 bool exit_on_fatal, 82 bool need_private 83 ); 84 ~BareosDbPostgresql(); 85 }; 86 87 #endif /* BAREOS_CATS_BDB_POSTGRESQL_H_ */ 88