mirror of
https://github.com/MariaDB/server.git
synced 2026-05-07 07:35:32 +02:00
5.5-merge
This commit is contained in:
commit
9809f05199
3220 changed files with 98728 additions and 426290 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2005-2006 MySQL AB
|
||||
/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -62,7 +62,7 @@ typedef struct st_mysql_time MYSQL_TIME;
|
|||
|
||||
/**
|
||||
maximum length of string representation (number of maximum decimal
|
||||
digits + 1 position for sign + 1 position for decimal point)
|
||||
digits + 1 position for sign + 1 position for decimal point, no terminator)
|
||||
*/
|
||||
#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
|
||||
|
||||
|
|
@ -102,6 +102,24 @@ class my_decimal :public decimal_t
|
|||
|
||||
public:
|
||||
|
||||
my_decimal(const my_decimal &rhs) : decimal_t(rhs)
|
||||
{
|
||||
for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++)
|
||||
buffer[i]= rhs.buffer[i];
|
||||
fix_buffer_pointer();
|
||||
}
|
||||
|
||||
my_decimal& operator=(const my_decimal &rhs)
|
||||
{
|
||||
if (this == &rhs)
|
||||
return *this;
|
||||
decimal_t::operator=(rhs);
|
||||
for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++)
|
||||
buffer[i]= rhs.buffer[i];
|
||||
fix_buffer_pointer();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
len= DECIMAL_BUFF_LENGTH;
|
||||
|
|
@ -160,7 +178,7 @@ void max_my_decimal(my_decimal *to, int precision, int frac)
|
|||
{
|
||||
DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION)&&
|
||||
(frac <= DECIMAL_MAX_SCALE));
|
||||
max_decimal(precision, frac, (decimal_t*) to);
|
||||
max_decimal(precision, frac, to);
|
||||
}
|
||||
|
||||
inline void max_internal_decimal(my_decimal *to)
|
||||
|
|
@ -225,6 +243,7 @@ inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale,
|
|||
inline
|
||||
int my_decimal_string_length(const my_decimal *d)
|
||||
{
|
||||
/* length of string representation including terminating '\0' */
|
||||
return decimal_string_size(d);
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +267,6 @@ inline
|
|||
void my_decimal2decimal(const my_decimal *from, my_decimal *to)
|
||||
{
|
||||
*to= *from;
|
||||
to->fix_buffer_pointer();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -260,14 +278,19 @@ inline
|
|||
int binary2my_decimal(uint mask, const uchar *bin, my_decimal *d, int prec,
|
||||
int scale)
|
||||
{
|
||||
return check_result(mask, bin2decimal(bin, (decimal_t*) d, prec, scale));
|
||||
return check_result(mask, bin2decimal(bin, d, prec, scale));
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
int my_decimal_set_zero(my_decimal *d)
|
||||
{
|
||||
decimal_make_zero(((decimal_t*) d));
|
||||
/*
|
||||
We need the up-cast here, since my_decimal has sign() member functions,
|
||||
which conflicts with decimal_t::size
|
||||
(and decimal_make_zero is a macro, rather than a funcion).
|
||||
*/
|
||||
decimal_make_zero(static_cast<decimal_t*>(d));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +298,7 @@ int my_decimal_set_zero(my_decimal *d)
|
|||
inline
|
||||
bool my_decimal_is_zero(const my_decimal *decimal_value)
|
||||
{
|
||||
return decimal_is_zero((decimal_t*) decimal_value);
|
||||
return decimal_is_zero(decimal_value);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -283,7 +306,7 @@ inline
|
|||
int my_decimal_round(uint mask, const my_decimal *from, int scale,
|
||||
bool truncate, my_decimal *to)
|
||||
{
|
||||
return check_result(mask, decimal_round((decimal_t*) from, to, scale,
|
||||
return check_result(mask, decimal_round(from, to, scale,
|
||||
(truncate ? TRUNCATE : HALF_UP)));
|
||||
}
|
||||
|
||||
|
|
@ -291,14 +314,14 @@ int my_decimal_round(uint mask, const my_decimal *from, int scale,
|
|||
inline
|
||||
int my_decimal_floor(uint mask, const my_decimal *from, my_decimal *to)
|
||||
{
|
||||
return check_result(mask, decimal_round((decimal_t*) from, to, 0, FLOOR));
|
||||
return check_result(mask, decimal_round(from, to, 0, FLOOR));
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
int my_decimal_ceiling(uint mask, const my_decimal *from, my_decimal *to)
|
||||
{
|
||||
return check_result(mask, decimal_round((decimal_t*) from, to, 0, CEILING));
|
||||
return check_result(mask, decimal_round(from, to, 0, CEILING));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -320,7 +343,7 @@ int my_decimal2int(uint mask, const my_decimal *d, my_bool unsigned_flag,
|
|||
{
|
||||
my_decimal rounded;
|
||||
/* decimal_round can return only E_DEC_TRUNCATED */
|
||||
decimal_round((decimal_t*)d, &rounded, 0, HALF_UP);
|
||||
decimal_round(d, &rounded, 0, HALF_UP);
|
||||
return check_result(mask, (unsigned_flag ?
|
||||
decimal2ulonglong(&rounded, (ulonglong *)l) :
|
||||
decimal2longlong(&rounded, l)));
|
||||
|
|
@ -328,18 +351,17 @@ int my_decimal2int(uint mask, const my_decimal *d, my_bool unsigned_flag,
|
|||
|
||||
|
||||
inline
|
||||
int my_decimal2double(uint mask, const my_decimal *d, double *result)
|
||||
int my_decimal2double(uint, const my_decimal *d, double *result)
|
||||
{
|
||||
/* No need to call check_result as this will always succeed */
|
||||
return decimal2double((decimal_t*) d, result);
|
||||
return decimal2double(d, result);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
int str2my_decimal(uint mask, const char *str, my_decimal *d, char **end)
|
||||
{
|
||||
return check_result_and_overflow(mask, string2decimal(str,(decimal_t*)d,end),
|
||||
d);
|
||||
return check_result_and_overflow(mask, string2decimal(str, d, end), d);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -362,7 +384,7 @@ my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec);
|
|||
inline
|
||||
int double2my_decimal(uint mask, double val, my_decimal *d)
|
||||
{
|
||||
return check_result_and_overflow(mask, double2decimal(val, (decimal_t*)d), d);
|
||||
return check_result_and_overflow(mask, double2decimal(val, d), d);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -392,7 +414,7 @@ int my_decimal_add(uint mask, my_decimal *res, const my_decimal *a,
|
|||
const my_decimal *b)
|
||||
{
|
||||
return check_result_and_overflow(mask,
|
||||
decimal_add((decimal_t*)a,(decimal_t*)b,res),
|
||||
decimal_add(a, b, res),
|
||||
res);
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +424,7 @@ int my_decimal_sub(uint mask, my_decimal *res, const my_decimal *a,
|
|||
const my_decimal *b)
|
||||
{
|
||||
return check_result_and_overflow(mask,
|
||||
decimal_sub((decimal_t*)a,(decimal_t*)b,res),
|
||||
decimal_sub(a, b, res),
|
||||
res);
|
||||
}
|
||||
|
||||
|
|
@ -412,7 +434,7 @@ int my_decimal_mul(uint mask, my_decimal *res, const my_decimal *a,
|
|||
const my_decimal *b)
|
||||
{
|
||||
return check_result_and_overflow(mask,
|
||||
decimal_mul((decimal_t*)a,(decimal_t*)b,res),
|
||||
decimal_mul(a, b, res),
|
||||
res);
|
||||
}
|
||||
|
||||
|
|
@ -422,8 +444,7 @@ int my_decimal_div(uint mask, my_decimal *res, const my_decimal *a,
|
|||
const my_decimal *b, int div_scale_inc)
|
||||
{
|
||||
return check_result_and_overflow(mask,
|
||||
decimal_div((decimal_t*)a,(decimal_t*)b,res,
|
||||
div_scale_inc),
|
||||
decimal_div(a, b, res, div_scale_inc),
|
||||
res);
|
||||
}
|
||||
|
||||
|
|
@ -433,7 +454,7 @@ int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a,
|
|||
const my_decimal *b)
|
||||
{
|
||||
return check_result_and_overflow(mask,
|
||||
decimal_mod((decimal_t*)a,(decimal_t*)b,res),
|
||||
decimal_mod(a, b, res),
|
||||
res);
|
||||
}
|
||||
|
||||
|
|
@ -445,14 +466,14 @@ int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a,
|
|||
inline
|
||||
int my_decimal_cmp(const my_decimal *a, const my_decimal *b)
|
||||
{
|
||||
return decimal_cmp((decimal_t*) a, (decimal_t*) b);
|
||||
return decimal_cmp(a, b);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
int my_decimal_intg(const my_decimal *a)
|
||||
{
|
||||
return decimal_intg((decimal_t*) a);
|
||||
return decimal_intg(a);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue