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_DATA_H
21
#define CLIENT_DRIZZLEDUMP_DATA_H
23
#define DRIZZLE_MAX_LINE_LENGTH 1024*1024L-1025
24
#include "client_priv.h"
31
class DrizzleDumpDatabase;
32
class DrizzleDumpData;
34
class DrizzleDumpIndex
37
std::string indexName;
39
DrizzleDumpIndex(std::string &index) :
43
virtual ~DrizzleDumpIndex() { }
49
std::vector<std::string> columns;
50
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpIndex &obj);
53
class DrizzleDumpField
56
DrizzleDumpField(std::string &field) :
60
virtual ~DrizzleDumpField() { }
62
std::stringstream errmsg;
64
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpField &obj);
65
std::string fieldName;
74
std::string defaultValue;
75
std::string collation;
78
std::string enumValues;
80
/* For decimal/double */
81
uint32_t decimalPrecision;
82
uint32_t decimalScale;
84
virtual void setType(const char*, const char*) { }
88
class DrizzleDumpTable
91
DrizzleDumpTable(std::string &table) :
95
virtual ~DrizzleDumpTable() { }
97
std::stringstream errmsg;
99
virtual bool populateFields() { return false; }
100
virtual bool populateIndexes() { return false; }
101
virtual DrizzleDumpData* getData() { return NULL; }
102
std::vector<DrizzleDumpField*> fields;
103
std::vector<DrizzleDumpIndex*> indexes;
105
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpTable &obj);
106
std::string tableName;
107
std::string engineName;
110
// Currently MySQL only, hard to do in Drizzle
111
uint64_t autoIncrement;
112
DrizzleDumpDatabase* database;
115
class DrizzleDumpDatabase
118
DrizzleDumpDatabase(const std::string &database) :
119
databaseName(database)
122
virtual ~DrizzleDumpDatabase() { }
124
std::stringstream errmsg;
126
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpDatabase &obj);
128
virtual bool populateTables() { return false; }
129
virtual void setCollate(const char*) { }
130
std::vector<DrizzleDumpTable*> tables;
132
const std::string databaseName;
136
class DrizzleDumpData
139
std::stringstream errmsg;
140
DrizzleDumpTable *table;
141
drizzle_result_st *result;
142
DrizzleDumpData(DrizzleDumpTable *dataTable) :
146
virtual ~DrizzleDumpData() { }
147
friend std::ostream& operator <<(std::ostream &os, const DrizzleDumpData &obj);
149
virtual std::ostream& checkDateTime(std::ostream &os, const char*, uint32_t) const { return os; }
150
std::string convertHex(const char* from, size_t from_size) const;
151
std::string escape(const char* from, size_t from_size) const;
154
#endif /* CLIENT_DRIZZLEDUMP_DATA_H */