~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/uuid.cc

  • Committer: Brian Aker
  • Date: 2011-01-25 07:22:15 UTC
  • mfrom: (2109.1.7 drizzle-build)
  • Revision ID: brian@tangent.org-20110125072215-567z6uzy5vdvn4va
Merge in build/timestamp patches/fixes.

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