13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <drizzled/server_includes.h>
16
#include "mysql_priv.h"
18
#include <drizzled/drizzled_error_messages.h>
22
22
report result of decimal operation.
38
38
case E_DEC_TRUNCATED:
39
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
40
ER_WARN_DATA_TRUNCATED, ER(ER_WARN_DATA_TRUNCATED),
39
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
40
WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED),
43
43
case E_DEC_OVERFLOW:
44
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
44
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
45
45
ER_TRUNCATED_WRONG_VALUE,
46
46
ER(ER_TRUNCATED_WRONG_VALUE),
49
49
case E_DEC_DIV_ZERO:
50
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
50
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
51
51
ER_DIVISION_BY_ZERO, ER(ER_DIVISION_BY_ZERO));
53
53
case E_DEC_BAD_NUM:
54
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
54
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
55
55
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
56
56
ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
57
57
"decimal", "", "", (long)-1);
88
int my_decimal2string(uint32_t mask, const my_decimal *d,
89
uint32_t fixed_prec, uint32_t fixed_dec,
88
int my_decimal2string(uint mask, const my_decimal *d,
89
uint fixed_prec, uint fixed_dec,
90
90
char filler, String *str)
138
int my_decimal2binary(uint32_t mask, const my_decimal *d, unsigned char *bin, int prec,
138
int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec,
141
141
int err1= E_DEC_OK, err2;
177
int str2my_decimal(uint32_t mask, const char *from, uint32_t length,
178
const CHARSET_INFO * charset, my_decimal *decimal_value)
177
int str2my_decimal(uint mask, const char *from, uint length,
178
CHARSET_INFO *charset, my_decimal *decimal_value)
180
180
char *end, *from_end;
183
183
String tmp(buff, sizeof(buff), &my_charset_bin);
184
184
if (charset->mbminlen > 1)
186
uint32_t dummy_errors;
187
tmp.copy(from, length, charset, &my_charset_utf8_general_ci, &dummy_errors);
187
tmp.copy(from, length, charset, &my_charset_latin1, &dummy_errors);
189
189
length= tmp.length();
190
190
charset= &my_charset_bin;
196
196
/* Give warning if there is something other than end space */
197
197
for ( ; end < from_end; end++)
199
if (!my_isspace(&my_charset_utf8_general_ci, *end))
199
if (!my_isspace(&my_charset_latin1, *end))
201
201
err= E_DEC_TRUNCATED;
211
my_decimal *date2my_decimal(DRIZZLE_TIME *ltime, my_decimal *dec)
211
my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec)
214
214
date = (ltime->year*100L + ltime->month)*100L + ltime->day;
215
if (ltime->time_type > DRIZZLE_TIMESTAMP_DATE)
215
if (ltime->time_type > MYSQL_TIMESTAMP_DATE)
216
216
date= ((date*100L + ltime->hour)*100L+ ltime->minute)*100L + ltime->second;
217
217
if (int2my_decimal(E_DEC_FATAL_ERROR, date, false, dec))