~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/int64_t.cc

  • Committer: Brian Aker
  • Date: 2010-12-07 09:12:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1985.
  • Revision ID: brian@tangent.org-20101207091212-1m0w20tck6z7632m
This is a fix for bug lp:686197

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
 
22
22
#include "config.h"
23
 
#include <drizzled/field/int64.h>
 
23
#include <drizzled/field/int64_t.h>
24
24
#include <drizzled/error.h>
25
25
#include <drizzled/table.h>
26
26
#include <drizzled/session.h>
35
35
namespace drizzled
36
36
{
37
37
 
38
 
namespace field
39
 
{
40
 
 
41
38
/****************************************************************************
42
 
  Field type Int64 int (8 bytes)
43
 
 ****************************************************************************/
 
39
 Field type int64_t int (8 bytes)
 
40
****************************************************************************/
44
41
 
45
 
int Int64::store(const char *from,uint32_t len, const CHARSET_INFO * const cs)
 
42
int Field_int64_t::store(const char *from,uint32_t len, const CHARSET_INFO * const cs)
46
43
{
47
44
  int error= 0;
48
45
  char *end;
73
70
}
74
71
 
75
72
 
76
 
int Int64::store(double nr)
 
73
int Field_int64_t::store(double nr)
77
74
{
78
75
  int error= 0;
79
76
  int64_t res;
110
107
}
111
108
 
112
109
 
113
 
int Int64::store(int64_t nr, bool )
 
110
int Field_int64_t::store(int64_t nr, bool )
114
111
{
115
112
  int error= 0;
116
113
 
128
125
}
129
126
 
130
127
 
131
 
double Int64::val_real(void)
 
128
double Field_int64_t::val_real(void)
132
129
{
133
130
  int64_t j;
134
131
 
147
144
}
148
145
 
149
146
 
150
 
int64_t Int64::val_int(void)
 
147
int64_t Field_int64_t::val_int(void)
151
148
{
152
149
  int64_t j;
153
150
 
163
160
}
164
161
 
165
162
 
166
 
String *Int64::val_str(String *val_buffer,
167
 
                       String *)
 
163
String *Field_int64_t::val_str(String *val_buffer,
 
164
                                String *)
168
165
{
169
166
  const CHARSET_INFO * const cs= &my_charset_bin;
170
167
  uint32_t length;
188
185
  return val_buffer;
189
186
}
190
187
 
191
 
int Int64::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
 
188
int Field_int64_t::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
192
189
{
193
190
  int64_t a,b;
194
191
#ifdef WORDS_BIGENDIAN
206
203
  return (a < b) ? -1 : (a > b) ? 1 : 0;
207
204
}
208
205
 
209
 
void Int64::sort_string(unsigned char *to,uint32_t )
 
206
void Field_int64_t::sort_string(unsigned char *to,uint32_t )
210
207
{
211
208
#ifdef WORDS_BIGENDIAN
212
209
  if (!getTable()->getShare()->db_low_byte_first)
235
232
}
236
233
 
237
234
 
238
 
void Int64::sql_type(String &res) const
 
235
void Field_int64_t::sql_type(String &res) const
239
236
{
240
237
  const CHARSET_INFO * const cs=res.charset();
241
238
  res.length(cs->cset->snprintf(cs,(char*) res.ptr(),res.alloced_length(), "bigint"));
242
239
}
243
240
 
244
241
 
245
 
unsigned char *Int64::pack(unsigned char* to, const unsigned char *from,
246
 
                           uint32_t,
 
242
unsigned char *Field_int64_t::pack(unsigned char* to, const unsigned char *from,
 
243
                                         uint32_t,
247
244
#ifdef WORDS_BIGENDIAN
248
 
                           bool low_byte_first
 
245
                                         bool low_byte_first
249
246
#else
250
 
                           bool
 
247
                                         bool
251
248
#endif
252
 
                          )
 
249
)
253
250
{
254
251
  int64_t val;
255
252
#ifdef WORDS_BIGENDIAN
256
253
  if (getTable()->getShare()->db_low_byte_first)
257
 
    val = sint8korr(from);
 
254
     val = sint8korr(from);
258
255
  else
259
256
#endif
260
257
    int64_tget(val, from);
269
266
}
270
267
 
271
268
 
272
 
const unsigned char *Int64::unpack(unsigned char* to, const unsigned char *from, uint32_t,
 
269
const unsigned char *Field_int64_t::unpack(unsigned char* to, const unsigned char *from, uint32_t,
273
270
#ifdef WORDS_BIGENDIAN
274
 
                                   bool low_byte_first
 
271
                                           bool low_byte_first
275
272
#else
276
 
                                   bool
 
273
                                           bool
277
274
#endif
278
 
                                  )
 
275
)
279
276
{
280
277
  int64_t val;
281
278
#ifdef WORDS_BIGENDIAN
294
291
  return from + sizeof(val);
295
292
}
296
293
 
297
 
} /* namespace field */
298
294
} /* namespace drizzled */