~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message.cc

  • Committer: Monty Taylor
  • Date: 2010-10-12 20:20:44 UTC
  • mto: (1842.1.3 build) (1843.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1843.
  • Revision ID: mordred@inaugust.com-20101012202044-yfrmnmkznvkqfxe4
Added support for valgrind suppressions.
Run strip-valgrind as part of make valgrind.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include "drizzled/message/table.pb.h"
30
30
#include "drizzled/message/schema.pb.h"
31
 
 
32
 
#include <string>
33
31
#include <uuid/uuid.h>
34
32
 
35
33
namespace drizzled {
36
34
namespace message {
37
35
 
38
 
static const std::string PROGRAM_ERROR("PROGRAM_ERROR");
39
 
 
40
 
// These are used to generate strings for types
41
 
static const std::string VARCHAR("VARCHAR");
42
 
static const std::string DOUBLE("DOUBLE");
43
 
static const std::string BLOB("BLOB");
44
 
static const std::string ENUM("ENUM");
45
 
static const std::string INTEGER("INTEGER");
46
 
static const std::string BIGINT("BIGINT");
47
 
static const std::string DECIMAL("DECIMAL");
48
 
static const std::string DATE("DATE");
49
 
static const std::string TIMESTAMP("TIMESTAMP");
50
 
static const std::string DATETIME("DATETIME");
51
 
static const std::string UUID("UUID");
52
 
 
53
 
static const std::string UNDEFINED("UNDEFINED");
54
 
static const std::string RESTRICT("RESTRICT");
55
 
static const std::string CASCADE("CASCADE");
56
 
static const std::string SET_NULL("SET NULL");
57
 
static const std::string NO_ACTION("NO ACTION");
58
 
static const std::string SET_DEFAULT("SET DEFAULT");
59
 
 
60
 
static const std::string YES("YES");
61
 
static const std::string NO("NO");
62
 
 
63
 
static const std::string UNKNOWN_INDEX("UNKNOWN_INDEX");
64
 
static const std::string BTREE("BTREE");
65
 
static const std::string RTREE("RTREE");
66
 
static const std::string HASH("HASH");
67
 
static const std::string FULLTEXT("FULLTEXT");
68
 
 
69
 
static const std::string MATCH_FULL("FULL");
70
 
static const std::string MATCH_PARTIAL("PARTIAL");
71
 
static const std::string MATCH_SIMPLE("SIMPLE");
72
 
 
73
36
void init(drizzled::message::Table &arg, const std::string &name_arg, const std::string &schema_arg, const std::string &engine_arg)
74
37
{
75
38
  arg.set_name(name_arg);
119
82
  arg.set_update_timestamp(time(NULL));
120
83
}
121
84
 
122
 
const std::string &type(drizzled::message::Table::Field::FieldType type)
123
 
{
124
 
  switch (type)
125
 
  {
126
 
  case message::Table::Field::VARCHAR:
127
 
    return VARCHAR;
128
 
  case message::Table::Field::DOUBLE:
129
 
    return DOUBLE;
130
 
  case message::Table::Field::BLOB:
131
 
    return BLOB;
132
 
  case message::Table::Field::ENUM:
133
 
    return ENUM;
134
 
  case message::Table::Field::INTEGER:
135
 
    return INTEGER;
136
 
  case message::Table::Field::BIGINT:
137
 
    return BIGINT;
138
 
  case message::Table::Field::DECIMAL:
139
 
    return DECIMAL;
140
 
  case message::Table::Field::DATE:
141
 
    return DATE;
142
 
  case message::Table::Field::TIMESTAMP:
143
 
    return TIMESTAMP;
144
 
  case message::Table::Field::DATETIME:
145
 
    return DATETIME;
146
 
  case message::Table::Field::UUID:
147
 
    return UUID;
148
 
  }
149
 
 
150
 
  assert(0);
151
 
  return PROGRAM_ERROR;
152
 
}
153
 
 
154
 
const std::string &type(drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption type)
155
 
{
156
 
  switch (type)
157
 
  {
158
 
  case message::Table::ForeignKeyConstraint::OPTION_RESTRICT:
159
 
    return RESTRICT;
160
 
  case message::Table::ForeignKeyConstraint::OPTION_CASCADE:
161
 
    return CASCADE;
162
 
  case message::Table::ForeignKeyConstraint::OPTION_SET_NULL:
163
 
    return SET_NULL;
164
 
  case message::Table::ForeignKeyConstraint::OPTION_UNDEF:
165
 
  case message::Table::ForeignKeyConstraint::OPTION_NO_ACTION:
166
 
    return NO_ACTION;
167
 
  case message::Table::ForeignKeyConstraint::OPTION_SET_DEFAULT:
168
 
    return SET_DEFAULT;
169
 
  }
170
 
 
171
 
  return NO_ACTION;
172
 
}
173
 
 
174
 
// This matches SQL standard of using YES/NO not the normal TRUE/FALSE
175
 
const std::string &type(bool type)
176
 
{
177
 
  return type ? YES : NO;
178
 
}
179
 
 
180
 
const std::string &type(drizzled::message::Table::Index::IndexType type)
181
 
{
182
 
  switch (type)
183
 
  {
184
 
  case message::Table::Index::UNKNOWN_INDEX:
185
 
    return UNKNOWN_INDEX;
186
 
  case message::Table::Index::BTREE:
187
 
    return BTREE;
188
 
  case message::Table::Index::RTREE:
189
 
    return RTREE;
190
 
  case message::Table::Index::HASH:
191
 
    return HASH;
192
 
  case message::Table::Index::FULLTEXT:
193
 
    return FULLTEXT;
194
 
  }
195
 
 
196
 
  assert(0);
197
 
  return PROGRAM_ERROR;
198
 
}
199
 
 
200
 
const std::string &type(drizzled::message::Table::ForeignKeyConstraint::ForeignKeyMatchOption type)
201
 
{
202
 
  switch (type)
203
 
  {
204
 
  case message::Table::ForeignKeyConstraint::MATCH_FULL:
205
 
    return MATCH_FULL;
206
 
  case message::Table::ForeignKeyConstraint::MATCH_PARTIAL:
207
 
    return MATCH_PARTIAL;
208
 
  case message::Table::ForeignKeyConstraint::MATCH_UNDEFINED:
209
 
  case message::Table::ForeignKeyConstraint::MATCH_SIMPLE:
210
 
    return MATCH_SIMPLE;
211
 
  }
212
 
 
213
 
  return MATCH_SIMPLE;
214
 
}
215
 
 
216
 
#if 0
217
 
std::ostream& operator<<(std::ostream& output, const message::Transaction &message)
218
 
219
 
    std::string buffer;
220
 
 
221
 
    google::protobuf::TextFormat::PrintToString(message, &buffer);
222
 
    output << buffer;
223
 
 
224
 
    return output;
225
 
}
226
 
 
227
 
std::ostream& operator<<(std::ostream& output, const message::Table &message)
228
 
229
 
  std::string buffer;
230
 
 
231
 
  google::protobuf::TextFormat::PrintToString(message, &buffer);
232
 
  output << buffer;
233
 
 
234
 
  return output;
235
 
}
236
 
#endif
237
 
 
238
 
 
239
85
} /* namespace message */
240
86
} /* namespace drizzled */