~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/uuid.cc

  • Committer: Monty Taylor
  • Date: 2010-12-26 03:15:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101226031544-1cf3raipu53fnmyj
Through page.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "drizzled/internal/my_sys.h"
32
32
#include "drizzled/session.h"
33
33
#include "drizzled/table.h"
 
34
#include "drizzled/temporal.h"
34
35
 
35
36
namespace drizzled
36
37
{
59
60
int Uuid::store(const char *from, uint32_t length, const CHARSET_INFO * const )
60
61
{
61
62
  ASSERT_COLUMN_MARKED_FOR_WRITE;
62
 
  type::Uuid uu;
 
63
  uuid_st uu;
63
64
 
64
65
  if (is_set)
65
66
  {
67
68
    return 0;
68
69
  }
69
70
 
70
 
  if (length != type::Uuid::DISPLAY_LENGTH)
 
71
  if (length != uuid_st::DISPLAY_LENGTH)
71
72
  {
72
73
    my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
73
74
    return 1;
91
92
  return 1;
92
93
}
93
94
 
94
 
int Uuid::store_decimal(const drizzled::type::Decimal*)
 
95
int Uuid::store_decimal(const drizzled::my_decimal*)
95
96
{
96
97
  ASSERT_COLUMN_MARKED_FOR_WRITE;
97
98
  my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
136
137
String *Uuid::val_str(String *val_buffer, String *)
137
138
{
138
139
  const CHARSET_INFO * const cs= &my_charset_bin;
139
 
  uint32_t mlength= (type::Uuid::DISPLAY_BUFFER_LENGTH) * cs->mbmaxlen;
140
 
  type::Uuid uu;
 
140
  uint32_t mlength= (uuid_st::DISPLAY_BUFFER_LENGTH) * cs->mbmaxlen;
 
141
  uuid_st uu;
141
142
 
142
143
  val_buffer->alloc(mlength);
143
144
  char *buffer=(char*) val_buffer->ptr();
147
148
  uu.unpack(ptr);
148
149
  uu.unparse(buffer);
149
150
 
150
 
  val_buffer->length(type::Uuid::DISPLAY_LENGTH);
 
151
  val_buffer->length(uuid_st::DISPLAY_LENGTH);
151
152
 
152
153
  return val_buffer;
153
154
}
154
155
 
155
156
void Uuid::sort_string(unsigned char *to, uint32_t length_arg)
156
157
{
157
 
  assert(length_arg == type::Uuid::LENGTH);
 
158
  assert(length_arg == uuid_st::LENGTH);
158
159
  memcpy(to, ptr, length_arg);
159
160
}
160
161
 
161
 
bool Uuid::get_date(type::Time &ltime, uint32_t )
 
162
bool Uuid::get_date(DRIZZLE_TIME *ltime, uint32_t )
162
163
{
163
 
  type::Uuid uu;
 
164
  uuid_st uu;
164
165
 
165
166
  uu.unpack(ptr);
166
167
 
167
168
  if (uu.isTimeType())
168
169
  {
 
170
    Timestamp temporal;
169
171
    struct timeval ret_tv;
170
172
 
171
 
    memset(&ret_tv, 0, sizeof(struct timeval));
 
173
    ret_tv.tv_sec= ret_tv.tv_usec= 0;
172
174
 
173
175
    uu.time(ret_tv);
174
176
 
175
 
    ltime.store(ret_tv);
 
177
    temporal.from_time_t(ret_tv.tv_sec);
 
178
 
 
179
    ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
 
180
    ltime->year= temporal.years();
 
181
    ltime->month= temporal.months();
 
182
    ltime->day= temporal.days();
 
183
    ltime->hour= temporal.hours();
 
184
    ltime->minute= temporal.minutes();
 
185
    ltime->second= temporal.seconds();
 
186
    ltime->second_part= temporal.nseconds();
176
187
 
177
188
    return false;
178
189
  }
179
 
  ltime.reset();
 
190
  memset(ltime, 0, sizeof(DRIZZLE_TIME));
180
191
 
181
192
  return true;
182
193
}
183
194
 
184
 
bool Uuid::get_time(type::Time &ltime)
 
195
bool Uuid::get_time(DRIZZLE_TIME *ltime)
185
196
{
186
197
  return get_date(ltime, 0);
187
198
}