1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
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; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include <drizzled/show.h>
24
#include <drizzled/session.h>
25
#include <drizzled/db.h>
26
#include <drizzled/plugin/event_observer.h>
27
#include <drizzled/message.h>
29
#include "drizzled/message/table.pb.h"
30
#include "drizzled/message/schema.pb.h"
37
static const std::string PROGRAM_ERROR("PROGRAM_ERROR");
39
// These are used to generate strings for types
40
static const std::string VARCHAR("VARCHAR");
41
static const std::string VARBINARY("VARBINARY");
42
static const std::string DOUBLE("DOUBLE");
43
static const std::string TEXT("TEXT");
44
static const std::string BLOB("BLOB");
45
static const std::string ENUM("ENUM");
46
static const std::string INTEGER("INTEGER");
47
static const std::string BIGINT("BIGINT");
48
static const std::string DECIMAL("DECIMAL");
49
static const std::string DATE("DATE");
50
static const std::string EPOCH("EPOCH");
51
static const std::string TIMESTAMP("TIMESTAMP");
52
static const std::string MICROTIME("MICROTIME");
53
static const std::string DATETIME("DATETIME");
54
static const std::string TIME("TIME");
55
static const std::string UUID("UUID");
56
static const std::string BOOLEAN("BOOLEAN");
58
static const std::string UNDEFINED("UNDEFINED");
59
static const std::string RESTRICT("RESTRICT");
60
static const std::string CASCADE("CASCADE");
61
static const std::string SET_NULL("SET NULL");
62
static const std::string NO_ACTION("NO ACTION");
63
static const std::string SET_DEFAULT("SET DEFAULT");
65
static const std::string YES("YES");
66
static const std::string NO("NO");
68
static const std::string UNKNOWN_INDEX("UNKNOWN_INDEX");
69
static const std::string BTREE("BTREE");
70
static const std::string RTREE("RTREE");
71
static const std::string HASH("HASH");
72
static const std::string FULLTEXT("FULLTEXT");
74
static const std::string MATCH_FULL("FULL");
75
static const std::string MATCH_PARTIAL("PARTIAL");
76
static const std::string MATCH_SIMPLE("SIMPLE");
78
void update(drizzled::message::Schema &arg)
80
arg.set_version(arg.version() + 1);
81
arg.set_update_timestamp(time(NULL));
84
void update(drizzled::message::Table &arg)
86
arg.set_version(arg.version() + 1);
87
arg.set_update_timestamp(time(NULL));
90
bool is_numeric(const message::Table::Field &field)
92
message::Table::Field::FieldType type= field.type();
96
case message::Table::Field::DOUBLE:
97
case message::Table::Field::INTEGER:
98
case message::Table::Field::BIGINT:
99
case message::Table::Field::DECIMAL:
101
case message::Table::Field::BLOB:
102
case message::Table::Field::VARCHAR:
103
case message::Table::Field::ENUM:
104
case message::Table::Field::DATE:
105
case message::Table::Field::EPOCH:
106
case message::Table::Field::DATETIME:
107
case message::Table::Field::TIME:
108
case message::Table::Field::UUID:
109
case message::Table::Field::BOOLEAN:
116
const std::string &type(const message::Table::Field &field)
118
message::Table::Field::FieldType type= field.type();
122
case message::Table::Field::VARCHAR:
123
return field.string_options().collation().compare("binary") ? VARCHAR : VARBINARY;
124
case message::Table::Field::DOUBLE:
126
case message::Table::Field::BLOB:
127
return field.string_options().collation().compare("binary") ? TEXT : BLOB;
128
case message::Table::Field::ENUM:
130
case message::Table::Field::INTEGER:
132
case message::Table::Field::BIGINT:
134
case message::Table::Field::DECIMAL:
136
case message::Table::Field::DATE:
138
case message::Table::Field::EPOCH:
140
case message::Table::Field::DATETIME:
142
case message::Table::Field::TIME:
144
case message::Table::Field::UUID:
146
case message::Table::Field::BOOLEAN:
153
const std::string &type(drizzled::message::Table::Field::FieldType type)
157
case message::Table::Field::VARCHAR:
159
case message::Table::Field::DOUBLE:
161
case message::Table::Field::BLOB:
163
case message::Table::Field::ENUM:
165
case message::Table::Field::INTEGER:
167
case message::Table::Field::BIGINT:
169
case message::Table::Field::DECIMAL:
171
case message::Table::Field::DATE:
173
case message::Table::Field::EPOCH:
175
case message::Table::Field::DATETIME:
177
case message::Table::Field::TIME:
179
case message::Table::Field::UUID:
181
case message::Table::Field::BOOLEAN:
188
const std::string &type(drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption type)
192
case message::Table::ForeignKeyConstraint::OPTION_RESTRICT:
194
case message::Table::ForeignKeyConstraint::OPTION_CASCADE:
196
case message::Table::ForeignKeyConstraint::OPTION_SET_NULL:
198
case message::Table::ForeignKeyConstraint::OPTION_UNDEF:
199
case message::Table::ForeignKeyConstraint::OPTION_NO_ACTION:
201
case message::Table::ForeignKeyConstraint::OPTION_SET_DEFAULT:
208
// This matches SQL standard of using YES/NO not the normal TRUE/FALSE
209
const std::string &type(bool type)
211
return type ? YES : NO;
214
const std::string &type(drizzled::message::Table::Index::IndexType type)
218
case message::Table::Index::UNKNOWN_INDEX:
219
return UNKNOWN_INDEX;
220
case message::Table::Index::BTREE:
222
case message::Table::Index::RTREE:
224
case message::Table::Index::HASH:
226
case message::Table::Index::FULLTEXT:
231
return PROGRAM_ERROR;
234
const std::string &type(drizzled::message::Table::ForeignKeyConstraint::ForeignKeyMatchOption type)
238
case message::Table::ForeignKeyConstraint::MATCH_FULL:
240
case message::Table::ForeignKeyConstraint::MATCH_PARTIAL:
241
return MATCH_PARTIAL;
242
case message::Table::ForeignKeyConstraint::MATCH_UNDEFINED:
243
case message::Table::ForeignKeyConstraint::MATCH_SIMPLE:
251
std::ostream& operator<<(std::ostream& output, const message::Transaction &message)
255
google::protobuf::TextFormat::PrintToString(message, &buffer);
261
std::ostream& operator<<(std::ostream& output, const message::Table &message)
265
google::protobuf::TextFormat::PrintToString(message, &buffer);
273
} /* namespace message */
274
} /* namespace drizzled */