~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/my_decimal.cc

  • Committer: Brian Aker
  • Date: 2009-10-16 10:27:33 UTC
  • mfrom: (1183.1.4 merge)
  • Revision ID: brian@gaz-20091016102733-b10po5oup0hjlilh
MergeĀ EngineĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include <drizzled/server_includes.h>
 
17
#include <drizzled/current_session.h>
17
18
#include <time.h>
18
 
#include <drizzled/drizzled_error_messages.h>
19
 
 
20
 
 
21
 
#ifndef DRIZZLE_CLIENT
 
19
#include <drizzled/error.h>
 
20
 
 
21
 
22
22
/**
23
23
  report result of decimal operation.
24
24
 
37
37
  case E_DEC_OK:
38
38
    break;
39
39
  case E_DEC_TRUNCATED:
40
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
40
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
41
41
                        ER_WARN_DATA_TRUNCATED, ER(ER_WARN_DATA_TRUNCATED),
42
42
                        "", (long)-1);
43
43
    break;
44
44
  case E_DEC_OVERFLOW:
45
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
45
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
46
46
                        ER_TRUNCATED_WRONG_VALUE,
47
47
                        ER(ER_TRUNCATED_WRONG_VALUE),
48
48
                        "DECIMAL", "");
49
49
    break;
50
50
  case E_DEC_DIV_ZERO:
51
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
51
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
52
52
                        ER_DIVISION_BY_ZERO, ER(ER_DIVISION_BY_ZERO));
53
53
    break;
54
54
  case E_DEC_BAD_NUM:
55
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
55
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
56
56
                        ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
57
57
                        ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
58
58
                        "decimal", "", "", (long)-1);
86
86
    @retval E_DEC_OOM
87
87
*/
88
88
 
89
 
int my_decimal2string(uint mask, const my_decimal *d,
90
 
                      uint fixed_prec, uint fixed_dec,
 
89
int my_decimal2string(uint32_t mask, const my_decimal *d,
 
90
                      uint32_t fixed_prec, uint32_t fixed_dec,
91
91
                      char filler, String *str)
92
92
{
93
93
  /*
136
136
    E_DEC_OVERFLOW
137
137
*/
138
138
 
139
 
int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec,
 
139
int my_decimal2binary(uint32_t mask, const my_decimal *d, unsigned char *bin, int prec,
140
140
                      int scale)
141
141
{
142
142
  int err1= E_DEC_OK, err2;
175
175
    E_DEC_OOM
176
176
*/
177
177
 
178
 
int str2my_decimal(uint mask, const char *from, uint length,
 
178
int str2my_decimal(uint32_t mask, const char *from, uint32_t length,
179
179
                   const CHARSET_INFO * charset, my_decimal *decimal_value)
180
180
{
181
181
  char *end, *from_end;
184
184
  String tmp(buff, sizeof(buff), &my_charset_bin);
185
185
  if (charset->mbminlen > 1)
186
186
  {
187
 
    uint dummy_errors;
188
 
    tmp.copy(from, length, charset, &my_charset_latin1, &dummy_errors);
 
187
    uint32_t dummy_errors;
 
188
    tmp.copy(from, length, charset, &my_charset_utf8_general_ci, &dummy_errors);
189
189
    from= tmp.ptr();
190
190
    length=  tmp.length();
191
191
    charset= &my_charset_bin;
197
197
    /* Give warning if there is something other than end space */
198
198
    for ( ; end < from_end; end++)
199
199
    {
200
 
      if (!my_isspace(&my_charset_latin1, *end))
 
200
      if (!my_isspace(&my_charset_utf8_general_ci, *end))
201
201
      {
202
202
        err= E_DEC_TRUNCATED;
203
203
        break;
226
226
}
227
227
 
228
228
 
229
 
void my_decimal_trim(uint32_t *precision, uint *scale)
 
229
void my_decimal_trim(uint32_t *precision, uint32_t *scale)
230
230
{
231
231
  if (!(*precision) && !(*scale))
232
232
  {
235
235
    return;
236
236
  }
237
237
}
238
 
 
239
 
 
240
 
/* routines for debugging print */
241
 
#define DIG_PER_DEC1 9
242
 
#define ROUND_UP(X)  (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
243
 
 
244
 
#endif /*DRIZZLE_CLIENT*/