~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/uuid.cc

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
 
22
 
#include <config.h>
 
22
#include "config.h"
23
23
 
24
24
#include <algorithm>
25
25
 
26
26
#include <uuid/uuid.h>
27
27
 
28
 
#include <drizzled/field/uuid.h>
 
28
#include "drizzled/field/uuid.h"
29
29
 
30
 
#include <drizzled/error.h>
31
 
#include <drizzled/internal/my_sys.h>
32
 
#include <drizzled/session.h>
33
 
#include <drizzled/table.h>
 
30
#include "drizzled/error.h"
 
31
#include "drizzled/internal/my_sys.h"
 
32
#include "drizzled/session.h"
 
33
#include "drizzled/table.h"
 
34
#include "drizzled/temporal.h"
34
35
 
35
36
namespace drizzled
36
37
{
103
104
  res.set_ascii(STRING_WITH_LEN("uuid"));
104
105
}
105
106
 
106
 
double Uuid::val_real() const
 
107
double Uuid::val_real()
107
108
{
108
109
  ASSERT_COLUMN_MARKED_FOR_READ;
109
110
  my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
110
111
  return 0;
111
112
}
112
113
 
113
 
int64_t Uuid::val_int() const
 
114
int64_t Uuid::val_int()
114
115
{
115
116
  ASSERT_COLUMN_MARKED_FOR_READ;
116
117
  my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
133
134
}
134
135
#endif
135
136
 
136
 
String *Uuid::val_str(String *val_buffer, String *) const
 
137
String *Uuid::val_str(String *val_buffer, String *)
137
138
{
138
139
  const CHARSET_INFO * const cs= &my_charset_bin;
139
140
  uint32_t mlength= (type::Uuid::DISPLAY_BUFFER_LENGTH) * cs->mbmaxlen;
158
159
  memcpy(to, ptr, length_arg);
159
160
}
160
161
 
161
 
bool Uuid::get_date(type::Time &ltime, uint32_t ) const
 
162
bool Uuid::get_date(type::Time *ltime, uint32_t )
162
163
{
163
164
  type::Uuid uu;
164
165
 
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(type::Time));
180
191
 
181
192
  return true;
182
193
}
183
194
 
184
 
bool Uuid::get_time(type::Time &ltime) const
 
195
bool Uuid::get_time(type::Time *ltime)
185
196
{
186
197
  return get_date(ltime, 0);
187
198
}