~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/my_decimal.cc

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

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