-
Notifications
You must be signed in to change notification settings - Fork 256
/
database_export_postgresql.h
63 lines (49 loc) · 2.09 KB
/
database_export_postgresql.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2020-2020 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef BAREOS_SRC_DIRD_DBCOPY_DATABASE_EXPORT_POSTGRESQL_H_
#define BAREOS_SRC_DIRD_DBCOPY_DATABASE_EXPORT_POSTGRESQL_H_
class DatabaseConnection;
class DatabaseTableDescriptions;
class DatabaseExportPostgresql : public DatabaseExport {
public:
DatabaseExportPostgresql(const DatabaseConnection& db_connection,
bool clear_tables = false);
~DatabaseExportPostgresql();
bool StartTable(const std::string& table_name) override;
void EndTable() override;
void CopyStart() override;
void CopyRow(const RowData& data) override;
void CopyEnd() override;
virtual void CompareRow(const RowData& data) override;
public:
struct SequenceSchema {
std::string table_name;
std::string column_name;
std::string sequence_name;
};
using SequenceSchemaVector = std::vector<SequenceSchema>;
private:
bool transaction_{false};
bool start_new_table{false};
SequenceSchemaVector sequence_schema_vector_;
void SelectSequenceSchema();
void CursorStartTable(const std::string& table_name);
bool TableExists(const std::string& table_name);
static int ResultHandlerSequenceSchema(void* ctx, int fields, char** row);
static int ResultHandlerCompare(void* ctx, int fields, char** row);
};
#endif // BAREOS_SRC_DIRD_DBCOPY_DATABASE_EXPORT_POSTGRESQL_H_