1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Andrew Hutchings
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef CLIENT_DRIZZLEDUMP_H
21
#define CLIENT_DRIZZLEDUMP_H
23
class DrizzleDumpDatabase;
25
class DrizzleDumpIndex
28
std::string indexName;
30
DrizzleDumpIndex(std::string &index) :
44
std::vector<std::string> columns;
45
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpIndex &obj);
48
class DrizzleDumpField
51
std::stringstream errmsg;
53
DrizzleDumpField(std::string &field) :
57
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpField &obj);
58
std::string fieldName;
67
std::string defaultValue;
68
std::string collation;
71
std::string enumValues;
73
/* For decimal/double */
74
uint32_t decimalPrecision;
75
uint32_t decimalScale;
77
void dateTimeConvert(const char* oldDefault);
78
void setCollate(const char* newCollate);
79
void setType(const char* raw_type, const char* collation);
82
class DrizzleDumpTable
85
std::stringstream errmsg;
87
DrizzleDumpTable(std::string &table) :
97
bool populateFields(drizzle_con_st &connection);
98
bool populateIndexes(drizzle_con_st &connection);
99
std::vector<DrizzleDumpField*> fields;
100
std::vector<DrizzleDumpIndex*> indexes;
102
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpTable &obj);
103
std::string tableName;
104
std::string engineName;
107
void setCollate(const char* newCollate);
108
void setEngine(const char* newEngine);
110
// Currently MySQL only, hard to do in Drizzle
111
uint64_t autoIncrement;
112
DrizzleDumpDatabase* database;
115
class DrizzleDumpDatabase
118
std::stringstream errmsg;
120
DrizzleDumpDatabase(const std::string &database) :
121
databaseName(database)
124
~DrizzleDumpDatabase()
129
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpDatabase &obj);
131
bool populateTables(drizzle_con_st &connection);
132
std::vector<DrizzleDumpTable*> tables;
134
void setCollate(const char* newCollate);
135
const std::string databaseName;
139
class DrizzleDumpData
141
DrizzleDumpTable *table;
142
drizzle_con_st *connection;
143
std::stringstream errmsg;
144
drizzle_result_st *result;
147
DrizzleDumpData(drizzle_con_st &conn, DrizzleDumpTable *dataTable);
149
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpData &obj);
151
/* For 0000-00-00 -> NULL conversion */
152
std::string convertDate(const char* oldDate) const;
153
/* For xx:xx:xx -> INT conversion */
154
long convertTime(const char* oldTime) const;
155
std::string convertHex(const char* from, size_t from_size) const;
156
std::string escape(const char* from, size_t from_size) const;
159
#endif /* CLIENT_DRIZZLEDUMP_H */