~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/num.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-07-22 23:26:26 UTC
  • mto: (1039.5.43 replication)
  • mto: This revision was merged to the branch mainline in revision 1130.
  • Revision ID: osullivan.padraig@gmail.com-20090722232626-mu4khq7ho6dqcf7q
Created a simple filtered replicator that can filter by schema name or table
name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
 
22
 
#include "config.h"
 
22
#include <drizzled/server_includes.h>
23
23
#include <drizzled/field/num.h>
24
24
#include <drizzled/error.h>
25
25
#include <drizzled/table.h>
26
26
#include <drizzled/session.h>
27
 
#include "drizzled/internal/my_sys.h"
28
 
 
29
 
namespace drizzled
30
 
{
31
27
 
32
28
/**
33
29
  Numeric fields base class constructor.
34
30
*/
35
 
Field_num::Field_num(unsigned char *ptr_arg,
36
 
                     uint32_t len_arg,
37
 
                     unsigned char *null_ptr_arg,
38
 
                     unsigned char null_bit_arg,
39
 
                     utype unireg_check_arg,
 
31
Field_num::Field_num(unsigned char *ptr_arg,uint32_t len_arg, unsigned char *null_ptr_arg,
 
32
                     unsigned char null_bit_arg, utype unireg_check_arg,
40
33
                     const char *field_name_arg,
41
 
                     uint8_t dec_arg,
42
 
                     bool zero_arg,
43
 
                     bool unsigned_arg) :
44
 
  Field(ptr_arg,
45
 
        len_arg,
46
 
        null_ptr_arg,
47
 
        null_bit_arg,
48
 
        unireg_check_arg,
49
 
        field_name_arg),
50
 
  dec(dec_arg),
51
 
  decimal_precision(zero_arg),
52
 
  unsigned_flag(unsigned_arg)
53
 
  {
 
34
                     uint8_t dec_arg, bool zero_arg, bool unsigned_arg)
 
35
  :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
 
36
         unireg_check_arg, field_name_arg),
 
37
  dec(dec_arg),decimal_precision(zero_arg), unsigned_flag(unsigned_arg)
 
38
{
54
39
}
55
40
 
56
41
 
85
70
    char buff[128];
86
71
    String tmp(buff, (uint32_t) sizeof(buff), system_charset_info);
87
72
    tmp.copy(str, length, system_charset_info);
88
 
    push_warning_printf(getTable()->in_use, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
73
    push_warning_printf(table->in_use, DRIZZLE_ERROR::WARN_LEVEL_WARN,
89
74
                        ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
90
75
                        ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
91
76
                        "integer", tmp.c_ptr(), field_name,
92
 
                        (uint32_t) getTable()->in_use->row_count);
 
77
                        (uint32_t) table->in_use->row_count);
93
78
    return 1;
94
79
  }
95
80
  /* Test if we have garbage at the end of the given string. */
143
128
    goto out_of_range;
144
129
  }
145
130
 
146
 
  if (getTable()->in_use->count_cuted_fields &&
 
131
  if (table->in_use->count_cuted_fields &&
147
132
      check_int(cs, from, len, end, error))
148
133
    return 1;
149
 
 
150
134
  return 0;
151
135
 
152
136
out_of_range:
168
152
    !=0  error
169
153
*/
170
154
 
171
 
int Field_num::store_decimal(const type::Decimal *val)
 
155
int Field_num::store_decimal(const my_decimal *val)
172
156
{
173
157
  int err= 0;
174
158
  int64_t i= convert_decimal2int64_t(val, false, &err);
189
173
    pointer to decimal buffer with value of field
190
174
*/
191
175
 
192
 
type::Decimal* Field_num::val_decimal(type::Decimal *decimal_value)
 
176
my_decimal* Field_num::val_decimal(my_decimal *decimal_value)
193
177
{
194
178
  assert(result_type() == INT_RESULT);
195
179
 
196
180
  int64_t nr= val_int();
197
 
  int2_class_decimal(E_DEC_FATAL_ERROR, nr, false, decimal_value);
 
181
  int2my_decimal(E_DEC_FATAL_ERROR, nr, false, decimal_value);
198
182
  return decimal_value;
199
183
}
200
184
 
231
215
}
232
216
 
233
217
 
234
 
} /* namespace drizzled */