24
24
#include <algorithm>
26
#include "drizzled/field/boolean.h"
26
#include <drizzled/field/boolean.h>
27
#include <drizzled/type/boolean.h>
28
#include "drizzled/error.h"
29
#include "drizzled/internal/my_sys.h"
30
#include "drizzled/session.h"
31
#include "drizzled/table.h"
32
#include "drizzled/temporal.h"
29
#include <drizzled/error.h>
30
#include <drizzled/internal/my_sys.h>
31
#include <drizzled/session.h>
32
#include <drizzled/table.h>
33
#include <drizzled/temporal.h>
35
36
unsigned char byte;
71
74
ASSERT_COLUMN_MARKED_FOR_WRITE;
78
case 't': case 'T': // PG compatibility
83
case 'f': case 'F': // PG compatibility
88
my_error(ER_INVALID_BOOLEAN_VALUE, MYF(0), from);
92
else if ((length == 5) and (strcasecmp(from, "FALSE") == 0))
96
if ((length == 4) and (strcasecmp(from, "TRUE") == 0))
100
else if ((length == 5) and (strcasecmp(from, "FALSE") == 0))
104
else if ((length == 3) and (strcasecmp(from, "YES") == 0))
108
else if ((length == 2) and (strcasecmp(from, "NO") == 0))
77
if (not type::convert(result, from, length))
114
79
my_error(ER_INVALID_BOOLEAN_VALUE, MYF(0), from);
151
125
res.set_ascii(STRING_WITH_LEN("boolean"));
154
double Boolean::val_real()
156
ASSERT_COLUMN_MARKED_FOR_READ;
160
int64_t Boolean::val_int()
162
ASSERT_COLUMN_MARKED_FOR_READ;
166
String *Boolean::val_str(String *val_buffer, String *)
168
ASSERT_COLUMN_MARKED_FOR_READ;
169
const CHARSET_INFO * const cs= &my_charset_bin;
170
uint32_t mlength= (5) * cs->mbmaxlen;
172
val_buffer->alloc(mlength);
173
char *buffer=(char*) val_buffer->c_ptr();
179
memcpy(buffer, "YES", 3);
180
val_buffer->length(3);
184
memcpy(buffer, "TRUE", 4);
185
val_buffer->length(4);
192
memcpy(buffer, "NO", 2);
193
val_buffer->length(2);
197
memcpy(buffer, "FALSE", 5);
198
val_buffer->length(5);
128
double Boolean::val_real() const
130
ASSERT_COLUMN_MARKED_FOR_READ;
134
int64_t Boolean::val_int() const
136
ASSERT_COLUMN_MARKED_FOR_READ;
140
String *Boolean::val_str(String *val_buffer, String *) const
142
ASSERT_COLUMN_MARKED_FOR_READ;
144
(void)type::convert(*val_buffer, isTrue(), ansi_display);
202
146
return val_buffer;
205
type::Decimal *Boolean::val_decimal(type::Decimal *dec)
149
type::Decimal *Boolean::val_decimal(type::Decimal *dec) const