~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message.cc

  • Committer: Lee Bieber
  • Date: 2010-12-23 23:11:00 UTC
  • mfrom: (2024.1.1 clean)
  • Revision ID: kalebral@gmail.com-20101223231100-0rqirgz7ugkl10yp
Merge Brian - session list cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "drizzled/message/schema.pb.h"
31
31
 
32
32
#include <string>
 
33
#include <uuid/uuid.h>
33
34
 
34
35
namespace drizzled {
35
36
namespace message {
49
50
static const std::string DATE("DATE");
50
51
static const std::string EPOCH("EPOCH");
51
52
static const std::string TIMESTAMP("TIMESTAMP");
52
 
static const std::string MICROTIME("MICROTIME");
53
53
static const std::string DATETIME("DATETIME");
54
54
static const std::string TIME("TIME");
55
55
static const std::string UUID("UUID");
56
 
static const std::string BOOLEAN("BOOLEAN");
57
56
 
58
57
static const std::string UNDEFINED("UNDEFINED");
59
58
static const std::string RESTRICT("RESTRICT");
75
74
static const std::string MATCH_PARTIAL("PARTIAL");
76
75
static const std::string MATCH_SIMPLE("SIMPLE");
77
76
 
78
 
const static std::string STANDARD_STRING("STANDARD");
79
 
const static std::string TEMPORARY_STRING("TEMPORARY");
80
 
const static std::string INTERNAL_STRING("INTERNAL");
81
 
const static std::string FUNCTION_STRING("FUNCTION");
 
77
void init(drizzled::message::Table &arg, const std::string &name_arg, const std::string &schema_arg, const std::string &engine_arg)
 
78
{
 
79
  arg.set_name(name_arg);
 
80
  arg.set_schema(schema_arg);
 
81
  arg.set_creation_timestamp(time(NULL));
 
82
  arg.set_update_timestamp(time(NULL));
 
83
  arg.mutable_engine()->set_name(engine_arg);
 
84
 
 
85
  /* 36 characters for uuid string +1 for NULL */
 
86
  uuid_t uu;
 
87
  char uuid_string[37];
 
88
  uuid_generate_random(uu);
 
89
  uuid_unparse(uu, uuid_string);
 
90
  arg.set_uuid(uuid_string, 36);
 
91
 
 
92
  arg.set_version(1);
 
93
}
 
94
 
 
95
void init(drizzled::message::Schema &arg, const std::string &name_arg)
 
96
{
 
97
  arg.set_name(name_arg);
 
98
  arg.mutable_engine()->set_name(std::string("filesystem")); // For the moment we have only one.
 
99
  if (not arg.has_collation())
 
100
  {
 
101
    arg.set_collation(default_charset_info->name);
 
102
  }
 
103
 
 
104
  /* 36 characters for uuid string +1 for NULL */
 
105
  uuid_t uu;
 
106
  char uuid_string[37];
 
107
  uuid_generate_random(uu);
 
108
  uuid_unparse(uu, uuid_string);
 
109
  arg.set_uuid(uuid_string, 36);
 
110
 
 
111
  arg.set_version(1);
 
112
}
82
113
 
83
114
void update(drizzled::message::Schema &arg)
84
115
{
111
142
  case message::Table::Field::DATETIME:
112
143
  case message::Table::Field::TIME:
113
144
  case message::Table::Field::UUID:
114
 
  case message::Table::Field::BOOLEAN:
115
145
    break;
116
146
  }
117
147
 
148
178
    return TIME;
149
179
  case message::Table::Field::UUID:
150
180
    return UUID;
151
 
  case message::Table::Field::BOOLEAN:
152
 
    return BOOLEAN;
153
181
  }
154
182
 
155
183
  abort();
183
211
    return TIME;
184
212
  case message::Table::Field::UUID:
185
213
    return UUID;
186
 
  case message::Table::Field::BOOLEAN:
187
 
    return BOOLEAN;
188
214
  }
189
215
 
190
216
  abort();
252
278
  return MATCH_SIMPLE;
253
279
}
254
280
 
255
 
const std::string &type(drizzled::message::Table::TableType type)
256
 
{
257
 
  switch (type)
258
 
  {
259
 
  case message::Table::STANDARD:
260
 
    return STANDARD_STRING;
261
 
  case message::Table::TEMPORARY:
262
 
    return TEMPORARY_STRING;
263
 
  case message::Table::INTERNAL:
264
 
    return INTERNAL_STRING;
265
 
  case message::Table::FUNCTION:
266
 
    return FUNCTION_STRING;
267
 
  }
268
 
 
269
 
  assert(0);
270
 
  return PROGRAM_ERROR;
271
 
}
272
 
 
273
281
#if 0
274
282
std::ostream& operator<<(std::ostream& output, const message::Transaction &message)
275
283