~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message.cc

  • Committer: Brian Aker
  • Date: 2011-01-06 05:17:09 UTC
  • Revision ID: brian@tangent.org-20110106051709-oa0se8ur02uc6i9o
Added native functions into the function table.

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");
75
75
static const std::string MATCH_PARTIAL("PARTIAL");
76
76
static const std::string MATCH_SIMPLE("SIMPLE");
77
77
 
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");
 
78
void init(drizzled::message::Table &arg, const std::string &name_arg, const std::string &schema_arg, const std::string &engine_arg)
 
79
{
 
80
  arg.set_name(name_arg);
 
81
  arg.set_schema(schema_arg);
 
82
  arg.set_creation_timestamp(time(NULL));
 
83
  arg.set_update_timestamp(time(NULL));
 
84
  arg.mutable_engine()->set_name(engine_arg);
 
85
 
 
86
  /* 36 characters for uuid string +1 for NULL */
 
87
  uuid_t uu;
 
88
  char uuid_string[37];
 
89
  uuid_generate_random(uu);
 
90
  uuid_unparse(uu, uuid_string);
 
91
  arg.set_uuid(uuid_string, 36);
 
92
 
 
93
  arg.set_version(1);
 
94
}
 
95
 
 
96
void init(drizzled::message::Schema &arg, const std::string &name_arg)
 
97
{
 
98
  arg.set_name(name_arg);
 
99
  arg.mutable_engine()->set_name(std::string("filesystem")); // For the moment we have only one.
 
100
  if (not arg.has_collation())
 
101
  {
 
102
    arg.set_collation(default_charset_info->name);
 
103
  }
 
104
 
 
105
  /* 36 characters for uuid string +1 for NULL */
 
106
  uuid_t uu;
 
107
  char uuid_string[37];
 
108
  uuid_generate_random(uu);
 
109
  uuid_unparse(uu, uuid_string);
 
110
  arg.set_uuid(uuid_string, 36);
 
111
 
 
112
  arg.set_version(1);
 
113
}
82
114
 
83
115
void update(drizzled::message::Schema &arg)
84
116
{
252
284
  return MATCH_SIMPLE;
253
285
}
254
286
 
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
287
#if 0
274
288
std::ostream& operator<<(std::ostream& output, const message::Transaction &message)
275
289