~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/fdecimal.cc

  • Committer: Monty Taylor
  • Date: 2008-10-22 21:31:15 UTC
  • Revision ID: monty@inaugust.com-20081022213115-xuxc80r939tl88p1
Renamed drizzle_common again. Removed sql_common. (empty) 
Now all we need to do is merge/disect base.h, common.h, common_includes.h, server_includes.h and globa.h (good grief)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifdef USE_PRAGMA_IMPLEMENTATION
22
 
#pragma implementation                          // gcc: Class implementation
23
 
#endif
24
21
 
25
22
#include <drizzled/server_includes.h>
26
23
#include <drizzled/field/fdecimal.h>
85
82
{
86
83
  max_my_decimal(decimal_value, precision, decimals());
87
84
  if (sign)
88
 
  {
89
 
    if (unsigned_flag)
90
 
      my_decimal_set_zero(decimal_value);
91
 
    else
92
 
      decimal_value->sign(true);
93
 
  }
 
85
    decimal_value->sign(true);
 
86
 
94
87
  return;
95
88
}
96
89
 
114
107
{
115
108
  int error= 0;
116
109
 
117
 
  /* check that we do not try to write negative value in unsigned field */
118
 
  if (unsigned_flag && decimal_value->sign())
119
 
  {
120
 
    set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
121
 
    error= 1;
122
 
    decimal_value= &decimal_zero;
123
 
  }
124
 
 
125
110
  if (warn_if_overflow(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
126
111
                                         decimal_value, ptr, precision, dec)))
127
112
  {
265
250
{
266
251
  int64_t i;
267
252
  my_decimal decimal_value;
268
 
  my_decimal2int(E_DEC_FATAL_ERROR, val_decimal(&decimal_value),
269
 
                 unsigned_flag, &i);
 
253
  my_decimal2int(E_DEC_FATAL_ERROR, val_decimal(&decimal_value), false, &i);
270
254
  return i;
271
255
}
272
256
 
308
292
  const CHARSET_INFO * const cs= str.charset();
309
293
  str.length(cs->cset->snprintf(cs, (char*) str.ptr(), str.alloced_length(),
310
294
                                "decimal(%d,%d)", precision, (int)dec));
311
 
  add_unsigned(str);
312
295
}
313
296
 
314
297