2014-10-06 19:53:55 +02:00
|
|
|
/* Copyright (c) 2004, 2014, Oracle and/or its affiliates.
|
|
|
|
Copyright (c) 2009, 2014, Monty Program Ab.
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
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
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-05-11 20:29:06 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=======================================================================
|
|
|
|
NOTE: this library implements SQL standard "exact numeric" type
|
|
|
|
and is not at all generic, but rather intentinally crippled to
|
|
|
|
follow the standard :)
|
|
|
|
=======================================================================
|
|
|
|
Quoting the standard
|
|
|
|
(SQL:2003, Part 2 Foundations, aka ISO/IEC 9075-2:2003)
|
|
|
|
|
|
|
|
4.4.2 Characteristics of numbers, page 27:
|
|
|
|
|
|
|
|
An exact numeric type has a precision P and a scale S. P is a positive
|
|
|
|
integer that determines the number of significant digits in a
|
|
|
|
particular radix R, where R is either 2 or 10. S is a non-negative
|
|
|
|
integer. Every value of an exact numeric type of scale S is of the
|
2011-06-06 20:28:15 +02:00
|
|
|
form n*10^{-S}, where n is an integer such that -R^P <= n <= R^P.
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
[...]
|
|
|
|
|
|
|
|
If an assignment of some number would result in a loss of its most
|
|
|
|
significant digit, an exception condition is raised. If least
|
|
|
|
significant digits are lost, implementation-defined rounding or
|
|
|
|
truncating occurs, with no exception condition being raised.
|
|
|
|
|
|
|
|
[...]
|
|
|
|
|
|
|
|
Whenever an exact or approximate numeric value is assigned to an exact
|
|
|
|
numeric value site, an approximation of its value that preserves
|
|
|
|
leading significant digits after rounding or truncating is represented
|
|
|
|
in the declared type of the target. The value is converted to have the
|
|
|
|
precision and scale of the target. The choice of whether to truncate
|
|
|
|
or round is implementation-defined.
|
|
|
|
|
|
|
|
[...]
|
|
|
|
|
|
|
|
All numeric values between the smallest and the largest value,
|
|
|
|
inclusive, in a given exact numeric type have an approximation
|
|
|
|
obtained by rounding or truncation for that type; it is
|
|
|
|
implementation-defined which other numeric values have such
|
|
|
|
approximations.
|
|
|
|
|
|
|
|
5.3 <literal>, page 143
|
|
|
|
|
|
|
|
<exact numeric literal> ::=
|
|
|
|
<unsigned integer> [ <period> [ <unsigned integer> ] ]
|
|
|
|
| <period> <unsigned integer>
|
|
|
|
|
|
|
|
6.1 <data type>, page 165:
|
|
|
|
|
|
|
|
19) The <scale> of an <exact numeric type> shall not be greater than
|
|
|
|
the <precision> of the <exact numeric type>.
|
|
|
|
|
|
|
|
20) For the <exact numeric type>s DECIMAL and NUMERIC:
|
|
|
|
|
|
|
|
a) The maximum value of <precision> is implementation-defined.
|
|
|
|
<precision> shall not be greater than this value.
|
|
|
|
b) The maximum value of <scale> is implementation-defined. <scale>
|
|
|
|
shall not be greater than this maximum value.
|
|
|
|
|
|
|
|
21) NUMERIC specifies the data type exact numeric, with the decimal
|
|
|
|
precision and scale specified by the <precision> and <scale>.
|
|
|
|
|
|
|
|
22) DECIMAL specifies the data type exact numeric, with the decimal
|
|
|
|
scale specified by the <scale> and the implementation-defined
|
|
|
|
decimal precision equal to or greater than the value of the
|
|
|
|
specified <precision>.
|
|
|
|
|
|
|
|
6.26 <numeric value expression>, page 241:
|
|
|
|
|
|
|
|
1) If the declared type of both operands of a dyadic arithmetic
|
|
|
|
operator is exact numeric, then the declared type of the result is
|
|
|
|
an implementation-defined exact numeric type, with precision and
|
|
|
|
scale determined as follows:
|
|
|
|
|
|
|
|
a) Let S1 and S2 be the scale of the first and second operands
|
|
|
|
respectively.
|
|
|
|
b) The precision of the result of addition and subtraction is
|
|
|
|
implementation-defined, and the scale is the maximum of S1 and S2.
|
|
|
|
c) The precision of the result of multiplication is
|
|
|
|
implementation-defined, and the scale is S1 + S2.
|
|
|
|
d) The precision and scale of the result of division are
|
|
|
|
implementation-defined.
|
|
|
|
*/
|
|
|
|
|
2011-01-30 11:41:44 +01:00
|
|
|
#include "strings_def.h"
|
2004-10-19 14:38:54 +02:00
|
|
|
#include <m_ctype.h>
|
|
|
|
#include <myisampack.h>
|
|
|
|
#include <my_sys.h> /* for my_alloca */
|
2004-12-06 01:00:37 +01:00
|
|
|
#include <decimal.h>
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2005-02-20 17:25:22 +01:00
|
|
|
/*
|
|
|
|
Internally decimal numbers are stored base 10^9 (see DIG_BASE below)
|
2005-03-21 13:58:34 +01:00
|
|
|
So one variable of type decimal_digit_t is limited:
|
2005-02-20 17:25:22 +01:00
|
|
|
|
|
|
|
0 < decimal_digit <= DIG_MAX < DIG_BASE
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
in the struct st_decimal_t:
|
2005-02-20 17:25:22 +01:00
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
intg is the number of *decimal* digits (NOT number of decimal_digit_t's !)
|
2005-02-20 17:25:22 +01:00
|
|
|
before the point
|
|
|
|
frac - number of decimal digits after the point
|
2005-03-21 13:58:34 +01:00
|
|
|
buf is an array of decimal_digit_t's
|
|
|
|
len is the length of buf (length of allocated space) in decimal_digit_t's,
|
2005-02-20 17:25:22 +01:00
|
|
|
not in bytes
|
|
|
|
*/
|
2005-03-21 13:58:34 +01:00
|
|
|
typedef decimal_digit_t dec1;
|
2004-10-18 14:06:46 +02:00
|
|
|
typedef longlong dec2;
|
|
|
|
|
|
|
|
#define DIG_PER_DEC1 9
|
|
|
|
#define DIG_MASK 100000000
|
|
|
|
#define DIG_BASE 1000000000
|
2005-02-20 16:55:11 +01:00
|
|
|
#define DIG_MAX (DIG_BASE-1)
|
|
|
|
#define DIG_BASE2 ((dec2)DIG_BASE * (dec2)DIG_BASE)
|
2004-10-18 14:06:46 +02:00
|
|
|
static const dec1 powers10[DIG_PER_DEC1+1]={
|
|
|
|
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
|
2004-11-02 13:55:44 +01:00
|
|
|
static const int dig2bytes[DIG_PER_DEC1+1]={0, 1, 1, 2, 2, 3, 3, 4, 4, 4};
|
2005-02-08 23:50:45 +01:00
|
|
|
static const dec1 frac_max[DIG_PER_DEC1-1]={
|
|
|
|
900000000, 990000000, 999000000,
|
|
|
|
999900000, 999990000, 999999000,
|
|
|
|
999999900, 999999990 };
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2014-10-07 10:53:43 +02:00
|
|
|
static inline int ROUND_UP(int x)
|
|
|
|
{
|
2014-10-08 00:46:10 +02:00
|
|
|
return (x + (x > 0 ? DIG_PER_DEC1 - 1 : 0)) / DIG_PER_DEC1;
|
2014-10-07 10:53:43 +02:00
|
|
|
}
|
|
|
|
|
2009-05-06 14:03:24 +02:00
|
|
|
#ifdef HAVE_valgrind
|
2005-03-21 10:57:42 +01:00
|
|
|
#define sanity(d) DBUG_ASSERT((d)->len > 0)
|
|
|
|
#else
|
2004-10-30 19:27:54 +02:00
|
|
|
#define sanity(d) DBUG_ASSERT((d)->len >0 && ((d)->buf[0] | \
|
|
|
|
(d)->buf[(d)->len-1] | 1))
|
2005-03-21 10:57:42 +01:00
|
|
|
#endif
|
2004-10-30 19:27:54 +02:00
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
#define FIX_INTG_FRAC_ERROR(len, intg1, frac1, error) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (unlikely(intg1+frac1 > (len))) \
|
|
|
|
{ \
|
|
|
|
if (unlikely(intg1 > (len))) \
|
|
|
|
{ \
|
|
|
|
intg1=(len); \
|
|
|
|
frac1=0; \
|
|
|
|
error=E_DEC_OVERFLOW; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
frac1=(len)-intg1; \
|
|
|
|
error=E_DEC_TRUNCATED; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
error=E_DEC_OK; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define ADD(to, from1, from2, carry) /* assume carry <= 1 */ \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
dec1 a=(from1)+(from2)+(carry); \
|
2006-07-07 16:27:11 +02:00
|
|
|
DBUG_ASSERT((carry) <= 1); \
|
2004-10-18 14:06:46 +02:00
|
|
|
if (((carry)= a >= DIG_BASE)) /* no division here! */ \
|
|
|
|
a-=DIG_BASE; \
|
|
|
|
(to)=a; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define ADD2(to, from1, from2, carry) \
|
|
|
|
do \
|
|
|
|
{ \
|
2006-07-06 12:18:05 +02:00
|
|
|
dec2 a=((dec2)(from1))+(from2)+(carry); \
|
2004-10-18 14:06:46 +02:00
|
|
|
if (((carry)= a >= DIG_BASE)) \
|
|
|
|
a-=DIG_BASE; \
|
|
|
|
if (unlikely(a >= DIG_BASE)) \
|
|
|
|
{ \
|
|
|
|
a-=DIG_BASE; \
|
|
|
|
carry++; \
|
|
|
|
} \
|
2006-07-06 12:18:05 +02:00
|
|
|
(to)=(dec1) a; \
|
2004-10-18 14:06:46 +02:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define SUB(to, from1, from2, carry) /* to=from1-from2 */ \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
dec1 a=(from1)-(from2)-(carry); \
|
|
|
|
if (((carry)= a < 0)) \
|
|
|
|
a+=DIG_BASE; \
|
|
|
|
(to)=a; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define SUB2(to, from1, from2, carry) /* to=from1-from2 */ \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
dec1 a=(from1)-(from2)-(carry); \
|
|
|
|
if (((carry)= a < 0)) \
|
|
|
|
a+=DIG_BASE; \
|
|
|
|
if (unlikely(a < 0)) \
|
|
|
|
{ \
|
|
|
|
a+=DIG_BASE; \
|
|
|
|
carry++; \
|
|
|
|
} \
|
|
|
|
(to)=a; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/*
|
2005-02-08 23:50:45 +01:00
|
|
|
Get maximum value for given precision and scale
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
2005-02-08 23:50:45 +01:00
|
|
|
max_decimal()
|
|
|
|
precision/scale - see decimal_bin_size() below
|
|
|
|
to - decimal where where the result will be stored
|
|
|
|
to->buf and to->len must be set.
|
2004-10-18 14:06:46 +02:00
|
|
|
*/
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
void max_decimal(decimal_digits_t precision, decimal_digits_t frac,
|
|
|
|
decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t intpart;
|
2005-02-08 23:50:45 +01:00
|
|
|
dec1 *buf= to->buf;
|
|
|
|
DBUG_ASSERT(precision && precision >= frac);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
to->sign= 0;
|
|
|
|
if ((intpart= to->intg= (precision - frac)))
|
|
|
|
{
|
|
|
|
int firstdigits= intpart % DIG_PER_DEC1;
|
|
|
|
if (firstdigits)
|
|
|
|
*buf++= powers10[firstdigits] - 1; /* get 9 99 999 ... */
|
|
|
|
for(intpart/= DIG_PER_DEC1; intpart; intpart--)
|
|
|
|
*buf++= DIG_MAX;
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
if ((to->frac= frac))
|
|
|
|
{
|
|
|
|
int lastdigits= frac % DIG_PER_DEC1;
|
|
|
|
for(frac/= DIG_PER_DEC1; frac; frac--)
|
|
|
|
*buf++= DIG_MAX;
|
|
|
|
if (lastdigits)
|
|
|
|
*buf= frac_max[lastdigits - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
static dec1 *remove_leading_zeroes(const decimal_t *from,
|
|
|
|
decimal_digits_t *intg_result)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t intg= from->intg, i;
|
2005-02-08 23:50:45 +01:00
|
|
|
dec1 *buf0= from->buf;
|
|
|
|
i= ((intg - 1) % DIG_PER_DEC1) + 1;
|
2004-10-18 14:06:46 +02:00
|
|
|
while (intg > 0 && *buf0 == 0)
|
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
intg-= i;
|
|
|
|
i= DIG_PER_DEC1;
|
2004-10-18 14:06:46 +02:00
|
|
|
buf0++;
|
|
|
|
}
|
|
|
|
if (intg > 0)
|
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
for (i= (intg - 1) % DIG_PER_DEC1; *buf0 < powers10[i--]; intg--) ;
|
2004-10-18 14:06:46 +02:00
|
|
|
DBUG_ASSERT(intg > 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
intg=0;
|
2005-02-08 23:50:45 +01:00
|
|
|
*intg_result= intg;
|
|
|
|
return buf0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-05-05 17:06:49 +02:00
|
|
|
Count actual length of fraction part (without ending zeroes)
|
2005-02-08 23:50:45 +01:00
|
|
|
|
|
|
|
SYNOPSIS
|
2005-05-05 17:06:49 +02:00
|
|
|
decimal_actual_fraction()
|
2005-02-08 23:50:45 +01:00
|
|
|
from number for processing
|
|
|
|
*/
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t decimal_actual_fraction(const decimal_t *from)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t frac= from->frac, i;
|
2005-02-08 23:50:45 +01:00
|
|
|
dec1 *buf0= from->buf + ROUND_UP(from->intg) + ROUND_UP(frac) - 1;
|
|
|
|
|
|
|
|
if (frac == 0)
|
2005-05-05 17:06:49 +02:00
|
|
|
return 0;
|
2005-02-08 23:50:45 +01:00
|
|
|
|
|
|
|
i= ((frac - 1) % DIG_PER_DEC1 + 1);
|
|
|
|
while (frac > 0 && *buf0 == 0)
|
|
|
|
{
|
|
|
|
frac-= i;
|
|
|
|
i= DIG_PER_DEC1;
|
|
|
|
buf0--;
|
|
|
|
}
|
|
|
|
if (frac > 0)
|
|
|
|
{
|
|
|
|
for (i= DIG_PER_DEC1 - ((frac - 1) % DIG_PER_DEC1);
|
|
|
|
*buf0 % powers10[i++] == 0;
|
2009-09-03 15:20:22 +02:00
|
|
|
frac--) {}
|
2005-02-08 23:50:45 +01:00
|
|
|
}
|
2005-05-05 17:06:49 +02:00
|
|
|
return frac;
|
2005-02-08 23:50:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Convert decimal to its printable string representation
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal2string()
|
|
|
|
from - value to convert
|
|
|
|
to - points to buffer where string representation
|
|
|
|
should be stored
|
2010-11-11 10:46:49 +01:00
|
|
|
*to_len - in: size of to buffer (incl. terminating '\0')
|
|
|
|
out: length of the actually written string (excl. '\0')
|
2005-02-08 23:50:45 +01:00
|
|
|
fixed_precision - 0 if representation can be variable length and
|
|
|
|
fixed_decimals will not be checked in this case.
|
|
|
|
Put number as with fixed point position with this
|
|
|
|
number of digits (sign counted and decimal point is
|
|
|
|
counted)
|
|
|
|
fixed_decimals - number digits after point.
|
|
|
|
filler - character to fill gaps in case of fixed_precision > 0
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW
|
|
|
|
*/
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal2string(const decimal_t *from, char *to, int *to_len,
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t fixed_precision,
|
|
|
|
decimal_digits_t fixed_decimals,
|
2005-02-08 23:50:45 +01:00
|
|
|
char filler)
|
|
|
|
{
|
2010-11-11 10:46:49 +01:00
|
|
|
/* {intg_len, frac_len} output widths; {intg, frac} places in input */
|
2020-08-27 11:24:32 +02:00
|
|
|
int len, frac= from->frac, i, intg_len, frac_len, fill, intg;
|
|
|
|
decimal_digits_t intg_tmp;
|
2005-02-08 23:50:45 +01:00
|
|
|
/* number digits before decimal point */
|
|
|
|
int fixed_intg= (fixed_precision ?
|
2005-05-05 17:06:49 +02:00
|
|
|
(fixed_precision - fixed_decimals) : 0);
|
2005-02-08 23:50:45 +01:00
|
|
|
int error=E_DEC_OK;
|
|
|
|
char *s=to;
|
|
|
|
dec1 *buf, *buf0=from->buf, tmp;
|
|
|
|
|
2010-09-24 00:00:32 +02:00
|
|
|
DBUG_ASSERT(*to_len >= 2+ (int) from->sign);
|
2005-02-08 23:50:45 +01:00
|
|
|
|
|
|
|
/* removing leading zeroes */
|
2020-08-27 11:24:32 +02:00
|
|
|
buf0= remove_leading_zeroes(from, &intg_tmp);
|
|
|
|
intg= (int) intg_tmp; /* intg can be negative later */
|
2004-10-18 14:06:46 +02:00
|
|
|
if (unlikely(intg+frac==0))
|
|
|
|
{
|
|
|
|
intg=1;
|
|
|
|
tmp=0;
|
|
|
|
buf0=&tmp;
|
|
|
|
}
|
|
|
|
|
2005-07-29 11:39:11 +02:00
|
|
|
if (!(intg_len= fixed_precision ? fixed_intg : intg))
|
|
|
|
intg_len= 1;
|
2005-02-08 23:50:45 +01:00
|
|
|
frac_len= fixed_precision ? fixed_decimals : frac;
|
2014-02-19 11:05:15 +01:00
|
|
|
len= from->sign + intg_len + MY_TEST(frac) + frac_len;
|
2005-02-08 23:50:45 +01:00
|
|
|
if (fixed_precision)
|
|
|
|
{
|
|
|
|
if (frac > fixed_decimals)
|
|
|
|
{
|
|
|
|
error= E_DEC_TRUNCATED;
|
|
|
|
frac= fixed_decimals;
|
|
|
|
}
|
|
|
|
if (intg > fixed_intg)
|
|
|
|
{
|
|
|
|
error= E_DEC_OVERFLOW;
|
|
|
|
intg= fixed_intg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (unlikely(len > --*to_len)) /* reserve one byte for \0 */
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2006-12-14 23:51:37 +01:00
|
|
|
int j= len-*to_len;
|
|
|
|
error= (frac && j <= frac + 1) ? E_DEC_TRUNCATED : E_DEC_OVERFLOW;
|
|
|
|
if (frac && j >= frac + 1) j--;
|
|
|
|
if (j > frac)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2006-12-14 23:51:37 +01:00
|
|
|
intg-= j-frac;
|
2004-10-18 14:06:46 +02:00
|
|
|
frac= 0;
|
|
|
|
}
|
|
|
|
else
|
2006-12-14 23:51:37 +01:00
|
|
|
frac-=j;
|
2015-12-10 11:22:53 +01:00
|
|
|
frac_len= frac;
|
2014-02-19 11:05:15 +01:00
|
|
|
len= from->sign + intg_len + MY_TEST(frac) + frac_len;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
*to_len=len;
|
|
|
|
s[len]=0;
|
|
|
|
|
|
|
|
if (from->sign)
|
|
|
|
*s++='-';
|
|
|
|
|
|
|
|
if (frac)
|
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
char *s1= s + intg_len;
|
|
|
|
fill= frac_len - frac;
|
2004-10-18 14:06:46 +02:00
|
|
|
buf=buf0+ROUND_UP(intg);
|
|
|
|
*s1++='.';
|
|
|
|
for (; frac>0; frac-=DIG_PER_DEC1)
|
|
|
|
{
|
|
|
|
dec1 x=*buf++;
|
2013-03-25 23:03:13 +01:00
|
|
|
for (i=MY_MIN(frac, DIG_PER_DEC1); i; i--)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
dec1 y=x/DIG_MASK;
|
|
|
|
*s1++='0'+(uchar)y;
|
|
|
|
x-=y*DIG_MASK;
|
|
|
|
x*=10;
|
|
|
|
}
|
|
|
|
}
|
2005-02-08 23:50:45 +01:00
|
|
|
for(; fill; fill--)
|
|
|
|
*s1++=filler;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
fill= intg_len - intg;
|
|
|
|
if (intg == 0)
|
2020-08-27 11:24:32 +02:00
|
|
|
{
|
|
|
|
DBUG_ASSERT(fill > 0);
|
2005-02-08 23:50:45 +01:00
|
|
|
fill--; /* symbol 0 before digital point */
|
2020-08-27 11:24:32 +02:00
|
|
|
}
|
2005-02-08 23:50:45 +01:00
|
|
|
for(; fill; fill--)
|
|
|
|
*s++=filler;
|
|
|
|
if (intg)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
s+=intg;
|
|
|
|
for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
dec1 x=*--buf;
|
2013-03-25 23:03:13 +01:00
|
|
|
for (i=MY_MIN(intg, DIG_PER_DEC1); i; i--)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
|
|
|
dec1 y=x/10;
|
|
|
|
*--s='0'+(uchar)(x-y*10);
|
|
|
|
x=y;
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
}
|
2005-02-08 23:50:45 +01:00
|
|
|
else
|
|
|
|
*s= '0';
|
2004-10-18 14:06:46 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
Return bounds of decimal digits in the number
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
digits_bounds()
|
|
|
|
from - decimal number for processing
|
|
|
|
start_result - index (from 0 ) of first decimal digits will
|
|
|
|
be written by this address
|
|
|
|
end_result - index of position just after last decimal digit
|
|
|
|
be written by this address
|
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
static void digits_bounds(decimal_t *from, int *start_result, int *end_result)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
|
|
|
int start, stop, i;
|
|
|
|
dec1 *buf_beg= from->buf;
|
|
|
|
dec1 *end= from->buf + ROUND_UP(from->intg) + ROUND_UP(from->frac);
|
|
|
|
dec1 *buf_end= end - 1;
|
|
|
|
|
2016-06-08 13:14:42 +02:00
|
|
|
/* find non-zero digit from number beginning */
|
2005-02-08 23:50:45 +01:00
|
|
|
while (buf_beg < end && *buf_beg == 0)
|
|
|
|
buf_beg++;
|
|
|
|
|
|
|
|
if (buf_beg >= end)
|
|
|
|
{
|
|
|
|
/* it is zero */
|
|
|
|
*start_result= *end_result= 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-08 13:14:42 +02:00
|
|
|
/* find non-zero decimal digit from number beginning */
|
2005-02-08 23:50:45 +01:00
|
|
|
if (buf_beg == from->buf && from->intg)
|
|
|
|
{
|
|
|
|
start= DIG_PER_DEC1 - (i= ((from->intg-1) % DIG_PER_DEC1 + 1));
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i= DIG_PER_DEC1 - 1;
|
2005-06-13 12:41:15 +02:00
|
|
|
start= (int) ((buf_beg - from->buf) * DIG_PER_DEC1);
|
2005-02-08 23:50:45 +01:00
|
|
|
}
|
|
|
|
if (buf_beg < end)
|
|
|
|
for (; *buf_beg < powers10[i--]; start++) ;
|
|
|
|
*start_result= start; /* index of first decimal digit (from 0) */
|
|
|
|
|
|
|
|
/* find non-zero digit at the end */
|
|
|
|
while (buf_end > buf_beg && *buf_end == 0)
|
|
|
|
buf_end--;
|
|
|
|
/* find non-zero decimal digit from the end */
|
|
|
|
if (buf_end == end - 1 && from->frac)
|
|
|
|
{
|
2005-06-13 12:41:15 +02:00
|
|
|
stop= (int) (((buf_end - from->buf) * DIG_PER_DEC1 +
|
|
|
|
(i= ((from->frac - 1) % DIG_PER_DEC1 + 1))));
|
2005-02-08 23:50:45 +01:00
|
|
|
i= DIG_PER_DEC1 - i + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-13 12:41:15 +02:00
|
|
|
stop= (int) ((buf_end - from->buf + 1) * DIG_PER_DEC1);
|
2005-02-08 23:50:45 +01:00
|
|
|
i= 1;
|
|
|
|
}
|
2009-09-03 15:20:22 +02:00
|
|
|
for (; *buf_end % powers10[i++] == 0; stop--) {}
|
2005-02-08 23:50:45 +01:00
|
|
|
*end_result= stop; /* index of position after last decimal digit (from 0) */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Left shift for alignment of data in buffer
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
do_mini_left_shift()
|
|
|
|
dec pointer to decimal number which have to be shifted
|
|
|
|
shift number of decimal digits on which it should be shifted
|
|
|
|
beg/end bounds of decimal digits (see digits_bounds())
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
Result fitting in the buffer should be garanted.
|
|
|
|
'shift' have to be from 1 to DIG_PER_DEC1-1 (inclusive)
|
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
void do_mini_left_shift(decimal_t *dec, int shift, int beg, int last)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
|
|
|
dec1 *from= dec->buf + ROUND_UP(beg + 1) - 1;
|
|
|
|
dec1 *end= dec->buf + ROUND_UP(last) - 1;
|
|
|
|
int c_shift= DIG_PER_DEC1 - shift;
|
|
|
|
DBUG_ASSERT(from >= dec->buf);
|
|
|
|
DBUG_ASSERT(end < dec->buf + dec->len);
|
|
|
|
if (beg % DIG_PER_DEC1 < shift)
|
|
|
|
*(from - 1)= (*from) / powers10[c_shift];
|
|
|
|
for(; from < end; from++)
|
|
|
|
*from= ((*from % powers10[c_shift]) * powers10[shift] +
|
|
|
|
(*(from + 1)) / powers10[c_shift]);
|
|
|
|
*from= (*from % powers10[c_shift]) * powers10[shift];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Right shift for alignment of data in buffer
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
do_mini_left_shift()
|
|
|
|
dec pointer to decimal number which have to be shifted
|
|
|
|
shift number of decimal digits on which it should be shifted
|
|
|
|
beg/end bounds of decimal digits (see digits_bounds())
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
Result fitting in the buffer should be garanted.
|
|
|
|
'shift' have to be from 1 to DIG_PER_DEC1-1 (inclusive)
|
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
void do_mini_right_shift(decimal_t *dec, int shift, int beg, int last)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
|
|
|
dec1 *from= dec->buf + ROUND_UP(last) - 1;
|
|
|
|
dec1 *end= dec->buf + ROUND_UP(beg + 1) - 1;
|
|
|
|
int c_shift= DIG_PER_DEC1 - shift;
|
|
|
|
DBUG_ASSERT(from < dec->buf + dec->len);
|
|
|
|
DBUG_ASSERT(end >= dec->buf);
|
|
|
|
if (DIG_PER_DEC1 - ((last - 1) % DIG_PER_DEC1 + 1) < shift)
|
|
|
|
*(from + 1)= (*from % powers10[shift]) * powers10[c_shift];
|
|
|
|
for(; from > end; from--)
|
|
|
|
*from= (*from / powers10[shift] +
|
|
|
|
(*(from - 1) % powers10[shift]) * powers10[c_shift]);
|
|
|
|
*from= *from / powers10[shift];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Shift of decimal digits in given number (with rounding if it need)
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal_shift()
|
|
|
|
dec number to be shifted
|
|
|
|
shift number of decimal positions
|
|
|
|
shift > 0 means shift to left shift
|
|
|
|
shift < 0 meand right shift
|
|
|
|
NOTE
|
|
|
|
In fact it is multipling on 10^shift.
|
|
|
|
RETURN
|
|
|
|
E_DEC_OK OK
|
|
|
|
E_DEC_OVERFLOW operation lead to overflow, number is untoched
|
|
|
|
E_DEC_TRUNCATED number was rounded to fit into buffer
|
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
int decimal_shift(decimal_t *dec, int shift)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
|
|
|
/* index of first non zero digit (all indexes from 0) */
|
|
|
|
int beg;
|
|
|
|
/* index of position after last decimal digit */
|
|
|
|
int end;
|
|
|
|
/* index of digit position just after point */
|
|
|
|
int point= ROUND_UP(dec->intg) * DIG_PER_DEC1;
|
|
|
|
/* new point position */
|
|
|
|
int new_point= point + shift;
|
|
|
|
/* number of digits in result */
|
|
|
|
int digits_int, digits_frac;
|
|
|
|
/* length of result and new fraction in big digits*/
|
|
|
|
int new_len, new_frac_len;
|
|
|
|
/* return code */
|
|
|
|
int err= E_DEC_OK;
|
|
|
|
int new_front;
|
|
|
|
|
|
|
|
if (shift == 0)
|
|
|
|
return E_DEC_OK;
|
|
|
|
|
|
|
|
digits_bounds(dec, &beg, &end);
|
|
|
|
|
|
|
|
if (beg == end)
|
|
|
|
{
|
|
|
|
decimal_make_zero(dec);
|
|
|
|
return E_DEC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
digits_int= new_point - beg;
|
|
|
|
set_if_bigger(digits_int, 0);
|
|
|
|
digits_frac= end - new_point;
|
|
|
|
set_if_bigger(digits_frac, 0);
|
|
|
|
|
|
|
|
if ((new_len= ROUND_UP(digits_int) + (new_frac_len= ROUND_UP(digits_frac))) >
|
|
|
|
dec->len)
|
|
|
|
{
|
|
|
|
int lack= new_len - dec->len;
|
|
|
|
int diff;
|
|
|
|
|
|
|
|
if (new_frac_len < lack)
|
|
|
|
return E_DEC_OVERFLOW; /* lack more then we have in fraction */
|
|
|
|
|
|
|
|
/* cat off fraction part to allow new number to fit in our buffer */
|
|
|
|
err= E_DEC_TRUNCATED;
|
|
|
|
new_frac_len-= lack;
|
|
|
|
diff= digits_frac - (new_frac_len * DIG_PER_DEC1);
|
|
|
|
/* Make rounding method as parameter? */
|
|
|
|
decimal_round(dec, dec, end - point - diff, HALF_UP);
|
|
|
|
end-= diff;
|
|
|
|
digits_frac= new_frac_len * DIG_PER_DEC1;
|
|
|
|
|
|
|
|
if (end <= beg)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
we lost all digits (they will be shifted out of buffer), so we can
|
|
|
|
just return 0
|
|
|
|
*/
|
|
|
|
decimal_make_zero(dec);
|
|
|
|
return E_DEC_TRUNCATED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shift % DIG_PER_DEC1)
|
|
|
|
{
|
|
|
|
int l_mini_shift, r_mini_shift, mini_shift;
|
|
|
|
int do_left;
|
|
|
|
/*
|
|
|
|
Calculate left/right shift to align decimal digits inside our bug
|
|
|
|
digits correctly
|
|
|
|
*/
|
|
|
|
if (shift > 0)
|
|
|
|
{
|
|
|
|
l_mini_shift= shift % DIG_PER_DEC1;
|
|
|
|
r_mini_shift= DIG_PER_DEC1 - l_mini_shift;
|
|
|
|
/*
|
|
|
|
It is left shift so prefer left shift, but if we have not place from
|
|
|
|
left, we have to have it from right, because we checked length of
|
|
|
|
result
|
|
|
|
*/
|
|
|
|
do_left= l_mini_shift <= beg;
|
|
|
|
DBUG_ASSERT(do_left || (dec->len * DIG_PER_DEC1 - end) >= r_mini_shift);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r_mini_shift= (-shift) % DIG_PER_DEC1;
|
|
|
|
l_mini_shift= DIG_PER_DEC1 - r_mini_shift;
|
|
|
|
/* see comment above */
|
|
|
|
do_left= !((dec->len * DIG_PER_DEC1 - end) >= r_mini_shift);
|
|
|
|
DBUG_ASSERT(!do_left || l_mini_shift <= beg);
|
|
|
|
}
|
|
|
|
if (do_left)
|
|
|
|
{
|
|
|
|
do_mini_left_shift(dec, l_mini_shift, beg, end);
|
2013-03-28 20:04:14 +01:00
|
|
|
mini_shift= -l_mini_shift;
|
2005-02-08 23:50:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
do_mini_right_shift(dec, r_mini_shift, beg, end);
|
|
|
|
mini_shift= r_mini_shift;
|
|
|
|
}
|
|
|
|
new_point+= mini_shift;
|
|
|
|
/*
|
|
|
|
If number is shifted and correctly aligned in buffer we can
|
|
|
|
finish
|
|
|
|
*/
|
|
|
|
if (!(shift+= mini_shift) && (new_point - digits_int) < DIG_PER_DEC1)
|
|
|
|
{
|
|
|
|
dec->intg= digits_int;
|
|
|
|
dec->frac= digits_frac;
|
|
|
|
return err; /* already shifted as it should be */
|
|
|
|
}
|
|
|
|
beg+= mini_shift;
|
|
|
|
end+= mini_shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if new 'decimal front' is in first digit, we do not need move digits */
|
|
|
|
if ((new_front= (new_point - digits_int)) >= DIG_PER_DEC1 ||
|
|
|
|
new_front < 0)
|
|
|
|
{
|
|
|
|
/* need to move digits */
|
|
|
|
int d_shift;
|
2005-02-09 10:35:22 +01:00
|
|
|
dec1 *to, *barier;
|
2005-02-08 23:50:45 +01:00
|
|
|
if (new_front > 0)
|
|
|
|
{
|
|
|
|
/* move left */
|
|
|
|
d_shift= new_front / DIG_PER_DEC1;
|
2005-02-09 10:35:22 +01:00
|
|
|
to= dec->buf + (ROUND_UP(beg + 1) - 1 - d_shift);
|
|
|
|
barier= dec->buf + (ROUND_UP(end) - 1 - d_shift);
|
2005-02-08 23:50:45 +01:00
|
|
|
DBUG_ASSERT(to >= dec->buf);
|
|
|
|
DBUG_ASSERT(barier + d_shift < dec->buf + dec->len);
|
|
|
|
for(; to <= barier; to++)
|
|
|
|
*to= *(to + d_shift);
|
|
|
|
for(barier+= d_shift; to <= barier; to++)
|
|
|
|
*to= 0;
|
|
|
|
d_shift= -d_shift;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* move right */
|
|
|
|
d_shift= (1 - new_front) / DIG_PER_DEC1;
|
2005-02-09 10:35:22 +01:00
|
|
|
to= dec->buf + ROUND_UP(end) - 1 + d_shift;
|
|
|
|
barier= dec->buf + ROUND_UP(beg + 1) - 1 + d_shift;
|
2005-02-08 23:50:45 +01:00
|
|
|
DBUG_ASSERT(to < dec->buf + dec->len);
|
|
|
|
DBUG_ASSERT(barier - d_shift >= dec->buf);
|
|
|
|
for(; to >= barier; to--)
|
|
|
|
*to= *(to - d_shift);
|
|
|
|
for(barier-= d_shift; to >= barier; to--)
|
|
|
|
*to= 0;
|
|
|
|
}
|
|
|
|
d_shift*= DIG_PER_DEC1;
|
|
|
|
beg+= d_shift;
|
|
|
|
end+= d_shift;
|
|
|
|
new_point+= d_shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
If there are gaps then fill ren with 0.
|
|
|
|
|
2018-02-24 18:42:13 +01:00
|
|
|
Only one of following 'for' loops will work because beg <= end
|
2005-02-08 23:50:45 +01:00
|
|
|
*/
|
|
|
|
beg= ROUND_UP(beg + 1) - 1;
|
|
|
|
end= ROUND_UP(end) - 1;
|
|
|
|
DBUG_ASSERT(new_point >= 0);
|
2005-07-07 15:23:30 +02:00
|
|
|
|
|
|
|
/* We don't want negative new_point below */
|
|
|
|
if (new_point != 0)
|
|
|
|
new_point= ROUND_UP(new_point) - 1;
|
|
|
|
|
|
|
|
if (new_point > end)
|
2005-07-28 15:10:14 +02:00
|
|
|
{
|
2005-07-07 15:23:30 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
dec->buf[new_point]=0;
|
2005-07-28 15:10:14 +02:00
|
|
|
} while (--new_point > end);
|
|
|
|
}
|
2005-07-07 15:23:30 +02:00
|
|
|
else
|
2005-07-28 15:10:14 +02:00
|
|
|
{
|
2005-07-07 15:23:30 +02:00
|
|
|
for (; new_point < beg; new_point++)
|
|
|
|
dec->buf[new_point]= 0;
|
2005-07-28 15:10:14 +02:00
|
|
|
}
|
2005-02-08 23:50:45 +01:00
|
|
|
dec->intg= digits_int;
|
|
|
|
dec->frac= digits_frac;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/*
|
|
|
|
Convert string to decimal
|
|
|
|
|
|
|
|
SYNOPSIS
|
2005-02-19 17:58:27 +01:00
|
|
|
internal_str2decl()
|
|
|
|
from - value to convert. Doesn't have to be \0 terminated!
|
2004-10-18 14:06:46 +02:00
|
|
|
to - decimal where where the result will be stored
|
|
|
|
to->buf and to->len must be set.
|
2005-02-19 17:58:27 +01:00
|
|
|
end - Pointer to pointer to end of string. Will on return be
|
|
|
|
set to the char after the last used character
|
2004-10-29 00:22:54 +02:00
|
|
|
fixed - use to->intg, to->frac as limits for input number
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
to->intg and to->frac can be modified even when fixed=1
|
|
|
|
(but only decreased, in this case)
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
RETURN VALUE
|
2004-10-29 00:22:54 +02:00
|
|
|
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW/E_DEC_BAD_NUM/E_DEC_OOM
|
2005-02-19 17:58:27 +01:00
|
|
|
In case of E_DEC_FATAL_ERROR *to is set to decimal zero
|
|
|
|
(to make error handling easier)
|
2004-10-18 14:06:46 +02:00
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
int
|
|
|
|
internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
const char *s= from, *s1, *endp, *end_of_string= *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
int i, intg, frac, error, intg1, frac1;
|
|
|
|
dec1 x,*buf;
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
error= E_DEC_BAD_NUM; /* In case of bad number */
|
|
|
|
while (s < end_of_string && my_isspace(&my_charset_latin1, *s))
|
2004-10-18 14:06:46 +02:00
|
|
|
s++;
|
2005-02-19 17:58:27 +01:00
|
|
|
if (s == end_of_string)
|
|
|
|
goto fatal_error;
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
if ((to->sign= (*s == '-')))
|
|
|
|
s++;
|
|
|
|
else if (*s == '+')
|
|
|
|
s++;
|
|
|
|
|
|
|
|
s1=s;
|
2005-02-19 17:58:27 +01:00
|
|
|
while (s < end_of_string && my_isdigit(&my_charset_latin1, *s))
|
2004-10-18 14:06:46 +02:00
|
|
|
s++;
|
2005-06-13 12:41:15 +02:00
|
|
|
intg= (int) (s-s1);
|
2020-08-05 06:14:49 +02:00
|
|
|
/*
|
|
|
|
If the integer part is long enough and it has multiple leading zeros,
|
|
|
|
let's trim them, so this expression can return 1 without overflowing:
|
|
|
|
CAST(CONCAT(REPEAT('0',90),'1') AS DECIMAL(10))
|
|
|
|
*/
|
|
|
|
if (intg > DIG_PER_DEC1 && s1[0] == '0' && s1[1] == '0')
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Keep at least one digit, to avoid an empty string.
|
|
|
|
So we trim '0000' to '0' rather than to ''.
|
|
|
|
Otherwise the below code (converting digits to to->buf)
|
|
|
|
would fail on a fatal error.
|
|
|
|
*/
|
|
|
|
const char *iend= s - 1;
|
|
|
|
for ( ; s1 < iend && *s1 == '0'; s1++)
|
|
|
|
{ }
|
|
|
|
intg= (int) (s-s1);
|
|
|
|
}
|
2005-02-19 17:58:27 +01:00
|
|
|
if (s < end_of_string && *s=='.')
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
endp= s+1;
|
2005-04-06 16:22:21 +02:00
|
|
|
while (endp < end_of_string && my_isdigit(&my_charset_latin1, *endp))
|
2005-02-08 23:50:45 +01:00
|
|
|
endp++;
|
2005-06-13 12:41:15 +02:00
|
|
|
frac= (int) (endp - s - 1);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
else
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
|
|
|
frac= 0;
|
|
|
|
endp= s;
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
*end= (char*) endp;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
if (frac+intg == 0)
|
2005-02-19 17:58:27 +01:00
|
|
|
goto fatal_error;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
error= 0;
|
2004-10-29 00:22:54 +02:00
|
|
|
if (fixed)
|
|
|
|
{
|
|
|
|
if (frac > to->frac)
|
|
|
|
{
|
|
|
|
error=E_DEC_TRUNCATED;
|
|
|
|
frac=to->frac;
|
|
|
|
}
|
|
|
|
if (intg > to->intg)
|
|
|
|
{
|
|
|
|
error=E_DEC_OVERFLOW;
|
|
|
|
intg=to->intg;
|
|
|
|
}
|
|
|
|
intg1=ROUND_UP(intg);
|
|
|
|
frac1=ROUND_UP(frac);
|
|
|
|
if (intg1+frac1 > to->len)
|
2005-02-19 17:58:27 +01:00
|
|
|
{
|
|
|
|
error= E_DEC_OOM;
|
|
|
|
goto fatal_error;
|
|
|
|
}
|
2004-10-29 00:22:54 +02:00
|
|
|
}
|
|
|
|
else
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2004-10-29 00:22:54 +02:00
|
|
|
intg1=ROUND_UP(intg);
|
|
|
|
frac1=ROUND_UP(frac);
|
|
|
|
FIX_INTG_FRAC_ERROR(to->len, intg1, frac1, error);
|
|
|
|
if (unlikely(error))
|
|
|
|
{
|
|
|
|
frac=frac1*DIG_PER_DEC1;
|
|
|
|
if (error == E_DEC_OVERFLOW)
|
|
|
|
intg=intg1*DIG_PER_DEC1;
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
2018-02-24 18:42:13 +01:00
|
|
|
/* Error is guaranteed to be set here */
|
2004-10-18 14:06:46 +02:00
|
|
|
to->intg=intg;
|
|
|
|
to->frac=frac;
|
|
|
|
|
|
|
|
buf=to->buf+intg1;
|
|
|
|
s1=s;
|
|
|
|
|
|
|
|
for (x=0, i=0; intg; intg--)
|
|
|
|
{
|
|
|
|
x+= (*--s - '0')*powers10[i];
|
|
|
|
|
|
|
|
if (unlikely(++i == DIG_PER_DEC1))
|
|
|
|
{
|
|
|
|
*--buf=x;
|
|
|
|
x=0;
|
|
|
|
i=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i)
|
|
|
|
*--buf=x;
|
|
|
|
|
|
|
|
buf=to->buf+intg1;
|
|
|
|
for (x=0, i=0; frac; frac--)
|
|
|
|
{
|
|
|
|
x= (*++s1 - '0') + x*10;
|
|
|
|
|
|
|
|
if (unlikely(++i == DIG_PER_DEC1))
|
|
|
|
{
|
|
|
|
*buf++=x;
|
|
|
|
x=0;
|
|
|
|
i=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i)
|
|
|
|
*buf=x*powers10[DIG_PER_DEC1-i];
|
2005-02-08 23:50:45 +01:00
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
/* Handle exponent */
|
|
|
|
if (endp+1 < end_of_string && (*endp == 'e' || *endp == 'E'))
|
|
|
|
{
|
|
|
|
int str_error;
|
2021-02-05 16:50:05 +01:00
|
|
|
const char *end_of_exponent= end_of_string;
|
|
|
|
longlong exponent= my_strtoll10(endp+1, (char**) &end_of_exponent,
|
2006-12-14 23:51:37 +01:00
|
|
|
&str_error);
|
2005-02-08 23:50:45 +01:00
|
|
|
|
2021-02-05 16:50:05 +01:00
|
|
|
if (end_of_exponent != endp +1) /* If at least one digit */
|
2005-02-19 17:58:27 +01:00
|
|
|
{
|
2021-02-05 16:50:05 +01:00
|
|
|
*end= (char*) end_of_exponent;
|
2005-02-19 17:58:27 +01:00
|
|
|
if (str_error > 0)
|
|
|
|
{
|
2021-02-05 16:50:05 +01:00
|
|
|
if (str_error == MY_ERRNO_ERANGE)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Exponent is:
|
|
|
|
- a huge positive number that does not fit into ulonglong
|
|
|
|
- a huge negative number that does not fit into longlong
|
|
|
|
Skip all remaining digits.
|
|
|
|
*/
|
|
|
|
for ( ; end_of_exponent < end_of_string &&
|
|
|
|
my_isdigit(&my_charset_latin1, *end_of_exponent)
|
|
|
|
; end_of_exponent++)
|
|
|
|
{ }
|
|
|
|
*end= (char*) end_of_exponent;
|
|
|
|
if (exponent == ~0)
|
|
|
|
{
|
|
|
|
if (!decimal_is_zero(to))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Non-zero mantissa and a huge positive exponent that
|
|
|
|
does not fit into ulonglong, e.g.:
|
|
|
|
1e111111111111111111111
|
|
|
|
*/
|
|
|
|
error= E_DEC_OVERFLOW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Zero mantissa and a huge positive exponent that
|
|
|
|
does not fit into ulonglong, e.g.:
|
|
|
|
0e111111111111111111111
|
|
|
|
Return zero without warnings.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Huge negative exponent that does not fit into longlong, e.g.
|
|
|
|
1e-111111111111111111111
|
|
|
|
0e-111111111111111111111
|
|
|
|
Return zero without warnings.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
goto fatal_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Some other error, e.g. MY_ERRNO_EDOM
|
|
|
|
*/
|
2005-02-19 17:58:27 +01:00
|
|
|
error= E_DEC_BAD_NUM;
|
|
|
|
goto fatal_error;
|
|
|
|
}
|
2006-12-14 23:51:37 +01:00
|
|
|
if (exponent > INT_MAX/2 || (str_error == 0 && exponent < 0))
|
2005-02-19 17:58:27 +01:00
|
|
|
{
|
2021-02-05 16:50:05 +01:00
|
|
|
/*
|
|
|
|
The exponent fits into ulonglong, but it's still huge, e.g.
|
|
|
|
1e1111111111
|
|
|
|
*/
|
|
|
|
if (!decimal_is_zero(to))
|
|
|
|
error= E_DEC_OVERFLOW;
|
2005-02-19 17:58:27 +01:00
|
|
|
goto fatal_error;
|
|
|
|
}
|
2006-12-14 23:51:37 +01:00
|
|
|
if (exponent < INT_MIN/2 && error != E_DEC_OVERFLOW)
|
2005-02-19 17:58:27 +01:00
|
|
|
{
|
|
|
|
error= E_DEC_TRUNCATED;
|
|
|
|
goto fatal_error;
|
|
|
|
}
|
|
|
|
if (error != E_DEC_OVERFLOW)
|
2006-12-14 23:51:37 +01:00
|
|
|
error= decimal_shift(to, (int) exponent);
|
2005-02-19 17:58:27 +01:00
|
|
|
}
|
2005-02-08 23:50:45 +01:00
|
|
|
}
|
2016-06-26 13:37:27 +02:00
|
|
|
if (to->sign && decimal_is_zero(to))
|
|
|
|
to->sign= 0;
|
2005-02-19 17:58:27 +01:00
|
|
|
return error;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
fatal_error:
|
|
|
|
decimal_make_zero(to);
|
2004-10-18 14:06:46 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/*
|
|
|
|
Convert decimal to double
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal2double()
|
|
|
|
from - value to convert
|
|
|
|
to - result will be stored there
|
|
|
|
|
|
|
|
RETURN VALUE
|
2009-12-22 17:23:13 +01:00
|
|
|
E_DEC_OK/E_DEC_OVERFLOW/E_DEC_TRUNCATED
|
2004-10-18 14:06:46 +02:00
|
|
|
*/
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal2double(const decimal_t *from, double *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2009-12-22 17:23:13 +01:00
|
|
|
char strbuf[FLOATING_POINT_BUFFER], *end;
|
|
|
|
int len= sizeof(strbuf);
|
|
|
|
int rc, error;
|
2006-12-20 01:42:26 +01:00
|
|
|
|
2009-12-22 17:23:13 +01:00
|
|
|
rc = decimal2string(from, strbuf, &len, 0, 0, 0);
|
|
|
|
end= strbuf + len;
|
2006-12-20 01:42:26 +01:00
|
|
|
|
2009-12-22 17:23:13 +01:00
|
|
|
DBUG_PRINT("info", ("interm.: %s", strbuf));
|
2006-12-20 01:42:26 +01:00
|
|
|
|
2009-12-22 17:23:13 +01:00
|
|
|
*to= my_strtod(strbuf, &end, &error);
|
2006-12-20 01:42:26 +01:00
|
|
|
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
DBUG_PRINT("info", ("result: %f", *to));
|
2006-12-20 01:42:26 +01:00
|
|
|
|
2009-12-22 17:23:13 +01:00
|
|
|
return (rc != E_DEC_OK) ? rc : (error ? E_DEC_OVERFLOW : E_DEC_OK);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Convert double to decimal
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
double2decimal()
|
|
|
|
from - value to convert
|
|
|
|
to - result will be stored there
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_OVERFLOW/E_DEC_TRUNCATED
|
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
int double2decimal(double from, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2009-12-22 17:23:13 +01:00
|
|
|
char buff[FLOATING_POINT_BUFFER], *end;
|
|
|
|
int res;
|
2005-11-23 19:16:06 +01:00
|
|
|
DBUG_ENTER("double2decimal");
|
2009-12-22 17:23:13 +01:00
|
|
|
end= buff + my_gcvt(from, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL);
|
2005-11-23 19:16:06 +01:00
|
|
|
res= string2decimal(buff, to, &end);
|
|
|
|
DBUG_PRINT("exit", ("res: %d", res));
|
|
|
|
DBUG_RETURN(res);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2005-11-23 19:16:06 +01:00
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
static int ull2dec(ulonglong from, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
int intg1, error=E_DEC_OK;
|
|
|
|
ulonglong x=from;
|
|
|
|
dec1 *buf;
|
|
|
|
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
|
|
|
|
2018-02-25 20:59:01 +01:00
|
|
|
if (!from)
|
|
|
|
{
|
|
|
|
decimal_make_zero(to);
|
|
|
|
return E_DEC_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-03 15:20:22 +02:00
|
|
|
for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) {}
|
2004-10-18 14:06:46 +02:00
|
|
|
if (unlikely(intg1 > to->len))
|
|
|
|
{
|
|
|
|
intg1=to->len;
|
|
|
|
error=E_DEC_OVERFLOW;
|
|
|
|
}
|
|
|
|
to->frac=0;
|
2016-06-25 23:02:32 +02:00
|
|
|
for(to->intg= (intg1-1)*DIG_PER_DEC1; from; to->intg++, from/=10) {}
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
for (buf=to->buf+intg1; intg1; intg1--)
|
|
|
|
{
|
|
|
|
ulonglong y=x/DIG_BASE;
|
|
|
|
*--buf=(dec1)(x-y*DIG_BASE);
|
|
|
|
x=y;
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
int ulonglong2decimal(ulonglong from, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
to->sign=0;
|
|
|
|
return ull2dec(from, to);
|
|
|
|
}
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
int longlong2decimal(longlong from, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
if ((to->sign= from < 0))
|
2015-05-04 08:32:05 +02:00
|
|
|
{
|
|
|
|
if (from == LONGLONG_MIN) // avoid undefined behavior
|
|
|
|
return ull2dec((ulonglong)LONGLONG_MIN, to);
|
2004-10-18 14:06:46 +02:00
|
|
|
return ull2dec(-from, to);
|
2015-05-04 08:32:05 +02:00
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
return ull2dec(from, to);
|
|
|
|
}
|
|
|
|
|
Adding support for Dynamic columns (WL#34):
- COLUMN_CREATE(column_nr, value, [column_nr,value]...)
- COLUMN_ADD(blob,column_nr, value, column_nr,value]...)
- COLUMN_DELETE(blob, column_nr, column_nr...)
- COLUMN_EXISTS(blob, column_nr)
- COLUMN_LIST(blob, column_nr)
- COLUMN_GET(string, column_nr AS type)
Added cast(X as DOUBLE) and cast(x as INT)
Better warning and error messages for wrong cast's
Created some sub functions to simplify and reuse code.
Added a lot of conversation functions with error/warnings for what went wrong.
Fixed some issues when casting time to datetime.
Added functions to dynamic strings and Strings to allow one to move a string buffer from dynamic strings to String (to save malloc+ copy)
Added dynamic columns library to libmysqlclient
include/Makefile.am:
Added ma_dyncol.h
include/decimal.h:
Added 'const' to arguments for some functions.
include/my_sys.h:
Added dynstr_reassociate()
include/my_time.h:
Added TIME_SUBSECOND_RANGE
Added double_to_datetime()
Added flag argument to str_to_time()
libmysql/CMakeLists.txt:
Added mysys/ma_dyncol.c
libmysql/Makefile.shared:
Added ma_dyncol
libmysql/libmysql.c:
Added argument to str_to_time()
mysql-test/r/bigint.result:
Better error messages
mysql-test/r/cast.result:
Better warning and error messages
A lot of new cast() tests
mysql-test/r/func_math.result:
Better warning messages
mysql-test/r/func_str.result:
Better warning messages
mysql-test/r/func_time.result:
Better warning messages
mysql-test/r/sp-vars.result:
Better warning messages
mysql-test/r/strict.result:
Better warning messages
New test result
mysql-test/r/type_newdecimal.result:
Better warning messages
mysql-test/r/warnings.result:
Better warning messages
mysql-test/suite/funcs_1/r/innodb_func_view.result:
Updated results after better cast warnings
mysql-test/suite/funcs_1/r/memory_func_view.result:
Updated results after better cast warnings
mysql-test/suite/funcs_1/r/myisam_func_view.result:
Updated results after better cast warnings
mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test:
Added begin...commit to speed up test.
mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc:
Added begin...commit to speed up test.
mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc:
Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_innodb.result:
Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_myisam.result:
Added begin...commit to speed up test.
mysql-test/suite/parts/r/rpl_partition.result:
Added begin...commit to speed up test.
mysql-test/suite/parts/t/part_supported_sql_func_innodb.test:
Removed duplicated --big_test
mysql-test/suite/parts/t/rpl_partition.test:
Added begin...commit to speed up test.
mysql-test/suite/pbxt/r/cast.result:
Updated results after better cast warnings
mysql-test/suite/pbxt/r/func_str.result:
Updated results after better cast warnings
mysql-test/suite/pbxt/r/type_newdecimal.result:
Updated results after better cast warnings
mysql-test/suite/rpl/r/rpl_innodb_bug28430.result:
Added begin...commit to speed up test.
mysql-test/suite/rpl/t/rpl_innodb_bug28430.test:
Added begin...commit to speed up test.
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result:
More warnings
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result:
More warnings
mysql-test/t/cast.test:
A lot of new cast() tests
mysql-test/t/strict.test:
Added new test
mysys/CMakeLists.txt:
Added ma_dyncol.c
mysys/Makefile.am:
Added ma_dyncol.c
mysys/string.c:
Added dynstr_reassociate() to move a buffer from dynamic_strings to some other allocator
sql-common/my_time.c:
Added 'fuzzydate' flag to str_to_time()
Added support for microseconds to my_time_to_str() and my_datetime_to_str()
Reset second_parts in number_to_datetime()
Added double_to_datetime()
sql/field.cc:
Added double_to_longlong() and truncate_double() to simplify and reuse code
sql/field.h:
New prototypes
sql/item.cc:
Changed Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) to be aware of type of argument.
(Needed to make it microsecond safe and get better warnings).
Updated call to str_to_time_with_warn()
sql/item.h:
Added struct st_dyncall_create_def used by dynamic columns
Added virtual bool dynamic_result() to tell if type of argument may change over calls.
sql/item_cmpfunc.cc:
Added Item_func_dyncol_exists()
sql/item_cmpfunc.h:
Added class Item_func_dyncol_exists
sql/item_create.cc:
Added get_length_and_scale() to simplify other functions
Simplified and extended create_func_cast()
Added support for cast(X as double(X,Y))
Added functions to create dynamic column functions.
sql/item_create.h:
Added prototypes
sql/item_func.cc:
Extended cast functions Item_func_signed() and Item_func_unsigned() to work with dynamic types
Added Item_double_typecast()
sql/item_func.h:
Added class Item_double_typecast()
sql/item_strfunc.cc:
Added functions for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_strfunc.h:
Added classes for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_timefunc.cc:
Added flag argument to str_to_time_with_warn()
Updated Item_char_typecast() to handle result type that may change between calls (for dynamic columns)
Added Item_time_typecast::get_date() to ensure that we cast a datetime to time properly.
sql/item_timefunc.h:
Added get_date() to Item_time_typecast() to allow proper results for casting time to datetime
sql/lex.h:
Added new SQL function names
sql/my_decimal.cc:
Added 'const' to some arguments.
Better error message in case of errors (we now print out the wrong value)
Added my_decimal2int()
sql/my_decimal.h:
Moved some constants to my_decimal_limits.h
Updated prototypes.
Made my_decimal2int() a function as it's rather long (no reason to have it inline)
Added decimal2my_decimal() function.
sql/mysql_priv.h:
Prototypes for new functions
sql/share/errmsg.txt:
New error messages for wrong casts and dynamic columns
sql/sql_acl.cc:
Fixed indentation
sql/sql_base.cc:
Added dynamic_column_error_message()
sql/sql_string.h:
Added reassociate() to move a buffer to be owned by String object.
sql/sql_yacc.yy:
Added syntax for COLUMN_ functions.
sql/time.cc:
Updated str_to_datetime_with_warn() flag argument to same type as other functions
Added conversion flag to str_to_time_with_warn() (Similar to all datetime functions)
Added conversion functions with warnings: double_to_datetime_with_warn() and decimal_to_datetime_with_warn()
strings/decimal.c:
Added 'const' to arguments for some functions.
unittest/mysys/Makefile.am:
Added test for dynamic columns code
2011-05-08 12:24:06 +02:00
|
|
|
int decimal2ulonglong(const decimal_t *from, ulonglong *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
dec1 *buf=from->buf;
|
|
|
|
ulonglong x=0;
|
2004-11-27 12:35:21 +01:00
|
|
|
int intg, frac;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
if (from->sign)
|
|
|
|
{
|
2013-04-07 14:00:16 +02:00
|
|
|
*to= 0;
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (intg=from->intg; intg > 0; intg-=DIG_PER_DEC1)
|
|
|
|
{
|
2021-11-22 06:58:46 +01:00
|
|
|
/*
|
|
|
|
Check that the decimal is bigger than any possible integer.
|
|
|
|
Do it before we do the x*=DIB_BASE to avoid integer
|
|
|
|
overflow.
|
|
|
|
*/
|
|
|
|
if (unlikely (
|
|
|
|
x >= ULONGLONG_MAX/DIG_BASE &&
|
|
|
|
(x > ULONGLONG_MAX/DIG_BASE ||
|
|
|
|
*buf > (dec1) (ULONGLONG_MAX%DIG_BASE))))
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2006-10-30 06:52:50 +01:00
|
|
|
*to=ULONGLONG_MAX;
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OVERFLOW;
|
|
|
|
}
|
2021-11-22 06:58:46 +01:00
|
|
|
|
|
|
|
x=x*DIG_BASE + *buf++;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
*to=x;
|
2004-11-27 12:35:21 +01:00
|
|
|
for (frac=from->frac; unlikely(frac > 0); frac-=DIG_PER_DEC1)
|
|
|
|
if (*buf++)
|
|
|
|
return E_DEC_TRUNCATED;
|
|
|
|
return E_DEC_OK;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
Adding support for Dynamic columns (WL#34):
- COLUMN_CREATE(column_nr, value, [column_nr,value]...)
- COLUMN_ADD(blob,column_nr, value, column_nr,value]...)
- COLUMN_DELETE(blob, column_nr, column_nr...)
- COLUMN_EXISTS(blob, column_nr)
- COLUMN_LIST(blob, column_nr)
- COLUMN_GET(string, column_nr AS type)
Added cast(X as DOUBLE) and cast(x as INT)
Better warning and error messages for wrong cast's
Created some sub functions to simplify and reuse code.
Added a lot of conversation functions with error/warnings for what went wrong.
Fixed some issues when casting time to datetime.
Added functions to dynamic strings and Strings to allow one to move a string buffer from dynamic strings to String (to save malloc+ copy)
Added dynamic columns library to libmysqlclient
include/Makefile.am:
Added ma_dyncol.h
include/decimal.h:
Added 'const' to arguments for some functions.
include/my_sys.h:
Added dynstr_reassociate()
include/my_time.h:
Added TIME_SUBSECOND_RANGE
Added double_to_datetime()
Added flag argument to str_to_time()
libmysql/CMakeLists.txt:
Added mysys/ma_dyncol.c
libmysql/Makefile.shared:
Added ma_dyncol
libmysql/libmysql.c:
Added argument to str_to_time()
mysql-test/r/bigint.result:
Better error messages
mysql-test/r/cast.result:
Better warning and error messages
A lot of new cast() tests
mysql-test/r/func_math.result:
Better warning messages
mysql-test/r/func_str.result:
Better warning messages
mysql-test/r/func_time.result:
Better warning messages
mysql-test/r/sp-vars.result:
Better warning messages
mysql-test/r/strict.result:
Better warning messages
New test result
mysql-test/r/type_newdecimal.result:
Better warning messages
mysql-test/r/warnings.result:
Better warning messages
mysql-test/suite/funcs_1/r/innodb_func_view.result:
Updated results after better cast warnings
mysql-test/suite/funcs_1/r/memory_func_view.result:
Updated results after better cast warnings
mysql-test/suite/funcs_1/r/myisam_func_view.result:
Updated results after better cast warnings
mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test:
Added begin...commit to speed up test.
mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc:
Added begin...commit to speed up test.
mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc:
Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_innodb.result:
Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_myisam.result:
Added begin...commit to speed up test.
mysql-test/suite/parts/r/rpl_partition.result:
Added begin...commit to speed up test.
mysql-test/suite/parts/t/part_supported_sql_func_innodb.test:
Removed duplicated --big_test
mysql-test/suite/parts/t/rpl_partition.test:
Added begin...commit to speed up test.
mysql-test/suite/pbxt/r/cast.result:
Updated results after better cast warnings
mysql-test/suite/pbxt/r/func_str.result:
Updated results after better cast warnings
mysql-test/suite/pbxt/r/type_newdecimal.result:
Updated results after better cast warnings
mysql-test/suite/rpl/r/rpl_innodb_bug28430.result:
Added begin...commit to speed up test.
mysql-test/suite/rpl/t/rpl_innodb_bug28430.test:
Added begin...commit to speed up test.
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result:
More warnings
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result:
More warnings
mysql-test/t/cast.test:
A lot of new cast() tests
mysql-test/t/strict.test:
Added new test
mysys/CMakeLists.txt:
Added ma_dyncol.c
mysys/Makefile.am:
Added ma_dyncol.c
mysys/string.c:
Added dynstr_reassociate() to move a buffer from dynamic_strings to some other allocator
sql-common/my_time.c:
Added 'fuzzydate' flag to str_to_time()
Added support for microseconds to my_time_to_str() and my_datetime_to_str()
Reset second_parts in number_to_datetime()
Added double_to_datetime()
sql/field.cc:
Added double_to_longlong() and truncate_double() to simplify and reuse code
sql/field.h:
New prototypes
sql/item.cc:
Changed Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) to be aware of type of argument.
(Needed to make it microsecond safe and get better warnings).
Updated call to str_to_time_with_warn()
sql/item.h:
Added struct st_dyncall_create_def used by dynamic columns
Added virtual bool dynamic_result() to tell if type of argument may change over calls.
sql/item_cmpfunc.cc:
Added Item_func_dyncol_exists()
sql/item_cmpfunc.h:
Added class Item_func_dyncol_exists
sql/item_create.cc:
Added get_length_and_scale() to simplify other functions
Simplified and extended create_func_cast()
Added support for cast(X as double(X,Y))
Added functions to create dynamic column functions.
sql/item_create.h:
Added prototypes
sql/item_func.cc:
Extended cast functions Item_func_signed() and Item_func_unsigned() to work with dynamic types
Added Item_double_typecast()
sql/item_func.h:
Added class Item_double_typecast()
sql/item_strfunc.cc:
Added functions for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_strfunc.h:
Added classes for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_timefunc.cc:
Added flag argument to str_to_time_with_warn()
Updated Item_char_typecast() to handle result type that may change between calls (for dynamic columns)
Added Item_time_typecast::get_date() to ensure that we cast a datetime to time properly.
sql/item_timefunc.h:
Added get_date() to Item_time_typecast() to allow proper results for casting time to datetime
sql/lex.h:
Added new SQL function names
sql/my_decimal.cc:
Added 'const' to some arguments.
Better error message in case of errors (we now print out the wrong value)
Added my_decimal2int()
sql/my_decimal.h:
Moved some constants to my_decimal_limits.h
Updated prototypes.
Made my_decimal2int() a function as it's rather long (no reason to have it inline)
Added decimal2my_decimal() function.
sql/mysql_priv.h:
Prototypes for new functions
sql/share/errmsg.txt:
New error messages for wrong casts and dynamic columns
sql/sql_acl.cc:
Fixed indentation
sql/sql_base.cc:
Added dynamic_column_error_message()
sql/sql_string.h:
Added reassociate() to move a buffer to be owned by String object.
sql/sql_yacc.yy:
Added syntax for COLUMN_ functions.
sql/time.cc:
Updated str_to_datetime_with_warn() flag argument to same type as other functions
Added conversion flag to str_to_time_with_warn() (Similar to all datetime functions)
Added conversion functions with warnings: double_to_datetime_with_warn() and decimal_to_datetime_with_warn()
strings/decimal.c:
Added 'const' to arguments for some functions.
unittest/mysys/Makefile.am:
Added test for dynamic columns code
2011-05-08 12:24:06 +02:00
|
|
|
int decimal2longlong(const decimal_t *from, longlong *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
dec1 *buf=from->buf;
|
|
|
|
longlong x=0;
|
2004-11-27 13:54:51 +01:00
|
|
|
int intg, frac;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
for (intg=from->intg; intg > 0; intg-=DIG_PER_DEC1)
|
|
|
|
{
|
|
|
|
/*
|
2021-11-22 06:58:46 +01:00
|
|
|
Check that the decimal is less than any possible integer.
|
|
|
|
Do it before we do the x*=DIB_BASE to avoid integer
|
|
|
|
overflow.
|
2004-10-18 14:06:46 +02:00
|
|
|
Attention: trick!
|
|
|
|
we're calculating -|from| instead of |from| here
|
2004-11-27 13:54:51 +01:00
|
|
|
because |LONGLONG_MIN| > LONGLONG_MAX
|
2021-11-22 06:58:46 +01:00
|
|
|
so we can convert -9223372036854775808 correctly.
|
2004-10-18 14:06:46 +02:00
|
|
|
*/
|
2021-11-22 06:58:46 +01:00
|
|
|
if (unlikely (
|
|
|
|
x <= LONGLONG_MIN/DIG_BASE &&
|
|
|
|
(x < LONGLONG_MIN/DIG_BASE ||
|
|
|
|
*buf > (dec1) (-(LONGLONG_MIN%DIG_BASE)))))
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2007-05-16 07:12:49 +02:00
|
|
|
/*
|
2021-11-22 06:58:46 +01:00
|
|
|
the decimal is bigger than any possible integer
|
|
|
|
return border integer depending on the sign
|
2007-05-16 07:12:49 +02:00
|
|
|
*/
|
|
|
|
*to= from->sign ? LONGLONG_MIN : LONGLONG_MAX;
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OVERFLOW;
|
|
|
|
}
|
2021-11-22 06:58:46 +01:00
|
|
|
|
|
|
|
x=x*DIG_BASE - *buf++;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
/* boundary case: 9223372036854775808 */
|
2005-12-23 20:50:28 +01:00
|
|
|
if (unlikely(from->sign==0 && x == LONGLONG_MIN))
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-12-23 20:50:28 +01:00
|
|
|
*to= LONGLONG_MAX;
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*to=from->sign ? x : -x;
|
2004-11-27 13:54:51 +01:00
|
|
|
for (frac=from->frac; unlikely(frac > 0); frac-=DIG_PER_DEC1)
|
|
|
|
if (*buf++)
|
|
|
|
return E_DEC_TRUNCATED;
|
|
|
|
return E_DEC_OK;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2004-10-19 14:38:54 +02:00
|
|
|
/*
|
|
|
|
Convert decimal to its binary fixed-length representation
|
|
|
|
two representations of the same length can be compared with memcmp
|
|
|
|
with the correct -1/0/+1 result
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal2bin()
|
|
|
|
from - value to convert
|
|
|
|
to - points to buffer where string representation should be stored
|
|
|
|
precision/scale - see decimal_bin_size() below
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
the buffer is assumed to be of the size decimal_bin_size(precision, scale)
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW
|
2005-02-20 17:25:22 +01:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
for storage decimal numbers are converted to the "binary" format.
|
|
|
|
|
|
|
|
This format has the following properties:
|
|
|
|
1. length of the binary representation depends on the {precision, scale}
|
|
|
|
as provided by the caller and NOT on the intg/frac of the decimal to
|
|
|
|
convert.
|
|
|
|
2. binary representations of the same {precision, scale} can be compared
|
|
|
|
with memcmp - with the same result as decimal_cmp() of the original
|
|
|
|
decimals (not taking into account possible precision loss during
|
|
|
|
conversion).
|
|
|
|
|
|
|
|
This binary format is as follows:
|
|
|
|
1. First the number is converted to have a requested precision and scale.
|
|
|
|
2. Every full DIG_PER_DEC1 digits of intg part are stored in 4 bytes
|
|
|
|
as is
|
|
|
|
3. The first intg % DIG_PER_DEC1 digits are stored in the reduced
|
|
|
|
number of bytes (enough bytes to store this number of digits -
|
|
|
|
see dig2bytes)
|
2005-03-21 13:58:34 +01:00
|
|
|
4. same for frac - full decimal_digit_t's are stored as is,
|
2005-02-20 17:25:22 +01:00
|
|
|
the last frac % DIG_PER_DEC1 digits - in the reduced number of bytes.
|
|
|
|
5. If the number is negative - every byte is inversed.
|
|
|
|
5. The very first bit of the resulting byte array is inverted (because
|
|
|
|
memcmp compares unsigned bytes, see property 2 above)
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
1234567890.1234
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
internally is represented as 3 decimal_digit_t's
|
2005-02-20 17:25:22 +01:00
|
|
|
|
|
|
|
1 234567890 123400000
|
|
|
|
|
|
|
|
(assuming we want a binary representation with precision=14, scale=4)
|
|
|
|
in hex it's
|
|
|
|
|
|
|
|
00-00-00-01 0D-FB-38-D2 07-5A-EF-40
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
now, middle decimal_digit_t is full - it stores 9 decimal digits. It goes
|
2005-02-20 17:25:22 +01:00
|
|
|
into binary representation as is:
|
|
|
|
|
|
|
|
|
|
|
|
........... 0D-FB-38-D2 ............
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
First decimal_digit_t has only one decimal digit. We can store one digit in
|
2005-02-20 17:25:22 +01:00
|
|
|
one byte, no need to waste four:
|
|
|
|
|
|
|
|
01 0D-FB-38-D2 ............
|
|
|
|
|
|
|
|
now, last digit. It's 123400000. We can store 1234 in two bytes:
|
|
|
|
|
|
|
|
01 0D-FB-38-D2 04-D2
|
|
|
|
|
|
|
|
So, we've packed 12 bytes number in 7 bytes.
|
|
|
|
And now we invert the highest bit to get the final result:
|
|
|
|
|
|
|
|
81 0D FB 38 D2 04 D2
|
|
|
|
|
|
|
|
And for -1234567890.1234 it would be
|
|
|
|
|
2012-11-17 16:50:15 +01:00
|
|
|
7E F2 04 C7 2D FB 2D
|
2004-10-19 14:38:54 +02:00
|
|
|
*/
|
2020-08-27 11:24:32 +02:00
|
|
|
int decimal2bin(const decimal_t *from, uchar *to, decimal_digits_t precision,
|
|
|
|
decimal_digits_t frac)
|
2004-10-19 14:38:54 +02:00
|
|
|
{
|
|
|
|
dec1 mask=from->sign ? -1 : 0, *buf1=from->buf, *stop1;
|
|
|
|
int error=E_DEC_OK, intg=precision-frac,
|
2020-08-27 11:24:32 +02:00
|
|
|
isize1, intg1, intg1x,
|
2004-10-19 14:38:54 +02:00
|
|
|
intg0=intg/DIG_PER_DEC1,
|
|
|
|
frac0=frac/DIG_PER_DEC1,
|
|
|
|
intg0x=intg-intg0*DIG_PER_DEC1,
|
|
|
|
frac0x=frac-frac0*DIG_PER_DEC1,
|
|
|
|
frac1=from->frac/DIG_PER_DEC1,
|
|
|
|
frac1x=from->frac-frac1*DIG_PER_DEC1,
|
|
|
|
isize0=intg0*sizeof(dec1)+dig2bytes[intg0x],
|
|
|
|
fsize0=frac0*sizeof(dec1)+dig2bytes[frac0x],
|
|
|
|
fsize1=frac1*sizeof(dec1)+dig2bytes[frac1x];
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t from_intg;
|
2005-05-10 08:25:25 +02:00
|
|
|
const int orig_isize0= isize0;
|
|
|
|
const int orig_fsize0= fsize0;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
uchar *orig_to= to;
|
2004-11-04 13:27:44 +01:00
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
buf1= remove_leading_zeroes(from, &from_intg);
|
2004-11-04 13:27:44 +01:00
|
|
|
|
2004-12-03 00:11:30 +01:00
|
|
|
if (unlikely(from_intg+fsize1==0))
|
2004-11-04 13:27:44 +01:00
|
|
|
{
|
|
|
|
mask=0; /* just in case */
|
|
|
|
intg=1;
|
|
|
|
buf1=&mask;
|
|
|
|
}
|
|
|
|
|
2004-12-03 00:11:30 +01:00
|
|
|
intg1=from_intg/DIG_PER_DEC1;
|
|
|
|
intg1x=from_intg-intg1*DIG_PER_DEC1;
|
2004-11-04 13:27:44 +01:00
|
|
|
isize1=intg1*sizeof(dec1)+dig2bytes[intg1x];
|
|
|
|
|
2004-12-03 00:11:30 +01:00
|
|
|
if (intg < from_intg)
|
2004-10-19 14:38:54 +02:00
|
|
|
{
|
|
|
|
buf1+=intg1-intg0+(intg1x>0)-(intg0x>0);
|
|
|
|
intg1=intg0; intg1x=intg0x;
|
|
|
|
error=E_DEC_OVERFLOW;
|
|
|
|
}
|
|
|
|
else if (isize0 > isize1)
|
|
|
|
{
|
|
|
|
while (isize0-- > isize1)
|
|
|
|
*to++= (char)mask;
|
|
|
|
}
|
|
|
|
if (fsize0 < fsize1)
|
|
|
|
{
|
|
|
|
frac1=frac0; frac1x=frac0x;
|
|
|
|
error=E_DEC_TRUNCATED;
|
|
|
|
}
|
|
|
|
else if (fsize0 > fsize1 && frac1x)
|
|
|
|
{
|
|
|
|
if (frac0 == frac1)
|
2005-03-07 13:08:06 +01:00
|
|
|
{
|
2004-10-19 14:38:54 +02:00
|
|
|
frac1x=frac0x;
|
2005-03-07 13:08:06 +01:00
|
|
|
fsize0= fsize1;
|
|
|
|
}
|
2004-10-19 14:38:54 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
frac1++;
|
|
|
|
frac1x=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* intg1x part */
|
|
|
|
if (intg1x)
|
|
|
|
{
|
|
|
|
int i=dig2bytes[intg1x];
|
|
|
|
dec1 x=(*buf1++ % powers10[intg1x]) ^ mask;
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 1: mi_int1store(to, x); break;
|
|
|
|
case 2: mi_int2store(to, x); break;
|
|
|
|
case 3: mi_int3store(to, x); break;
|
|
|
|
case 4: mi_int4store(to, x); break;
|
|
|
|
default: DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
to+=i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* intg1+frac1 part */
|
|
|
|
for (stop1=buf1+intg1+frac1; buf1 < stop1; to+=sizeof(dec1))
|
|
|
|
{
|
|
|
|
dec1 x=*buf1++ ^ mask;
|
|
|
|
DBUG_ASSERT(sizeof(dec1) == 4);
|
|
|
|
mi_int4store(to, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* frac1x part */
|
|
|
|
if (frac1x)
|
|
|
|
{
|
2004-12-27 23:17:09 +01:00
|
|
|
dec1 x;
|
|
|
|
int i=dig2bytes[frac1x],
|
|
|
|
lim=(frac1 < frac0 ? DIG_PER_DEC1 : frac0x);
|
|
|
|
while (frac1x < lim && dig2bytes[frac1x] == i)
|
|
|
|
frac1x++;
|
|
|
|
x=(*buf1 / powers10[DIG_PER_DEC1 - frac1x]) ^ mask;
|
2004-10-19 14:38:54 +02:00
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 1: mi_int1store(to, x); break;
|
|
|
|
case 2: mi_int2store(to, x); break;
|
|
|
|
case 3: mi_int3store(to, x); break;
|
|
|
|
case 4: mi_int4store(to, x); break;
|
|
|
|
default: DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
to+=i;
|
|
|
|
}
|
|
|
|
if (fsize0 > fsize1)
|
|
|
|
{
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
uchar *to_end= orig_to + orig_fsize0 + orig_isize0;
|
2005-05-10 08:25:25 +02:00
|
|
|
|
|
|
|
while (fsize0-- > fsize1 && to < to_end)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
*to++= (uchar)mask;
|
2004-10-19 14:38:54 +02:00
|
|
|
}
|
2005-02-08 23:50:45 +01:00
|
|
|
orig_to[0]^= 0x80;
|
2005-05-10 08:25:25 +02:00
|
|
|
|
|
|
|
/* Check that we have written the whole decimal and nothing more */
|
|
|
|
DBUG_ASSERT(to == orig_to + orig_fsize0 + orig_isize0);
|
2004-10-19 14:38:54 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Restores decimal from its binary fixed-length representation
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
bin2decimal()
|
|
|
|
from - value to convert
|
|
|
|
to - result
|
|
|
|
precision/scale - see decimal_bin_size() below
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
see decimal2bin()
|
|
|
|
the buffer is assumed to be of the size decimal_bin_size(precision, scale)
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW
|
|
|
|
*/
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
int bin2decimal(const uchar *from, decimal_t *to, decimal_digits_t precision,
|
|
|
|
decimal_digits_t scale)
|
2004-10-19 14:38:54 +02:00
|
|
|
{
|
|
|
|
int error=E_DEC_OK, intg=precision-scale,
|
|
|
|
intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
|
|
|
|
intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1,
|
|
|
|
intg1=intg0+(intg0x>0), frac1=frac0+(frac0x>0);
|
2005-02-12 22:36:35 +01:00
|
|
|
dec1 *buf=to->buf, mask=(*from & 0x80) ? 0 : -1;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
const uchar *stop;
|
|
|
|
uchar *d_copy;
|
2005-02-08 23:50:45 +01:00
|
|
|
int bin_size= decimal_bin_size(precision, scale);
|
2004-10-19 14:38:54 +02:00
|
|
|
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
d_copy= (uchar*) my_alloca(bin_size);
|
2005-02-08 23:50:45 +01:00
|
|
|
memcpy(d_copy, from, bin_size);
|
|
|
|
d_copy[0]^= 0x80;
|
|
|
|
from= d_copy;
|
2004-10-30 19:27:54 +02:00
|
|
|
|
2004-10-19 14:38:54 +02:00
|
|
|
FIX_INTG_FRAC_ERROR(to->len, intg1, frac1, error);
|
|
|
|
if (unlikely(error))
|
|
|
|
{
|
|
|
|
if (intg1 < intg0+(intg0x>0))
|
|
|
|
{
|
|
|
|
from+=dig2bytes[intg0x]+sizeof(dec1)*(intg0-intg1);
|
|
|
|
frac0=frac0x=intg0x=0;
|
|
|
|
intg0=intg1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frac0x=0;
|
|
|
|
frac0=frac1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
to->sign=(mask != 0);
|
|
|
|
to->intg=intg0*DIG_PER_DEC1+intg0x;
|
|
|
|
to->frac=frac0*DIG_PER_DEC1+frac0x;
|
|
|
|
|
|
|
|
if (intg0x)
|
|
|
|
{
|
|
|
|
int i=dig2bytes[intg0x];
|
2009-08-28 17:51:31 +02:00
|
|
|
dec1 UNINIT_VAR(x);
|
2004-10-19 14:38:54 +02:00
|
|
|
switch (i)
|
|
|
|
{
|
2004-11-02 13:55:44 +01:00
|
|
|
case 1: x=mi_sint1korr(from); break;
|
|
|
|
case 2: x=mi_sint2korr(from); break;
|
|
|
|
case 3: x=mi_sint3korr(from); break;
|
|
|
|
case 4: x=mi_sint4korr(from); break;
|
2018-02-20 22:17:36 +01:00
|
|
|
default: abort();
|
2004-10-19 14:38:54 +02:00
|
|
|
}
|
|
|
|
from+=i;
|
|
|
|
*buf=x ^ mask;
|
2006-11-20 21:42:06 +01:00
|
|
|
if (((ulonglong)*buf) >= (ulonglong) powers10[intg0x+1])
|
2006-02-28 10:36:41 +01:00
|
|
|
goto err;
|
2004-10-19 14:38:54 +02:00
|
|
|
if (buf > to->buf || *buf != 0)
|
|
|
|
buf++;
|
|
|
|
else
|
|
|
|
to->intg-=intg0x;
|
|
|
|
}
|
|
|
|
for (stop=from+intg0*sizeof(dec1); from < stop; from+=sizeof(dec1))
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(sizeof(dec1) == 4);
|
2004-11-02 13:55:44 +01:00
|
|
|
*buf=mi_sint4korr(from) ^ mask;
|
2006-02-28 10:36:41 +01:00
|
|
|
if (((uint32)*buf) > DIG_MAX)
|
|
|
|
goto err;
|
2004-10-19 14:38:54 +02:00
|
|
|
if (buf > to->buf || *buf != 0)
|
|
|
|
buf++;
|
|
|
|
else
|
|
|
|
to->intg-=DIG_PER_DEC1;
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(to->intg >=0);
|
|
|
|
for (stop=from+frac0*sizeof(dec1); from < stop; from+=sizeof(dec1))
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(sizeof(dec1) == 4);
|
2004-11-02 13:55:44 +01:00
|
|
|
*buf=mi_sint4korr(from) ^ mask;
|
2006-02-28 10:36:41 +01:00
|
|
|
if (((uint32)*buf) > DIG_MAX)
|
|
|
|
goto err;
|
2004-10-19 14:38:54 +02:00
|
|
|
buf++;
|
|
|
|
}
|
|
|
|
if (frac0x)
|
|
|
|
{
|
|
|
|
int i=dig2bytes[frac0x];
|
2009-08-28 17:51:31 +02:00
|
|
|
dec1 UNINIT_VAR(x);
|
2004-10-19 14:38:54 +02:00
|
|
|
switch (i)
|
|
|
|
{
|
2004-11-02 13:55:44 +01:00
|
|
|
case 1: x=mi_sint1korr(from); break;
|
|
|
|
case 2: x=mi_sint2korr(from); break;
|
|
|
|
case 3: x=mi_sint3korr(from); break;
|
|
|
|
case 4: x=mi_sint4korr(from); break;
|
2018-02-20 22:17:36 +01:00
|
|
|
default: abort();
|
2004-10-19 14:38:54 +02:00
|
|
|
}
|
|
|
|
*buf=(x ^ mask) * powers10[DIG_PER_DEC1 - frac0x];
|
2006-02-28 10:36:41 +01:00
|
|
|
if (((uint32)*buf) > DIG_MAX)
|
|
|
|
goto err;
|
2004-10-19 14:38:54 +02:00
|
|
|
buf++;
|
|
|
|
}
|
2005-02-08 23:50:45 +01:00
|
|
|
my_afree(d_copy);
|
2011-08-29 11:24:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
No digits? We have read the number zero, of unspecified precision.
|
|
|
|
Make it a proper zero, with non-zero precision.
|
|
|
|
*/
|
|
|
|
if (to->intg == 0 && to->frac == 0)
|
|
|
|
decimal_make_zero(to);
|
2004-10-19 14:38:54 +02:00
|
|
|
return error;
|
2006-02-28 10:36:41 +01:00
|
|
|
|
|
|
|
err:
|
|
|
|
my_afree(d_copy);
|
2011-08-29 11:24:36 +02:00
|
|
|
decimal_make_zero(to);
|
2006-02-28 10:36:41 +01:00
|
|
|
return(E_DEC_BAD_NUM);
|
2004-10-19 14:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Returns the size of array to hold a decimal with given precision and scale
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
size in dec1
|
|
|
|
(multiply by sizeof(dec1) to get the size if bytes)
|
|
|
|
*/
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
uint decimal_size(decimal_digits_t precision, decimal_digits_t scale)
|
2004-10-19 14:38:54 +02:00
|
|
|
{
|
2020-08-27 11:24:32 +02:00
|
|
|
DBUG_ASSERT(precision > 0 && scale <= precision);
|
2004-10-19 14:38:54 +02:00
|
|
|
return ROUND_UP(precision-scale)+ROUND_UP(scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Returns the size of array to hold a binary representation of a decimal
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
size in bytes
|
|
|
|
*/
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
uint decimal_bin_size(decimal_digits_t precision, decimal_digits_t scale)
|
2004-10-19 14:38:54 +02:00
|
|
|
{
|
|
|
|
int intg=precision-scale,
|
|
|
|
intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
|
|
|
|
intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
|
|
|
|
|
2013-03-06 20:10:58 +01:00
|
|
|
DBUG_ASSERT(precision > 0);
|
|
|
|
DBUG_ASSERT(scale <= precision);
|
2004-10-19 14:38:54 +02:00
|
|
|
return intg0*sizeof(dec1)+dig2bytes[intg0x]+
|
|
|
|
frac0*sizeof(dec1)+dig2bytes[frac0x];
|
|
|
|
}
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/*
|
|
|
|
Rounds the decimal to "scale" digits
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal_round()
|
2004-10-29 00:22:54 +02:00
|
|
|
from - decimal to round,
|
|
|
|
to - result buffer. from==to is allowed
|
2004-10-18 14:06:46 +02:00
|
|
|
scale - to what position to round. can be negative!
|
|
|
|
mode - round to nearest even or truncate
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
scale can be negative !
|
|
|
|
one TRUNCATED error (line XXX below) isn't treated very logical :(
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_TRUNCATED
|
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
int
|
2011-03-03 15:25:41 +01:00
|
|
|
decimal_round(const decimal_t *from, decimal_t *to, int scale,
|
2005-03-21 13:58:34 +01:00
|
|
|
decimal_round_mode mode)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2004-11-02 09:45:03 +01:00
|
|
|
int frac0=scale>0 ? ROUND_UP(scale) : scale/DIG_PER_DEC1,
|
2009-08-28 17:51:31 +02:00
|
|
|
frac1=ROUND_UP(from->frac), UNINIT_VAR(round_digit),
|
2011-10-14 10:09:53 +02:00
|
|
|
intg0=ROUND_UP(from->intg), error=E_DEC_OK, len=to->len;
|
|
|
|
|
2004-10-29 00:22:54 +02:00
|
|
|
dec1 *buf0=from->buf, *buf1=to->buf, x, y, carry=0;
|
2005-07-12 11:17:59 +02:00
|
|
|
int first_dig;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
|
|
|
|
2004-11-03 18:43:48 +01:00
|
|
|
switch (mode) {
|
|
|
|
case HALF_UP:
|
|
|
|
case HALF_EVEN: round_digit=5; break;
|
|
|
|
case CEILING: round_digit= from->sign ? 10 : 0; break;
|
|
|
|
case FLOOR: round_digit= from->sign ? 0 : 10; break;
|
|
|
|
case TRUNCATE: round_digit=10; break;
|
|
|
|
default: DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
|
2011-10-14 10:09:53 +02:00
|
|
|
/*
|
|
|
|
For my_decimal we always use len == DECIMAL_BUFF_LENGTH == 9
|
|
|
|
For internal testing here (ifdef MAIN) we always use len == 100/4
|
|
|
|
*/
|
|
|
|
DBUG_ASSERT(from->len == to->len);
|
|
|
|
|
2004-10-29 00:22:54 +02:00
|
|
|
if (unlikely(frac0+intg0 > len))
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2004-10-29 00:22:54 +02:00
|
|
|
frac0=len-intg0;
|
|
|
|
scale=frac0*DIG_PER_DEC1;
|
|
|
|
error=E_DEC_TRUNCATED;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2004-12-03 00:11:30 +01:00
|
|
|
if (scale+from->intg < 0)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2004-10-29 00:22:54 +02:00
|
|
|
decimal_make_zero(to);
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-14 10:09:53 +02:00
|
|
|
if (to != from)
|
2004-10-29 00:22:54 +02:00
|
|
|
{
|
2013-03-25 23:03:13 +01:00
|
|
|
dec1 *p0= buf0+intg0+MY_MAX(frac1, frac0);
|
|
|
|
dec1 *p1= buf1+intg0+MY_MAX(frac1, frac0);
|
2011-10-14 10:09:53 +02:00
|
|
|
|
|
|
|
DBUG_ASSERT(p0 - buf0 <= len);
|
|
|
|
DBUG_ASSERT(p1 - buf1 <= len);
|
2005-02-08 23:50:45 +01:00
|
|
|
|
|
|
|
while (buf0 < p0)
|
|
|
|
*(--p1) = *(--p0);
|
|
|
|
|
|
|
|
buf0=to->buf;
|
2004-10-29 00:22:54 +02:00
|
|
|
buf1=to->buf;
|
|
|
|
to->sign=from->sign;
|
2013-03-25 23:03:13 +01:00
|
|
|
to->intg=MY_MIN(intg0, len)*DIG_PER_DEC1;
|
2004-10-29 00:22:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frac0 > frac1)
|
|
|
|
{
|
|
|
|
buf1+=intg0+frac1;
|
|
|
|
while (frac0-- > frac1)
|
|
|
|
*buf1++=0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scale >= from->frac)
|
|
|
|
goto done; /* nothing to do */
|
|
|
|
|
|
|
|
buf0+=intg0+frac0-1;
|
|
|
|
buf1+=intg0+frac0-1;
|
2004-10-18 14:06:46 +02:00
|
|
|
if (scale == frac0*DIG_PER_DEC1)
|
|
|
|
{
|
2005-06-15 16:53:40 +02:00
|
|
|
int do_inc= FALSE;
|
2004-12-06 13:06:52 +01:00
|
|
|
DBUG_ASSERT(frac0+intg0 >= 0);
|
2005-07-04 02:42:33 +02:00
|
|
|
switch (round_digit) {
|
2005-06-15 16:53:40 +02:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
dec1 *p0= buf0 + (frac1-frac0);
|
|
|
|
for (; p0 > buf0; p0--)
|
2005-07-04 02:42:33 +02:00
|
|
|
{
|
2005-06-15 16:53:40 +02:00
|
|
|
if (*p0)
|
|
|
|
{
|
|
|
|
do_inc= TRUE;
|
|
|
|
break;
|
2005-07-04 02:42:33 +02:00
|
|
|
}
|
|
|
|
}
|
2005-06-15 16:53:40 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
x= buf0[1]/DIG_MASK;
|
|
|
|
do_inc= (x>5) || ((x == 5) &&
|
|
|
|
(mode == HALF_UP || (frac0+intg0 > 0 && *buf0 & 1)));
|
|
|
|
break;
|
2005-07-04 02:42:33 +02:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-06-15 16:53:40 +02:00
|
|
|
if (do_inc)
|
2004-12-06 13:06:52 +01:00
|
|
|
{
|
|
|
|
if (frac0+intg0>0)
|
|
|
|
(*buf1)++;
|
|
|
|
else
|
|
|
|
*(++buf1)=DIG_BASE;
|
|
|
|
}
|
2005-02-20 16:55:11 +01:00
|
|
|
else if (frac0+intg0==0)
|
|
|
|
{
|
|
|
|
decimal_make_zero(to);
|
|
|
|
return E_DEC_OK;
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-15 16:53:40 +02:00
|
|
|
/* TODO - fix this code as it won't work for CEILING mode */
|
2004-10-18 14:06:46 +02:00
|
|
|
int pos=frac0*DIG_PER_DEC1-scale-1;
|
2004-12-06 13:06:52 +01:00
|
|
|
DBUG_ASSERT(frac0+intg0 > 0);
|
2004-11-03 18:43:48 +01:00
|
|
|
x=*buf1 / powers10[pos];
|
|
|
|
y=x % 10;
|
|
|
|
if (y > round_digit ||
|
|
|
|
(round_digit == 5 && y == 5 && (mode == HALF_UP || (x/10) & 1)))
|
|
|
|
x+=10;
|
|
|
|
*buf1=powers10[pos]*(x-y);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
2004-10-31 21:30:19 +01:00
|
|
|
if (*buf1 >= DIG_BASE)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
carry=1;
|
2004-10-29 00:22:54 +02:00
|
|
|
*buf1-=DIG_BASE;
|
2004-10-31 21:30:19 +01:00
|
|
|
while (carry && --buf1 >= to->buf)
|
2004-10-29 00:22:54 +02:00
|
|
|
ADD(*buf1, *buf1, 0, carry);
|
2004-10-18 14:06:46 +02:00
|
|
|
if (unlikely(carry))
|
|
|
|
{
|
|
|
|
/* shifting the number to create space for new digit */
|
|
|
|
if (frac0+intg0 >= len)
|
|
|
|
{
|
|
|
|
frac0--;
|
|
|
|
scale=frac0*DIG_PER_DEC1;
|
|
|
|
error=E_DEC_TRUNCATED; /* XXX */
|
|
|
|
}
|
2013-03-25 23:03:13 +01:00
|
|
|
for (buf1=to->buf+intg0+MY_MAX(frac0,0); buf1 > to->buf; buf1--)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2004-10-29 00:22:54 +02:00
|
|
|
buf1[0]=buf1[-1];
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
2004-10-29 00:22:54 +02:00
|
|
|
*buf1=1;
|
2004-11-11 12:43:08 +01:00
|
|
|
to->intg++;
|
2014-03-20 09:50:45 +01:00
|
|
|
intg0++;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
}
|
2004-12-03 00:11:30 +01:00
|
|
|
else
|
|
|
|
{
|
2005-06-01 15:35:09 +02:00
|
|
|
for (;;)
|
2004-12-03 00:11:30 +01:00
|
|
|
{
|
2005-06-01 15:35:09 +02:00
|
|
|
if (likely(*buf1))
|
|
|
|
break;
|
|
|
|
if (buf1-- == to->buf)
|
|
|
|
{
|
2005-06-15 16:02:35 +02:00
|
|
|
/* making 'zero' with the proper scale */
|
|
|
|
dec1 *p0= to->buf + frac0 + 1;
|
|
|
|
to->intg=1;
|
2013-03-25 23:03:13 +01:00
|
|
|
to->frac= MY_MAX(scale, 0);
|
2005-06-15 16:02:35 +02:00
|
|
|
to->sign= 0;
|
|
|
|
for (buf1= to->buf; buf1<p0; buf1++)
|
|
|
|
*buf1= 0;
|
2005-06-01 15:35:09 +02:00
|
|
|
return E_DEC_OK;
|
|
|
|
}
|
2004-12-03 00:11:30 +01:00
|
|
|
}
|
|
|
|
}
|
2014-03-20 09:50:45 +01:00
|
|
|
/*
|
|
|
|
In case we're rounding e.g. 1.5e9 to 2.0e9, the decimal_digit_t's inside
|
|
|
|
the buffer are as follows.
|
|
|
|
|
|
|
|
Before <1, 5e8>
|
|
|
|
After <2, 5e8>
|
|
|
|
|
|
|
|
Hence we need to set the 2nd field to 0.
|
|
|
|
The same holds if we round 1.5e-9 to 2e-9.
|
|
|
|
*/
|
|
|
|
if (frac0 < frac1)
|
|
|
|
{
|
|
|
|
dec1 *buf= to->buf + ((scale == 0 && intg0 == 0) ? 1 : intg0 + frac0);
|
|
|
|
dec1 *end= to->buf + len;
|
|
|
|
|
|
|
|
while (buf < end)
|
|
|
|
*buf++=0;
|
|
|
|
}
|
2005-07-12 11:17:59 +02:00
|
|
|
|
|
|
|
/* Here we check 999.9 -> 1000 case when we need to increase intg */
|
|
|
|
first_dig= to->intg % DIG_PER_DEC1;
|
|
|
|
if (first_dig && (*buf1 >= powers10[first_dig]))
|
|
|
|
to->intg++;
|
|
|
|
|
2005-06-01 15:35:09 +02:00
|
|
|
if (scale<0)
|
|
|
|
scale=0;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
done:
|
2004-10-29 00:22:54 +02:00
|
|
|
to->frac=scale;
|
2004-10-18 14:06:46 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Returns the size of the result of the operation
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal_result_size()
|
|
|
|
from1 - operand of the unary operation or first operand of the
|
|
|
|
binary operation
|
|
|
|
from2 - second operand of the binary operation
|
|
|
|
op - operation. one char '+', '-', '*', '/' are allowed
|
|
|
|
others may be added later
|
|
|
|
param - extra param to the operation. unused for '+', '-', '*'
|
|
|
|
scale increment for '/'
|
|
|
|
|
2004-10-29 00:22:54 +02:00
|
|
|
NOTE
|
2017-11-15 05:37:32 +01:00
|
|
|
returned valued may be larger than the actual buffer required
|
2004-10-29 00:22:54 +02:00
|
|
|
in the operation, as decimal_result_size, by design, operates on
|
|
|
|
precision/scale values only and not on the actual decimal number
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
RETURN VALUE
|
|
|
|
size of to->buf array in dec1 elements. to get size in bytes
|
|
|
|
multiply by sizeof(dec1)
|
|
|
|
*/
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
uint decimal_result_size(decimal_t *from1, decimal_t *from2, char op, int param)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case '-':
|
2013-03-25 23:03:13 +01:00
|
|
|
return ROUND_UP(MY_MAX(from1->intg, from2->intg)) +
|
|
|
|
ROUND_UP(MY_MAX(from1->frac, from2->frac));
|
2004-10-18 14:06:46 +02:00
|
|
|
case '+':
|
2013-03-25 23:03:13 +01:00
|
|
|
return ROUND_UP(MY_MAX(from1->intg, from2->intg)+1) +
|
|
|
|
ROUND_UP(MY_MAX(from1->frac, from2->frac));
|
2004-10-18 14:06:46 +02:00
|
|
|
case '*':
|
|
|
|
return ROUND_UP(from1->intg+from2->intg)+
|
2004-10-19 14:38:54 +02:00
|
|
|
ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
|
2004-10-18 14:06:46 +02:00
|
|
|
case '/':
|
|
|
|
return ROUND_UP(from1->intg+from2->intg+1+from1->frac+from2->frac+param);
|
|
|
|
default: DBUG_ASSERT(0);
|
|
|
|
}
|
2020-08-27 11:24:32 +02:00
|
|
|
return 0; /* shut up the warning */
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
static int do_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
|
|
|
|
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
|
2013-03-25 23:03:13 +01:00
|
|
|
frac0=MY_MAX(frac1, frac2), intg0=MY_MAX(intg1, intg2), error;
|
2004-10-18 14:06:46 +02:00
|
|
|
dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
|
|
|
|
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/* is there a need for extra word because of carry ? */
|
|
|
|
x=intg1 > intg2 ? from1->buf[0] :
|
|
|
|
intg2 > intg1 ? from2->buf[0] :
|
|
|
|
from1->buf[0] + from2->buf[0] ;
|
2005-05-06 16:04:58 +02:00
|
|
|
if (unlikely(x > DIG_MAX-1)) /* yes, there is */
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
intg0++;
|
|
|
|
to->buf[0]=0; /* safety */
|
|
|
|
}
|
|
|
|
|
|
|
|
FIX_INTG_FRAC_ERROR(to->len, intg0, frac0, error);
|
2005-05-06 16:04:58 +02:00
|
|
|
if (unlikely(error == E_DEC_OVERFLOW))
|
|
|
|
{
|
|
|
|
max_decimal(to->len * DIG_PER_DEC1, 0, to);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
buf0=to->buf+intg0+frac0;
|
|
|
|
|
|
|
|
to->sign=from1->sign;
|
2013-03-25 23:03:13 +01:00
|
|
|
to->frac=MY_MAX(from1->frac, from2->frac);
|
2004-10-18 14:06:46 +02:00
|
|
|
to->intg=intg0*DIG_PER_DEC1;
|
|
|
|
if (unlikely(error))
|
|
|
|
{
|
|
|
|
set_if_smaller(to->frac, frac0*DIG_PER_DEC1);
|
|
|
|
set_if_smaller(frac1, frac0);
|
|
|
|
set_if_smaller(frac2, frac0);
|
|
|
|
set_if_smaller(intg1, intg0);
|
|
|
|
set_if_smaller(intg2, intg0);
|
|
|
|
}
|
|
|
|
|
2013-03-25 23:03:13 +01:00
|
|
|
/* part 1 - MY_MAX(frac) ... min (frac) */
|
2004-10-18 14:06:46 +02:00
|
|
|
if (frac1 > frac2)
|
|
|
|
{
|
|
|
|
buf1=from1->buf+intg1+frac1;
|
|
|
|
stop=from1->buf+intg1+frac2;
|
|
|
|
buf2=from2->buf+intg2+frac2;
|
|
|
|
stop2=from1->buf+(intg1 > intg2 ? intg1-intg2 : 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf1=from2->buf+intg2+frac2;
|
|
|
|
stop=from2->buf+intg2+frac1;
|
|
|
|
buf2=from1->buf+intg1+frac1;
|
|
|
|
stop2=from2->buf+(intg2 > intg1 ? intg2-intg1 : 0);
|
|
|
|
}
|
|
|
|
while (buf1 > stop)
|
|
|
|
*--buf0=*--buf1;
|
|
|
|
|
2013-03-25 23:03:13 +01:00
|
|
|
/* part 2 - MY_MIN(frac) ... MY_MIN(intg) */
|
2004-10-18 14:06:46 +02:00
|
|
|
carry=0;
|
|
|
|
while (buf1 > stop2)
|
|
|
|
{
|
|
|
|
ADD(*--buf0, *--buf1, *--buf2, carry);
|
|
|
|
}
|
|
|
|
|
2013-03-25 23:03:13 +01:00
|
|
|
/* part 3 - MY_MIN(intg) ... MY_MAX(intg) */
|
2004-10-18 14:06:46 +02:00
|
|
|
buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
|
|
|
|
((stop=from2->buf)+intg2-intg1) ;
|
|
|
|
while (buf1 > stop)
|
|
|
|
{
|
|
|
|
ADD(*--buf0, *--buf1, 0, carry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(carry))
|
|
|
|
*--buf0=1;
|
|
|
|
DBUG_ASSERT(buf0 == to->buf || buf0 == to->buf+1);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2004-10-20 15:26:03 +02:00
|
|
|
/* to=from1-from2.
|
|
|
|
if to==0, return -1/0/+1 - the result of the comparison */
|
2011-03-03 15:25:41 +01:00
|
|
|
static int do_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
|
|
|
|
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
|
2013-03-25 23:03:13 +01:00
|
|
|
int frac0=MY_MAX(frac1, frac2), error;
|
2010-09-24 00:00:32 +02:00
|
|
|
dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2;
|
|
|
|
my_bool carry=0;
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
/* let carry:=1 if from2 > from1 */
|
|
|
|
start1=buf1=from1->buf; stop1=buf1+intg1;
|
|
|
|
start2=buf2=from2->buf; stop2=buf2+intg2;
|
|
|
|
if (unlikely(*buf1 == 0))
|
|
|
|
{
|
|
|
|
while (buf1 < stop1 && *buf1 == 0)
|
|
|
|
buf1++;
|
|
|
|
start1=buf1;
|
2005-06-13 12:41:15 +02:00
|
|
|
intg1= (int) (stop1-buf1);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
if (unlikely(*buf2 == 0))
|
|
|
|
{
|
|
|
|
while (buf2 < stop2 && *buf2 == 0)
|
|
|
|
buf2++;
|
|
|
|
start2=buf2;
|
2005-06-13 12:41:15 +02:00
|
|
|
intg2= (int) (stop2-buf2);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
if (intg2 > intg1)
|
|
|
|
carry=1;
|
|
|
|
else if (intg2 == intg1)
|
|
|
|
{
|
2005-05-06 17:06:25 +02:00
|
|
|
dec1 *end1= stop1 + (frac1 - 1);
|
|
|
|
dec1 *end2= stop2 + (frac2 - 1);
|
|
|
|
while (unlikely((buf1 <= end1) && (*end1 == 0)))
|
|
|
|
end1--;
|
|
|
|
while (unlikely((buf2 <= end2) && (*end2 == 0)))
|
|
|
|
end2--;
|
2005-06-13 12:41:15 +02:00
|
|
|
frac1= (int) (end1 - stop1) + 1;
|
|
|
|
frac2= (int) (end2 - stop2) + 1;
|
2005-05-06 17:06:25 +02:00
|
|
|
while (buf1 <=end1 && buf2 <= end2 && *buf1 == *buf2)
|
2004-10-18 14:06:46 +02:00
|
|
|
buf1++, buf2++;
|
2005-05-06 17:06:25 +02:00
|
|
|
if (buf1 <= end1)
|
2005-06-01 15:35:09 +02:00
|
|
|
{
|
2005-05-06 17:06:25 +02:00
|
|
|
if (buf2 <= end2)
|
2004-10-18 14:06:46 +02:00
|
|
|
carry= *buf2 > *buf1;
|
|
|
|
else
|
|
|
|
carry= 0;
|
2005-06-01 15:35:09 +02:00
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
else
|
2005-06-01 15:35:09 +02:00
|
|
|
{
|
2005-05-06 17:06:25 +02:00
|
|
|
if (buf2 <= end2)
|
2004-10-18 14:06:46 +02:00
|
|
|
carry=1;
|
|
|
|
else /* short-circuit everything: from1 == from2 */
|
|
|
|
{
|
2004-10-20 15:26:03 +02:00
|
|
|
if (to == 0) /* decimal_cmp() */
|
|
|
|
return 0;
|
2004-10-29 00:22:54 +02:00
|
|
|
decimal_make_zero(to);
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OK;
|
|
|
|
}
|
2005-06-01 15:35:09 +02:00
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
2004-10-20 15:26:03 +02:00
|
|
|
|
|
|
|
if (to == 0) /* decimal_cmp() */
|
|
|
|
return carry == from1->sign ? 1 : -1;
|
|
|
|
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
|
|
|
|
2004-10-20 15:26:03 +02:00
|
|
|
to->sign=from1->sign;
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/* ensure that always from1 > from2 (and intg1 >= intg2) */
|
|
|
|
if (carry)
|
|
|
|
{
|
2011-03-03 15:25:41 +01:00
|
|
|
swap_variables(const decimal_t *, from1, from2);
|
2004-10-18 14:06:46 +02:00
|
|
|
swap_variables(dec1 *,start1, start2);
|
|
|
|
swap_variables(int,intg1,intg2);
|
|
|
|
swap_variables(int,frac1,frac2);
|
2010-09-24 00:00:32 +02:00
|
|
|
to->sign= !to->sign;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
|
|
|
|
buf0=to->buf+intg1+frac0;
|
|
|
|
|
2013-03-25 23:03:13 +01:00
|
|
|
to->frac=MY_MAX(from1->frac, from2->frac);
|
2004-10-18 14:06:46 +02:00
|
|
|
to->intg=intg1*DIG_PER_DEC1;
|
|
|
|
if (unlikely(error))
|
|
|
|
{
|
|
|
|
set_if_smaller(to->frac, frac0*DIG_PER_DEC1);
|
|
|
|
set_if_smaller(frac1, frac0);
|
|
|
|
set_if_smaller(frac2, frac0);
|
|
|
|
set_if_smaller(intg2, intg1);
|
|
|
|
}
|
|
|
|
carry=0;
|
|
|
|
|
2013-03-25 23:03:13 +01:00
|
|
|
/* part 1 - MY_MAX(frac) ... min (frac) */
|
2004-10-18 14:06:46 +02:00
|
|
|
if (frac1 > frac2)
|
|
|
|
{
|
|
|
|
buf1=start1+intg1+frac1;
|
|
|
|
stop1=start1+intg1+frac2;
|
|
|
|
buf2=start2+intg2+frac2;
|
2004-11-08 10:06:32 +01:00
|
|
|
while (frac0-- > frac1)
|
|
|
|
*--buf0=0;
|
2004-10-18 14:06:46 +02:00
|
|
|
while (buf1 > stop1)
|
|
|
|
*--buf0=*--buf1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf1=start1+intg1+frac1;
|
|
|
|
buf2=start2+intg2+frac2;
|
|
|
|
stop2=start2+intg2+frac1;
|
2004-11-08 10:06:32 +01:00
|
|
|
while (frac0-- > frac2)
|
|
|
|
*--buf0=0;
|
2004-10-18 14:06:46 +02:00
|
|
|
while (buf2 > stop2)
|
|
|
|
{
|
|
|
|
SUB(*--buf0, 0, *--buf2, carry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-25 23:03:13 +01:00
|
|
|
/* part 2 - MY_MIN(frac) ... intg2 */
|
2004-10-18 14:06:46 +02:00
|
|
|
while (buf2 > start2)
|
|
|
|
{
|
|
|
|
SUB(*--buf0, *--buf1, *--buf2, carry);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* part 3 - intg2 ... intg1 */
|
|
|
|
while (carry && buf1 > start1)
|
|
|
|
{
|
|
|
|
SUB(*--buf0, *--buf1, 0, carry);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (buf1 > start1)
|
|
|
|
*--buf0=*--buf1;
|
|
|
|
|
|
|
|
while (buf0 > to->buf)
|
|
|
|
*--buf0=0;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t decimal_intg(const decimal_t *from)
|
2006-08-08 13:03:42 +02:00
|
|
|
{
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t res;
|
2010-07-20 20:07:36 +02:00
|
|
|
remove_leading_zeroes(from, &res);
|
2006-08-08 13:03:42 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
if (likely(from1->sign == from2->sign))
|
|
|
|
return do_add(from1, from2, to);
|
|
|
|
return do_sub(from1, from2, to);
|
|
|
|
}
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
if (likely(from1->sign == from2->sign))
|
|
|
|
return do_sub(from1, from2, to);
|
|
|
|
return do_add(from1, from2, to);
|
|
|
|
}
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal_cmp(const decimal_t *from1, const decimal_t *from2)
|
2004-10-20 15:26:03 +02:00
|
|
|
{
|
|
|
|
if (likely(from1->sign == from2->sign))
|
|
|
|
return do_sub(from1, from2, 0);
|
|
|
|
return from1->sign > from2->sign ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal_is_zero(const decimal_t *from)
|
2004-12-06 15:08:26 +01:00
|
|
|
{
|
|
|
|
dec1 *buf1=from->buf,
|
|
|
|
*end=buf1+ROUND_UP(from->intg)+ROUND_UP(from->frac);
|
|
|
|
while (buf1 < end)
|
|
|
|
if (*buf1++)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/*
|
|
|
|
multiply two decimals
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal_mul()
|
|
|
|
from1, from2 - factors
|
|
|
|
to - product
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW;
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
in this implementation, with sizeof(dec1)=4 we have DIG_PER_DEC1=9,
|
|
|
|
and 63-digit number will take only 7 dec1 words (basically a 7-digit
|
|
|
|
"base 999999999" number). Thus there's no need in fast multiplication
|
|
|
|
algorithms, 7-digit numbers can be multiplied with a naive O(n*n)
|
|
|
|
method.
|
|
|
|
|
|
|
|
XXX if this library is to be used with huge numbers of thousands of
|
|
|
|
digits, fast multiplication must be implemented.
|
|
|
|
*/
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
|
|
|
|
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
|
|
|
|
intg0=ROUND_UP(from1->intg+from2->intg),
|
2005-09-04 18:00:00 +02:00
|
|
|
frac0=frac1+frac2, error, i, j, d_to_move;
|
2004-10-18 14:06:46 +02:00
|
|
|
dec1 *buf1=from1->buf+intg1, *buf2=from2->buf+intg2, *buf0,
|
|
|
|
*start2, *stop2, *stop1, *start0, carry;
|
|
|
|
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
|
|
|
|
2008-08-15 21:46:21 +02:00
|
|
|
i=intg0; /* save 'ideal' values */
|
2004-10-18 14:06:46 +02:00
|
|
|
j=frac0;
|
2008-08-15 21:46:21 +02:00
|
|
|
FIX_INTG_FRAC_ERROR(to->len, intg0, frac0, error); /* bound size */
|
2004-10-18 14:06:46 +02:00
|
|
|
to->sign=from1->sign != from2->sign;
|
2008-08-15 21:46:21 +02:00
|
|
|
to->frac=from1->frac+from2->frac; /* store size in digits */
|
2004-10-18 14:06:46 +02:00
|
|
|
to->intg=intg0*DIG_PER_DEC1;
|
|
|
|
|
|
|
|
if (unlikely(error))
|
|
|
|
{
|
|
|
|
set_if_smaller(to->frac, frac0*DIG_PER_DEC1);
|
|
|
|
set_if_smaller(to->intg, intg0*DIG_PER_DEC1);
|
2008-08-15 21:46:21 +02:00
|
|
|
if (unlikely(i > intg0)) /* bounded integer-part */
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
i-=intg0;
|
|
|
|
j=i >> 1;
|
|
|
|
intg1-= j;
|
|
|
|
intg2-=i-j;
|
|
|
|
frac1=frac2=0; /* frac0 is already 0 here */
|
|
|
|
}
|
2008-08-15 21:46:21 +02:00
|
|
|
else /* bounded fract part */
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
j-=frac0;
|
|
|
|
i=j >> 1;
|
2008-08-15 21:46:21 +02:00
|
|
|
if (frac1 <= frac2)
|
|
|
|
{
|
|
|
|
frac1-= i;
|
|
|
|
frac2-=j-i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frac2-= i;
|
|
|
|
frac1-=j-i;
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
start0=to->buf+intg0+frac0-1;
|
|
|
|
start2=buf2+frac2-1;
|
|
|
|
stop1=buf1-intg1;
|
|
|
|
stop2=buf2-intg2;
|
|
|
|
|
|
|
|
bzero(to->buf, (intg0+frac0)*sizeof(dec1));
|
|
|
|
|
|
|
|
for (buf1+=frac1-1; buf1 >= stop1; buf1--, start0--)
|
|
|
|
{
|
|
|
|
carry=0;
|
|
|
|
for (buf0=start0, buf2=start2; buf2 >= stop2; buf2--, buf0--)
|
|
|
|
{
|
|
|
|
dec1 hi, lo;
|
|
|
|
dec2 p= ((dec2)*buf1) * ((dec2)*buf2);
|
|
|
|
hi=(dec1)(p/DIG_BASE);
|
|
|
|
lo=(dec1)(p-((dec2)hi)*DIG_BASE);
|
|
|
|
ADD2(*buf0, *buf0, lo, carry);
|
|
|
|
carry+=hi;
|
|
|
|
}
|
2006-07-06 12:18:05 +02:00
|
|
|
if (carry)
|
|
|
|
{
|
|
|
|
if (buf0 < to->buf)
|
|
|
|
return E_DEC_OVERFLOW;
|
|
|
|
ADD2(*buf0, *buf0, 0, carry);
|
|
|
|
}
|
|
|
|
for (buf0--; carry; buf0--)
|
2005-11-02 15:46:13 +01:00
|
|
|
{
|
|
|
|
if (buf0 < to->buf)
|
|
|
|
return E_DEC_OVERFLOW;
|
2004-10-18 14:06:46 +02:00
|
|
|
ADD(*buf0, *buf0, 0, carry);
|
2005-11-02 15:46:13 +01:00
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
2005-05-07 11:41:00 +02:00
|
|
|
|
2018-10-30 15:15:41 +01:00
|
|
|
/* Remove trailing zero words in frac part */
|
|
|
|
frac0= ROUND_UP(to->frac);
|
|
|
|
|
|
|
|
if (frac0 > 0 && to->buf[intg0 + frac0 - 1] == 0)
|
2005-05-07 11:41:00 +02:00
|
|
|
{
|
2018-10-30 15:15:41 +01:00
|
|
|
do
|
2005-06-01 15:35:09 +02:00
|
|
|
{
|
2018-10-30 15:15:41 +01:00
|
|
|
frac0--;
|
|
|
|
} while (frac0 > 0 && to->buf[intg0 + frac0 - 1] == 0);
|
|
|
|
to->frac= DIG_PER_DEC1 * frac0;
|
2005-05-07 11:41:00 +02:00
|
|
|
}
|
2018-10-30 15:15:41 +01:00
|
|
|
|
|
|
|
/* Remove heading zero words in intg part */
|
2005-09-04 18:00:00 +02:00
|
|
|
buf1= to->buf;
|
2018-10-30 15:15:41 +01:00
|
|
|
d_to_move= intg0 + frac0;
|
2005-09-04 18:00:00 +02:00
|
|
|
while (!*buf1 && (to->intg > DIG_PER_DEC1))
|
|
|
|
{
|
|
|
|
buf1++;
|
|
|
|
to->intg-= DIG_PER_DEC1;
|
|
|
|
d_to_move--;
|
|
|
|
}
|
|
|
|
if (to->buf < buf1)
|
|
|
|
{
|
|
|
|
dec1 *cur_d= to->buf;
|
2005-10-06 16:54:43 +02:00
|
|
|
for (; d_to_move--; cur_d++, buf1++)
|
2005-09-04 18:00:00 +02:00
|
|
|
*cur_d= *buf1;
|
|
|
|
}
|
2018-10-30 15:15:41 +01:00
|
|
|
|
|
|
|
/* Now we have to check for -0.000 case */
|
|
|
|
if (to->sign && to->frac == 0 && to->buf[0] == 0)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(to->intg <= DIG_PER_DEC1);
|
|
|
|
/* We got decimal zero */
|
|
|
|
decimal_make_zero(to);
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
naive division algorithm (Knuth's Algorithm D in 4.3.1) -
|
|
|
|
it's ok for short numbers
|
|
|
|
also we're using alloca() to allocate a temporary buffer
|
|
|
|
|
|
|
|
XXX if this library is to be used with huge numbers of thousands of
|
|
|
|
digits, fast division must be implemented and alloca should be
|
|
|
|
changed to malloc (or at least fallback to malloc if alloca() fails)
|
2005-03-31 17:46:36 +02:00
|
|
|
but then, decimal_mul() should be rewritten too :(
|
2004-10-18 14:06:46 +02:00
|
|
|
*/
|
2011-03-03 15:25:41 +01:00
|
|
|
static int do_div_mod(const decimal_t *from1, const decimal_t *from2,
|
|
|
|
decimal_t *to, decimal_t *mod, int scale_incr)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
int frac1=ROUND_UP(from1->frac)*DIG_PER_DEC1, prec1=from1->intg+frac1,
|
|
|
|
frac2=ROUND_UP(from2->frac)*DIG_PER_DEC1, prec2=from2->intg+frac2,
|
2009-08-28 17:51:31 +02:00
|
|
|
UNINIT_VAR(error), i, intg0, frac0, len1, len2, dintg, div_mod=(!mod);
|
2004-10-18 14:06:46 +02:00
|
|
|
dec1 *buf0, *buf1=from1->buf, *buf2=from2->buf, *tmp1,
|
2005-03-31 17:46:36 +02:00
|
|
|
*start2, *stop2, *stop1, *stop0, norm2, carry, *start1, dcarry;
|
2004-10-18 14:06:46 +02:00
|
|
|
dec2 norm_factor, x, guess, y;
|
|
|
|
|
|
|
|
if (mod)
|
|
|
|
to=mod;
|
|
|
|
|
2004-10-30 19:27:54 +02:00
|
|
|
sanity(to);
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/* removing all the leading zeroes */
|
2005-05-06 10:31:48 +02:00
|
|
|
i= ((prec2 - 1) % DIG_PER_DEC1) + 1;
|
|
|
|
while (prec2 > 0 && *buf2 == 0)
|
|
|
|
{
|
|
|
|
prec2-= i;
|
|
|
|
i= DIG_PER_DEC1;
|
|
|
|
buf2++;
|
|
|
|
}
|
|
|
|
if (prec2 <= 0) /* short-circuit everything: from2 == 0 */
|
|
|
|
return E_DEC_DIV_ZERO;
|
|
|
|
for (i= (prec2 - 1) % DIG_PER_DEC1; *buf2 < powers10[i--]; prec2--) ;
|
|
|
|
DBUG_ASSERT(prec2 > 0);
|
|
|
|
|
2004-10-31 00:02:13 +02:00
|
|
|
i=((prec1-1) % DIG_PER_DEC1)+1;
|
2004-10-18 14:06:46 +02:00
|
|
|
while (prec1 > 0 && *buf1 == 0)
|
|
|
|
{
|
|
|
|
prec1-=i;
|
|
|
|
i=DIG_PER_DEC1;
|
|
|
|
buf1++;
|
|
|
|
}
|
|
|
|
if (prec1 <= 0)
|
|
|
|
{ /* short-circuit everything: from1 == 0 */
|
2004-10-29 00:22:54 +02:00
|
|
|
decimal_make_zero(to);
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OK;
|
|
|
|
}
|
|
|
|
for (i=(prec1-1) % DIG_PER_DEC1; *buf1 < powers10[i--]; prec1--) ;
|
|
|
|
DBUG_ASSERT(prec1 > 0);
|
|
|
|
|
|
|
|
/* let's fix scale_incr, taking into account frac1,frac2 increase */
|
|
|
|
if ((scale_incr-= frac1 - from1->frac + frac2 - from2->frac) < 0)
|
|
|
|
scale_incr=0;
|
|
|
|
|
2004-11-01 23:44:05 +01:00
|
|
|
dintg=(prec1-frac1)-(prec2-frac2)+(*buf1 >= *buf2);
|
|
|
|
if (dintg < 0)
|
|
|
|
{
|
|
|
|
dintg/=DIG_PER_DEC1;
|
2004-10-18 14:06:46 +02:00
|
|
|
intg0=0;
|
2004-11-01 23:44:05 +01:00
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
else
|
2004-11-01 23:44:05 +01:00
|
|
|
intg0=ROUND_UP(dintg);
|
2004-10-18 14:06:46 +02:00
|
|
|
if (mod)
|
|
|
|
{
|
|
|
|
/* we're calculating N1 % N2.
|
|
|
|
The result will have
|
2013-03-25 23:03:13 +01:00
|
|
|
frac=MY_MAX(frac1, frac2), as for subtraction
|
2004-10-18 14:06:46 +02:00
|
|
|
intg=intg2
|
|
|
|
*/
|
|
|
|
to->sign=from1->sign;
|
2013-03-25 23:03:13 +01:00
|
|
|
to->frac=MY_MAX(from1->frac, from2->frac);
|
2004-10-18 14:06:46 +02:00
|
|
|
frac0=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
we're calculating N1/N2. N1 is in the buf1, has prec1 digits
|
|
|
|
N2 is in the buf2, has prec2 digits. Scales are frac1 and
|
|
|
|
frac2 accordingly.
|
|
|
|
Thus, the result will have
|
|
|
|
frac = ROUND_UP(frac1+frac2+scale_incr)
|
|
|
|
and
|
|
|
|
intg = (prec1-frac1) - (prec2-frac2) + 1
|
|
|
|
prec = intg+frac
|
|
|
|
*/
|
|
|
|
frac0=ROUND_UP(frac1+frac2+scale_incr);
|
|
|
|
FIX_INTG_FRAC_ERROR(to->len, intg0, frac0, error);
|
|
|
|
to->sign=from1->sign != from2->sign;
|
|
|
|
to->intg=intg0*DIG_PER_DEC1;
|
|
|
|
to->frac=frac0*DIG_PER_DEC1;
|
|
|
|
}
|
|
|
|
buf0=to->buf;
|
|
|
|
stop0=buf0+intg0+frac0;
|
2006-12-14 23:51:37 +01:00
|
|
|
if (likely(div_mod))
|
2011-03-03 15:25:41 +01:00
|
|
|
while (dintg++ < 0 && buf0 < &to->buf[to->len])
|
|
|
|
{
|
2004-11-07 13:47:44 +01:00
|
|
|
*buf0++=0;
|
2011-03-03 15:25:41 +01:00
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
len1=(i=ROUND_UP(prec1))+ROUND_UP(2*frac2+scale_incr+1) + 1;
|
2004-11-02 20:45:55 +01:00
|
|
|
set_if_bigger(len1, 3);
|
2005-02-08 23:50:45 +01:00
|
|
|
if (!(tmp1=(dec1 *)my_alloca(len1*sizeof(dec1))))
|
2004-10-18 14:06:46 +02:00
|
|
|
return E_DEC_OOM;
|
|
|
|
memcpy(tmp1, buf1, i*sizeof(dec1));
|
|
|
|
bzero(tmp1+i, (len1-i)*sizeof(dec1));
|
|
|
|
|
|
|
|
start1=tmp1;
|
|
|
|
stop1=start1+len1;
|
|
|
|
start2=buf2;
|
|
|
|
stop2=buf2+ROUND_UP(prec2)-1;
|
|
|
|
|
|
|
|
/* removing end zeroes */
|
|
|
|
while (*stop2 == 0 && stop2 >= start2)
|
|
|
|
stop2--;
|
2005-06-13 12:41:15 +02:00
|
|
|
len2= (int) (stop2++ - start2);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
calculating norm2 (normalized *start2) - we need *start2 to be large
|
|
|
|
(at least > DIG_BASE/2), but unlike Knuth's Alg. D we don't want to
|
|
|
|
normalize input numbers (as we don't make a copy of the divisor).
|
|
|
|
Thus we normalize first dec1 of buf2 only, and we'll normalize *start1
|
|
|
|
on the fly for the purpose of guesstimation only.
|
|
|
|
It's also faster, as we're saving on normalization of buf2
|
|
|
|
*/
|
|
|
|
norm_factor=DIG_BASE/(*start2+1);
|
|
|
|
norm2=(dec1)(norm_factor*start2[0]);
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(len2>0))
|
2004-10-18 14:06:46 +02:00
|
|
|
norm2+=(dec1)(norm_factor*start2[1]/DIG_BASE);
|
|
|
|
|
2005-03-31 17:46:36 +02:00
|
|
|
if (*start1 < *start2)
|
|
|
|
dcarry=*start1++;
|
|
|
|
else
|
|
|
|
dcarry=0;
|
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
/* main loop */
|
2005-03-31 17:46:36 +02:00
|
|
|
for (; buf0 < stop0; buf0++)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
/* short-circuit, if possible */
|
2005-03-31 17:46:36 +02:00
|
|
|
if (unlikely(dcarry == 0 && *start1 < *start2))
|
|
|
|
guess=0;
|
2004-10-18 14:06:46 +02:00
|
|
|
else
|
|
|
|
{
|
2005-03-31 17:46:36 +02:00
|
|
|
/* D3: make a guess */
|
|
|
|
x=start1[0]+((dec2)dcarry)*DIG_BASE;
|
|
|
|
y=start1[1];
|
|
|
|
guess=(norm_factor*x+norm_factor*y/DIG_BASE)/norm2;
|
|
|
|
if (unlikely(guess >= DIG_BASE))
|
|
|
|
guess=DIG_BASE-1;
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(len2>0))
|
2005-03-31 17:46:36 +02:00
|
|
|
{
|
|
|
|
/* hmm, this is a suspicious trick - I removed normalization here */
|
|
|
|
if (start2[1]*guess > (x-guess*start2[0])*DIG_BASE+y)
|
|
|
|
guess--;
|
|
|
|
if (unlikely(start2[1]*guess > (x-guess*start2[0])*DIG_BASE+y))
|
|
|
|
guess--;
|
|
|
|
DBUG_ASSERT(start2[1]*guess <= (x-guess*start2[0])*DIG_BASE+y);
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2005-03-31 17:46:36 +02:00
|
|
|
/* D4: multiply and subtract */
|
2004-10-18 14:06:46 +02:00
|
|
|
buf2=stop2;
|
2005-03-31 17:46:36 +02:00
|
|
|
buf1=start1+len2;
|
|
|
|
DBUG_ASSERT(buf1 < stop1);
|
2004-10-18 14:06:46 +02:00
|
|
|
for (carry=0; buf2 > start2; buf1--)
|
|
|
|
{
|
2005-03-31 17:46:36 +02:00
|
|
|
dec1 hi, lo;
|
|
|
|
x=guess * (*--buf2);
|
|
|
|
hi=(dec1)(x/DIG_BASE);
|
|
|
|
lo=(dec1)(x-((dec2)hi)*DIG_BASE);
|
|
|
|
SUB2(*buf1, *buf1, lo, carry);
|
|
|
|
carry+=hi;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
2005-03-31 17:46:36 +02:00
|
|
|
carry= dcarry < carry;
|
|
|
|
|
|
|
|
/* D5: check the remainder */
|
|
|
|
if (unlikely(carry))
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-03-31 17:46:36 +02:00
|
|
|
/* D6: correct the guess */
|
|
|
|
guess--;
|
|
|
|
buf2=stop2;
|
|
|
|
buf1=start1+len2;
|
|
|
|
for (carry=0; buf2 > start2; buf1--)
|
|
|
|
{
|
|
|
|
ADD(*buf1, *buf1, *--buf2, carry);
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
}
|
2006-12-14 23:51:37 +01:00
|
|
|
if (likely(div_mod))
|
2011-07-18 09:47:39 +02:00
|
|
|
{
|
|
|
|
DBUG_ASSERT(buf0 < to->buf + to->len);
|
2004-11-07 13:47:44 +01:00
|
|
|
*buf0=(dec1)guess;
|
2011-07-18 09:47:39 +02:00
|
|
|
}
|
2012-02-06 13:30:39 +01:00
|
|
|
#ifdef WORKAROUND_GCC_4_3_2_BUG
|
|
|
|
dcarry= *(volatile dec1 *)start1;
|
|
|
|
#else
|
2005-03-31 17:46:36 +02:00
|
|
|
dcarry= *start1;
|
2012-02-06 13:30:39 +01:00
|
|
|
#endif
|
2005-03-31 17:46:36 +02:00
|
|
|
start1++;
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
if (mod)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
now the result is in tmp1, it has
|
|
|
|
intg=prec1-frac1
|
2013-03-25 23:03:13 +01:00
|
|
|
frac=MY_MAX(frac1, frac2)=to->frac
|
2004-10-18 14:06:46 +02:00
|
|
|
*/
|
2005-03-31 17:46:36 +02:00
|
|
|
if (dcarry)
|
|
|
|
*--start1=dcarry;
|
2004-10-18 14:06:46 +02:00
|
|
|
buf0=to->buf;
|
2005-06-13 12:41:15 +02:00
|
|
|
intg0=(int) (ROUND_UP(prec1-frac1)-(start1-tmp1));
|
2004-10-18 14:06:46 +02:00
|
|
|
frac0=ROUND_UP(to->frac);
|
|
|
|
error=E_DEC_OK;
|
2004-11-07 16:12:21 +01:00
|
|
|
if (unlikely(frac0==0 && intg0==0))
|
|
|
|
{
|
|
|
|
decimal_make_zero(to);
|
|
|
|
goto done;
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
if (intg0<=0)
|
|
|
|
{
|
|
|
|
if (unlikely(-intg0 >= to->len))
|
|
|
|
{
|
2004-10-29 00:22:54 +02:00
|
|
|
decimal_make_zero(to);
|
2004-10-18 14:06:46 +02:00
|
|
|
error=E_DEC_TRUNCATED;
|
|
|
|
goto done;
|
|
|
|
}
|
2014-07-03 10:42:02 +02:00
|
|
|
stop1= start1 + frac0 + intg0;
|
2004-10-18 14:06:46 +02:00
|
|
|
frac0+=intg0;
|
|
|
|
to->intg=0;
|
|
|
|
while (intg0++ < 0)
|
|
|
|
*buf0++=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (unlikely(intg0 > to->len))
|
|
|
|
{
|
|
|
|
frac0=0;
|
|
|
|
intg0=to->len;
|
|
|
|
error=E_DEC_OVERFLOW;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
|
|
|
|
stop1=start1+frac0+intg0;
|
2013-03-25 23:03:13 +01:00
|
|
|
to->intg=MY_MIN(intg0*DIG_PER_DEC1, from2->intg);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
if (unlikely(intg0+frac0 > to->len))
|
|
|
|
{
|
2007-10-08 00:48:59 +02:00
|
|
|
stop1-=frac0+intg0-to->len;
|
2004-10-18 14:06:46 +02:00
|
|
|
frac0=to->len-intg0;
|
|
|
|
to->frac=frac0*DIG_PER_DEC1;
|
|
|
|
error=E_DEC_TRUNCATED;
|
|
|
|
}
|
2007-10-08 00:48:59 +02:00
|
|
|
DBUG_ASSERT(buf0 + (stop1 - start1) <= to->buf + to->len);
|
2004-10-18 14:06:46 +02:00
|
|
|
while (start1 < stop1)
|
|
|
|
*buf0++=*start1++;
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
my_afree(tmp1);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
division of two decimals
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal_div()
|
|
|
|
from1 - dividend
|
|
|
|
from2 - divisor
|
|
|
|
to - quotient
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW/E_DEC_DIV_ZERO;
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
see do_div_mod()
|
|
|
|
*/
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
int
|
2011-03-03 15:25:41 +01:00
|
|
|
decimal_div(const decimal_t *from1, const decimal_t *from2, decimal_t *to,
|
|
|
|
int scale_incr)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
return do_div_mod(from1, from2, to, 0, scale_incr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
modulus
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
decimal_mod()
|
|
|
|
from1 - dividend
|
|
|
|
from2 - divisor
|
|
|
|
to - modulus
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW/E_DEC_DIV_ZERO;
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
see do_div_mod()
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
the modulus R in R = M mod N
|
|
|
|
|
|
|
|
is defined as
|
|
|
|
|
|
|
|
0 <= |R| < |M|
|
|
|
|
sign R == sign M
|
|
|
|
R = M - k*N, where k is integer
|
|
|
|
|
|
|
|
thus, there's no requirement for M or N to be integers
|
|
|
|
*/
|
|
|
|
|
2011-03-03 15:25:41 +01:00
|
|
|
int decimal_mod(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
return do_div_mod(from1, from2, 0, to, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MAIN
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
int full= 0;
|
2005-03-21 13:58:34 +01:00
|
|
|
decimal_t a, b, c;
|
2004-10-18 14:06:46 +02:00
|
|
|
char buf1[100], buf2[100], buf3[100];
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
void dump_decimal(decimal_t *d)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
printf("/* intg=%d, frac=%d, sign=%d, buf[]={", d->intg, d->frac, d->sign);
|
|
|
|
for (i=0; i < ROUND_UP(d->frac)+ROUND_UP(d->intg)-1; i++)
|
|
|
|
printf("%09d, ", d->buf[i]);
|
|
|
|
printf("%09d} */ ", d->buf[i]);
|
|
|
|
}
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
|
|
|
|
void check_result_code(int actual, int want)
|
|
|
|
{
|
|
|
|
if (actual != want)
|
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
printf("\n^^^^^^^^^^^^^ must return %d\n", want);
|
2005-02-08 23:50:45 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-21 13:58:34 +01:00
|
|
|
void print_decimal(decimal_t *d, const char *orig, int actual, int want)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
char s[100];
|
|
|
|
int slen=sizeof(s);
|
|
|
|
|
|
|
|
if (full) dump_decimal(d);
|
2005-02-08 23:50:45 +01:00
|
|
|
decimal2string(d, s, &slen, 0, 0, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("'%s'", s);
|
2005-02-08 23:50:45 +01:00
|
|
|
check_result_code(actual, want);
|
2004-12-03 13:04:03 +01:00
|
|
|
if (orig && strcmp(orig, s))
|
|
|
|
{
|
|
|
|
printf("\n^^^^^^^^^^^^^ must've been '%s'\n", orig);
|
|
|
|
exit(1);
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_d2s()
|
|
|
|
{
|
|
|
|
char s[100];
|
|
|
|
int slen, res;
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
printf("==== decimal2string ====\n");
|
|
|
|
a.buf[0]=12345; a.intg=5; a.frac=0; a.sign=0;
|
|
|
|
slen=sizeof(s);
|
2005-02-08 23:50:45 +01:00
|
|
|
res=decimal2string(&a, s, &slen, 0, 0, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
dump_decimal(&a); printf(" --> res=%d str='%s' len=%d\n", res, s, slen);
|
|
|
|
|
|
|
|
a.buf[1]=987000000; a.frac=3;
|
|
|
|
slen=sizeof(s);
|
2005-02-08 23:50:45 +01:00
|
|
|
res=decimal2string(&a, s, &slen, 0, 0, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
dump_decimal(&a); printf(" --> res=%d str='%s' len=%d\n", res, s, slen);
|
|
|
|
|
|
|
|
a.sign=1;
|
|
|
|
slen=sizeof(s);
|
2005-02-08 23:50:45 +01:00
|
|
|
res=decimal2string(&a, s, &slen, 0, 0, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
dump_decimal(&a); printf(" --> res=%d str='%s' len=%d\n", res, s, slen);
|
|
|
|
|
|
|
|
slen=8;
|
2005-02-08 23:50:45 +01:00
|
|
|
res=decimal2string(&a, s, &slen, 0, 0, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
dump_decimal(&a); printf(" --> res=%d str='%s' len=%d\n", res, s, slen);
|
|
|
|
|
|
|
|
slen=5;
|
2005-02-08 23:50:45 +01:00
|
|
|
res=decimal2string(&a, s, &slen, 0, 0, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
dump_decimal(&a); printf(" --> res=%d str='%s' len=%d\n", res, s, slen);
|
|
|
|
|
|
|
|
a.buf[0]=987000000; a.frac=3; a.intg=0;
|
|
|
|
slen=sizeof(s);
|
2005-02-08 23:50:45 +01:00
|
|
|
res=decimal2string(&a, s, &slen, 0, 0, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
dump_decimal(&a); printf(" --> res=%d str='%s' len=%d\n", res, s, slen);
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_s2d(const char *s, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s1[100], *end;
|
2005-02-08 23:50:45 +01:00
|
|
|
int res;
|
2004-10-18 14:06:46 +02:00
|
|
|
sprintf(s1, "'%s'", s);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s);
|
2005-02-08 23:50:45 +01:00
|
|
|
printf("len=%2d %-30s => res=%d ", a.len, s1,
|
2005-02-19 17:58:27 +01:00
|
|
|
(res= string2decimal(s, &a, &end)));
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&a, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_d2f(const char *s, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s1[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
double x;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
sprintf(s1, "'%s'", s);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s);
|
|
|
|
string2decimal(s, &a, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal2double(&a, &x);
|
|
|
|
if (full) dump_decimal(&a);
|
|
|
|
printf("%-40s => res=%d %.*g\n", s1, res, a.intg+a.frac, x);
|
2005-02-08 23:50:45 +01:00
|
|
|
check_result_code(res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_d2b2d(const char *str, int p, int s, const char *orig, int ex)
|
2004-10-19 14:38:54 +02:00
|
|
|
{
|
2021-05-11 20:25:08 +02:00
|
|
|
char s1[100], *end;
|
|
|
|
uchar buf[100];
|
2004-10-19 14:38:54 +02:00
|
|
|
int res, i, size=decimal_bin_size(p, s);
|
|
|
|
|
|
|
|
sprintf(s1, "'%s'", str);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(str);
|
|
|
|
string2decimal(str, &a, &end);
|
2004-10-19 14:38:54 +02:00
|
|
|
res=decimal2bin(&a, buf, p, s);
|
|
|
|
printf("%-31s {%2d, %2d} => res=%d size=%-2d ", s1, p, s, res, size);
|
|
|
|
if (full)
|
|
|
|
{
|
|
|
|
printf("0x");
|
|
|
|
for (i=0; i < size; i++)
|
|
|
|
printf("%02x", ((uchar *)buf)[i]);
|
|
|
|
}
|
|
|
|
res=bin2decimal(buf, &a, p, s);
|
|
|
|
printf(" => res=%d ", res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&a, orig, res, ex);
|
2004-10-19 14:38:54 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
2005-02-19 17:58:27 +01:00
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
void test_f2d(double from, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
res=double2decimal(from, &a);
|
|
|
|
printf("%-40.*f => res=%d ", DBL_DIG-2, from, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&a, 0, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_ull2d(ulonglong from, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
char s[100];
|
|
|
|
int res;
|
|
|
|
|
|
|
|
res=ulonglong2decimal(from, &a);
|
|
|
|
longlong10_to_str(from,s,10);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&a, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_ll2d(longlong from, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
char s[100];
|
|
|
|
int res;
|
|
|
|
|
|
|
|
res=longlong2decimal(from, &a);
|
|
|
|
longlong10_to_str(from,s,-10);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&a, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_d2ull(const char *s, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s1[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
ulonglong x;
|
|
|
|
int res;
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s);
|
|
|
|
string2decimal(s, &a, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal2ulonglong(&a, &x);
|
|
|
|
if (full) dump_decimal(&a);
|
|
|
|
longlong10_to_str(x,s1,10);
|
|
|
|
printf("%-40s => res=%d %s\n", s, res, s1);
|
2005-02-08 23:50:45 +01:00
|
|
|
check_result_code(res, ex);
|
2004-12-03 13:04:03 +01:00
|
|
|
if (orig && strcmp(orig, s1))
|
|
|
|
{
|
|
|
|
printf("\n^^^^^^^^^^^^^ must've been '%s'\n", orig);
|
|
|
|
exit(1);
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_d2ll(const char *s, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s1[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
longlong x;
|
|
|
|
int res;
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s);
|
|
|
|
string2decimal(s, &a, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal2longlong(&a, &x);
|
|
|
|
if (full) dump_decimal(&a);
|
|
|
|
longlong10_to_str(x,s1,-10);
|
|
|
|
printf("%-40s => res=%d %s\n", s, res, s1);
|
2005-02-08 23:50:45 +01:00
|
|
|
check_result_code(res, ex);
|
2004-12-03 13:04:03 +01:00
|
|
|
if (orig && strcmp(orig, s1))
|
|
|
|
{
|
|
|
|
printf("\n^^^^^^^^^^^^^ must've been '%s'\n", orig);
|
|
|
|
exit(1);
|
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_da(const char *s1, const char *s2, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
int res;
|
|
|
|
sprintf(s, "'%s' + '%s'", s1, s2);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
|
|
|
end= strend(s2);
|
|
|
|
string2decimal(s2, &b, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal_add(&a, &b, &c);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&c, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_ds(const char *s1, const char *s2, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
int res;
|
|
|
|
sprintf(s, "'%s' - '%s'", s1, s2);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
|
|
|
end= strend(s2);
|
|
|
|
string2decimal(s2, &b, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal_sub(&a, &b, &c);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&c, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_dc(const char *s1, const char *s2, int orig)
|
2004-10-20 15:26:03 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2004-10-20 15:26:03 +02:00
|
|
|
int res;
|
|
|
|
sprintf(s, "'%s' <=> '%s'", s1, s2);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
|
|
|
end= strend(s2);
|
|
|
|
string2decimal(s2, &b, &end);
|
2004-10-20 15:26:03 +02:00
|
|
|
res=decimal_cmp(&a, &b);
|
|
|
|
printf("%-40s => res=%d\n", s, res);
|
2004-12-03 13:04:03 +01:00
|
|
|
if (orig != res)
|
|
|
|
{
|
|
|
|
printf("\n^^^^^^^^^^^^^ must've been %d\n", orig);
|
|
|
|
exit(1);
|
|
|
|
}
|
2004-10-20 15:26:03 +02:00
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_dm(const char *s1, const char *s2, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
int res;
|
|
|
|
sprintf(s, "'%s' * '%s'", s1, s2);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
|
|
|
end= strend(s2);
|
|
|
|
string2decimal(s2, &b, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal_mul(&a, &b, &c);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&c, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_dv(const char *s1, const char *s2, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
int res;
|
|
|
|
sprintf(s, "'%s' / '%s'", s1, s2);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
|
|
|
end= strend(s2);
|
|
|
|
string2decimal(s2, &b, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal_div(&a, &b, &c, 5);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
check_result_code(res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
if (res == E_DEC_DIV_ZERO)
|
|
|
|
printf("E_DEC_DIV_ZERO");
|
|
|
|
else
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&c, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_md(const char *s1, const char *s2, const char *orig, int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
int res;
|
|
|
|
sprintf(s, "'%s' %% '%s'", s1, s2);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
|
|
|
end= strend(s2);
|
|
|
|
string2decimal(s2, &b, &end);
|
2004-10-18 14:06:46 +02:00
|
|
|
res=decimal_mod(&a, &b, &c);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
check_result_code(res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
if (res == E_DEC_DIV_ZERO)
|
|
|
|
printf("E_DEC_DIV_ZERO");
|
|
|
|
else
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&c, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
const char *round_mode[]=
|
|
|
|
{"TRUNCATE", "HALF_EVEN", "HALF_UP", "CEILING", "FLOOR"};
|
2004-11-03 18:43:48 +01:00
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_ro(const char *s1, int n, decimal_round_mode mode, const char *orig,
|
|
|
|
int ex)
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2004-10-18 14:06:46 +02:00
|
|
|
int res;
|
2004-11-03 18:43:48 +01:00
|
|
|
sprintf(s, "'%s', %d, %s", s1, n, round_mode[mode]);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
2004-10-29 00:22:54 +02:00
|
|
|
res=decimal_round(&a, &b, n, mode);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("%-40s => res=%d ", s, res);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&b, orig, res, ex);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_mx(int precision, int frac, const char *orig)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
|
|
|
char s[100];
|
|
|
|
sprintf(s, "%d, %d", precision, frac);
|
|
|
|
max_decimal(precision, frac, &a);
|
|
|
|
printf("%-40s => ", s);
|
|
|
|
print_decimal(&a, orig, 0, 0);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_pr(const char *s1, int prec, int dec, char filler, const char *orig,
|
|
|
|
int ex)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2005-02-08 23:50:45 +01:00
|
|
|
char s2[100];
|
|
|
|
int slen= sizeof(s2);
|
|
|
|
int res;
|
|
|
|
|
2005-12-23 20:50:28 +01:00
|
|
|
sprintf(s, filler ? "'%s', %d, %d, '%c'" : "'%s', %d, %d, '\\0'",
|
|
|
|
s1, prec, dec, filler);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
2005-02-08 23:50:45 +01:00
|
|
|
res= decimal2string(&a, s2, &slen, prec, dec, filler);
|
|
|
|
printf("%-40s => res=%d '%s'", s, res, s2);
|
|
|
|
check_result_code(res, ex);
|
|
|
|
if (orig && strcmp(orig, s2))
|
|
|
|
{
|
|
|
|
printf("\n^^^^^^^^^^^^^ must've been '%s'\n", orig);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_sh(const char *s1, int shift, const char *orig, int ex)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2005-02-08 23:50:45 +01:00
|
|
|
int res;
|
|
|
|
sprintf(s, "'%s' %s %d", s1, ((shift < 0) ? ">>" : "<<"), abs(shift));
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
2005-02-08 23:50:45 +01:00
|
|
|
res= decimal_shift(&a, shift);
|
|
|
|
printf("%-40s => res=%d ", s, res);
|
|
|
|
print_decimal(&a, orig, res, ex);
|
2004-10-18 14:06:46 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
|
2005-02-19 17:58:27 +01:00
|
|
|
void test_fr(const char *s1, const char *orig)
|
2005-02-08 23:50:45 +01:00
|
|
|
{
|
2005-02-19 17:58:27 +01:00
|
|
|
char s[100], *end;
|
2005-02-08 23:50:45 +01:00
|
|
|
sprintf(s, "'%s'", s1);
|
|
|
|
printf("%-40s => ", s);
|
2005-02-19 17:58:27 +01:00
|
|
|
end= strend(s1);
|
|
|
|
string2decimal(s1, &a, &end);
|
2005-05-05 17:06:49 +02:00
|
|
|
a.frac= decimal_actual_fraction(&a);
|
2005-02-08 23:50:45 +01:00
|
|
|
print_decimal(&a, orig, 0, 0);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
2004-10-18 14:06:46 +02:00
|
|
|
{
|
|
|
|
a.buf=(void*)buf1;
|
|
|
|
a.len=sizeof(buf1)/sizeof(dec1);
|
|
|
|
b.buf=(void*)buf2;
|
|
|
|
b.len=sizeof(buf2)/sizeof(dec1);
|
|
|
|
c.buf=(void*)buf3;
|
|
|
|
c.len=sizeof(buf3)/sizeof(dec1);
|
|
|
|
|
|
|
|
if (full)
|
|
|
|
test_d2s();
|
|
|
|
|
|
|
|
printf("==== string2decimal ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_s2d("12345", "12345", 0);
|
|
|
|
test_s2d("12345.", "12345", 0);
|
|
|
|
test_s2d("123.45", "123.45", 0);
|
|
|
|
test_s2d("-123.45", "-123.45", 0);
|
|
|
|
test_s2d(".00012345000098765", "0.00012345000098765", 0);
|
|
|
|
test_s2d(".12345000098765", "0.12345000098765", 0);
|
|
|
|
test_s2d("-.000000012345000098765", "-0.000000012345000098765", 0);
|
|
|
|
test_s2d("1234500009876.5", "1234500009876.5", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
a.len=1;
|
2005-02-08 23:50:45 +01:00
|
|
|
test_s2d("123450000098765", "98765", 2);
|
|
|
|
test_s2d("123450.000098765", "123450", 1);
|
2004-10-18 14:06:46 +02:00
|
|
|
a.len=sizeof(buf1)/sizeof(dec1);
|
2005-02-08 23:50:45 +01:00
|
|
|
test_s2d("123E5", "12300000", 0);
|
|
|
|
test_s2d("123E-2", "1.23", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== decimal2double ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_d2f("12345", 0);
|
|
|
|
test_d2f("123.45", 0);
|
|
|
|
test_d2f("-123.45", 0);
|
|
|
|
test_d2f("0.00012345000098765", 0);
|
|
|
|
test_d2f("1234500009876.5", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== double2decimal ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_f2d(12345, 0);
|
|
|
|
test_f2d(1.0/3, 0);
|
|
|
|
test_f2d(-123.45, 0);
|
|
|
|
test_f2d(0.00012345000098765, 0);
|
|
|
|
test_f2d(1234500009876.5, 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== ulonglong2decimal ====\n");
|
2021-05-11 20:25:08 +02:00
|
|
|
test_ull2d(12345ULL, "12345", 0);
|
|
|
|
test_ull2d(0ULL, "0", 0);
|
|
|
|
test_ull2d(18446744073709551615ULL, "18446744073709551615", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== decimal2ulonglong ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_d2ull("12345", "12345", 0);
|
|
|
|
test_d2ull("0", "0", 0);
|
|
|
|
test_d2ull("18446744073709551615", "18446744073709551615", 0);
|
2021-05-11 20:25:08 +02:00
|
|
|
test_d2ull("18446744073709551616", "18446744073709551615", 2);
|
2005-02-08 23:50:45 +01:00
|
|
|
test_d2ull("-1", "0", 2);
|
|
|
|
test_d2ull("1.23", "1", 1);
|
2021-05-11 20:25:08 +02:00
|
|
|
test_d2ull("9999999999999999999999999.000", "18446744073709551615", 2);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== longlong2decimal ====\n");
|
2021-05-11 20:25:08 +02:00
|
|
|
test_ll2d(-12345LL, "-12345", 0);
|
|
|
|
test_ll2d(-1LL, "-1", 0);
|
|
|
|
test_ll2d(-9223372036854775807LL, "-9223372036854775807", 0);
|
|
|
|
test_ll2d(9223372036854775808ULL, "-9223372036854775808", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== decimal2longlong ====\n");
|
2021-05-11 20:25:08 +02:00
|
|
|
test_d2ll("18446744073709551615", "9223372036854775807", 2);
|
2005-02-08 23:50:45 +01:00
|
|
|
test_d2ll("-1", "-1", 0);
|
|
|
|
test_d2ll("-1.23", "-1", 1);
|
|
|
|
test_d2ll("-9223372036854775807", "-9223372036854775807", 0);
|
|
|
|
test_d2ll("-9223372036854775808", "-9223372036854775808", 0);
|
|
|
|
test_d2ll("9223372036854775808", "9223372036854775807", 2);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== do_add ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_da(".00012345000098765" ,"123.45", "123.45012345000098765", 0);
|
|
|
|
test_da(".1" ,".45", "0.55", 0);
|
|
|
|
test_da("1234500009876.5" ,".00012345000098765", "1234500009876.50012345000098765", 0);
|
|
|
|
test_da("9999909999999.5" ,".555", "9999910000000.055", 0);
|
|
|
|
test_da("99999999" ,"1", "100000000", 0);
|
|
|
|
test_da("989999999" ,"1", "990000000", 0);
|
|
|
|
test_da("999999999" ,"1", "1000000000", 0);
|
|
|
|
test_da("12345" ,"123.45", "12468.45", 0);
|
|
|
|
test_da("-12345" ,"-123.45", "-12468.45", 0);
|
|
|
|
test_ds("-12345" ,"123.45", "-12468.45", 0);
|
|
|
|
test_ds("12345" ,"-123.45", "12468.45", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== do_sub ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_ds(".00012345000098765", "123.45","-123.44987654999901235", 0);
|
|
|
|
test_ds("1234500009876.5", ".00012345000098765","1234500009876.49987654999901235", 0);
|
|
|
|
test_ds("9999900000000.5", ".555","9999899999999.945", 0);
|
|
|
|
test_ds("1111.5551", "1111.555","0.0001", 0);
|
|
|
|
test_ds(".555", ".555","0", 0);
|
|
|
|
test_ds("10000000", "1","9999999", 0);
|
|
|
|
test_ds("1000001000", ".1","1000000999.9", 0);
|
|
|
|
test_ds("1000000000", ".1","999999999.9", 0);
|
|
|
|
test_ds("12345", "123.45","12221.55", 0);
|
|
|
|
test_ds("-12345", "-123.45","-12221.55", 0);
|
|
|
|
test_da("-12345", "123.45","-12221.55", 0);
|
|
|
|
test_da("12345", "-123.45","12221.55", 0);
|
|
|
|
test_ds("123.45", "12345","-12221.55", 0);
|
|
|
|
test_ds("-123.45", "-12345","12221.55", 0);
|
|
|
|
test_da("123.45", "-12345","-12221.55", 0);
|
|
|
|
test_da("-123.45", "12345","12221.55", 0);
|
|
|
|
test_da("5", "-6.0","-1.0", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== decimal_mul ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_dm("12", "10","120", 0);
|
|
|
|
test_dm("-123.456", "98765.4321","-12193185.1853376", 0);
|
|
|
|
test_dm("-123456000000", "98765432100000","-12193185185337600000000000", 0);
|
|
|
|
test_dm("123456", "987654321","121931851853376", 0);
|
|
|
|
test_dm("123456", "9876543210","1219318518533760", 0);
|
|
|
|
test_dm("123", "0.01","1.23", 0);
|
|
|
|
test_dm("123", "0","0", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== decimal_div ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_dv("120", "10","12.000000000", 0);
|
|
|
|
test_dv("123", "0.01","12300.000000000", 0);
|
|
|
|
test_dv("120", "100000000000.00000","0.000000001200000000", 0);
|
|
|
|
test_dv("123", "0","", 4);
|
2005-05-06 10:31:48 +02:00
|
|
|
test_dv("0", "0", "", 4);
|
2005-02-08 23:50:45 +01:00
|
|
|
test_dv("-12193185.1853376", "98765.4321","-123.456000000000000000", 0);
|
|
|
|
test_dv("121931851853376", "987654321","123456.000000000", 0);
|
|
|
|
test_dv("0", "987","0", 0);
|
|
|
|
test_dv("1", "3","0.333333333", 0);
|
|
|
|
test_dv("1.000000000000", "3","0.333333333333333333", 0);
|
|
|
|
test_dv("1", "1","1.000000000", 0);
|
|
|
|
test_dv("0.0123456789012345678912345", "9999999999","0.000000000001234567890246913578148141", 0);
|
2005-03-31 17:46:36 +02:00
|
|
|
test_dv("10.333000000", "12.34500","0.837019036046982584042122316", 0);
|
|
|
|
test_dv("10.000000000060", "2","5.000000000030000000", 0);
|
2004-10-18 14:06:46 +02:00
|
|
|
|
|
|
|
printf("==== decimal_mod ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_md("234","10","4", 0);
|
|
|
|
test_md("234.567","10.555","2.357", 0);
|
|
|
|
test_md("-234.567","10.555","-2.357", 0);
|
|
|
|
test_md("234.567","-10.555","2.357", 0);
|
2005-02-20 16:55:11 +01:00
|
|
|
c.buf[1]=0x3ABECA;
|
|
|
|
test_md("99999999999999999999999999999999999999","3","0", 0);
|
|
|
|
if (c.buf[1] != 0x3ABECA)
|
2004-11-07 13:47:44 +01:00
|
|
|
{
|
2005-02-20 16:55:11 +01:00
|
|
|
printf("%X - overflow\n", c.buf[1]);
|
|
|
|
exit(1);
|
2004-11-07 13:47:44 +01:00
|
|
|
}
|
2004-10-18 14:06:46 +02:00
|
|
|
|
2004-10-19 14:38:54 +02:00
|
|
|
printf("==== decimal2bin/bin2decimal ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_d2b2d("-10.55", 4, 2,"-10.55", 0);
|
|
|
|
test_d2b2d("0.0123456789012345678912345", 30, 25,"0.0123456789012345678912345", 0);
|
|
|
|
test_d2b2d("12345", 5, 0,"12345", 0);
|
|
|
|
test_d2b2d("12345", 10, 3,"12345.000", 0);
|
|
|
|
test_d2b2d("123.45", 10, 3,"123.450", 0);
|
|
|
|
test_d2b2d("-123.45", 20, 10,"-123.4500000000", 0);
|
|
|
|
test_d2b2d(".00012345000098765", 15, 14,"0.00012345000098", 0);
|
|
|
|
test_d2b2d(".00012345000098765", 22, 20,"0.00012345000098765000", 0);
|
|
|
|
test_d2b2d(".12345000098765", 30, 20,"0.12345000098765000000", 0);
|
|
|
|
test_d2b2d("-.000000012345000098765", 30, 20,"-0.00000001234500009876", 0);
|
|
|
|
test_d2b2d("1234500009876.5", 30, 5,"1234500009876.50000", 0);
|
|
|
|
test_d2b2d("111111111.11", 10, 2,"11111111.11", 0);
|
|
|
|
test_d2b2d("000000000.01", 7, 3,"0.010", 0);
|
|
|
|
test_d2b2d("123.4", 10, 2, "123.40", 0);
|
|
|
|
|
2004-10-19 14:38:54 +02:00
|
|
|
|
2004-10-20 15:26:03 +02:00
|
|
|
printf("==== decimal_cmp ====\n");
|
2004-12-03 13:04:03 +01:00
|
|
|
test_dc("12","13",-1);
|
|
|
|
test_dc("13","12",1);
|
|
|
|
test_dc("-10","10",-1);
|
|
|
|
test_dc("10","-10",1);
|
|
|
|
test_dc("-12","-13",1);
|
|
|
|
test_dc("0","12",-1);
|
|
|
|
test_dc("-10","0",-1);
|
|
|
|
test_dc("4","4",0);
|
2004-11-03 18:43:48 +01:00
|
|
|
|
|
|
|
printf("==== decimal_round ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_ro("5678.123451",-4,TRUNCATE,"0", 0);
|
|
|
|
test_ro("5678.123451",-3,TRUNCATE,"5000", 0);
|
|
|
|
test_ro("5678.123451",-2,TRUNCATE,"5600", 0);
|
|
|
|
test_ro("5678.123451",-1,TRUNCATE,"5670", 0);
|
|
|
|
test_ro("5678.123451",0,TRUNCATE,"5678", 0);
|
|
|
|
test_ro("5678.123451",1,TRUNCATE,"5678.1", 0);
|
|
|
|
test_ro("5678.123451",2,TRUNCATE,"5678.12", 0);
|
|
|
|
test_ro("5678.123451",3,TRUNCATE,"5678.123", 0);
|
|
|
|
test_ro("5678.123451",4,TRUNCATE,"5678.1234", 0);
|
|
|
|
test_ro("5678.123451",5,TRUNCATE,"5678.12345", 0);
|
|
|
|
test_ro("5678.123451",6,TRUNCATE,"5678.123451", 0);
|
|
|
|
test_ro("-5678.123451",-4,TRUNCATE,"0", 0);
|
2004-12-03 13:23:58 +01:00
|
|
|
memset(buf2, 33, sizeof(buf2));
|
2005-02-08 23:50:45 +01:00
|
|
|
test_ro("99999999999999999999999999999999999999",-31,TRUNCATE,"99999990000000000000000000000000000000", 0);
|
|
|
|
test_ro("15.1",0,HALF_UP,"15", 0);
|
|
|
|
test_ro("15.5",0,HALF_UP,"16", 0);
|
|
|
|
test_ro("15.9",0,HALF_UP,"16", 0);
|
|
|
|
test_ro("-15.1",0,HALF_UP,"-15", 0);
|
|
|
|
test_ro("-15.5",0,HALF_UP,"-16", 0);
|
|
|
|
test_ro("-15.9",0,HALF_UP,"-16", 0);
|
|
|
|
test_ro("15.1",1,HALF_UP,"15.1", 0);
|
|
|
|
test_ro("-15.1",1,HALF_UP,"-15.1", 0);
|
|
|
|
test_ro("15.17",1,HALF_UP,"15.2", 0);
|
|
|
|
test_ro("15.4",-1,HALF_UP,"20", 0);
|
|
|
|
test_ro("-15.4",-1,HALF_UP,"-20", 0);
|
|
|
|
test_ro("5.4",-1,HALF_UP,"10", 0);
|
|
|
|
test_ro(".999", 0, HALF_UP, "1", 0);
|
2004-12-06 13:06:52 +01:00
|
|
|
memset(buf2, 33, sizeof(buf2));
|
2005-02-08 23:50:45 +01:00
|
|
|
test_ro("999999999", -9, HALF_UP, "1000000000", 0);
|
|
|
|
test_ro("15.1",0,HALF_EVEN,"15", 0);
|
|
|
|
test_ro("15.5",0,HALF_EVEN,"16", 0);
|
|
|
|
test_ro("14.5",0,HALF_EVEN,"14", 0);
|
|
|
|
test_ro("15.9",0,HALF_EVEN,"16", 0);
|
|
|
|
test_ro("15.1",0,CEILING,"16", 0);
|
|
|
|
test_ro("-15.1",0,CEILING,"-15", 0);
|
|
|
|
test_ro("15.1",0,FLOOR,"15", 0);
|
|
|
|
test_ro("-15.1",0,FLOOR,"-16", 0);
|
|
|
|
test_ro("999999999999999999999.999", 0, CEILING,"1000000000000000000000", 0);
|
|
|
|
test_ro("-999999999999999999999.999", 0, FLOOR,"-1000000000000000000000", 0);
|
|
|
|
|
2005-02-20 16:55:11 +01:00
|
|
|
b.buf[0]=DIG_BASE+1;
|
|
|
|
b.buf++;
|
|
|
|
test_ro(".3", 0, HALF_UP, "0", 0);
|
|
|
|
b.buf--;
|
|
|
|
if (b.buf[0] != DIG_BASE+1)
|
|
|
|
{
|
|
|
|
printf("%d - underflow\n", b.buf[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
printf("==== max_decimal ====\n");
|
|
|
|
test_mx(1,1,"0.9");
|
|
|
|
test_mx(1,0,"9");
|
|
|
|
test_mx(2,1,"9.9");
|
|
|
|
test_mx(4,2,"99.99");
|
|
|
|
test_mx(6,3,"999.999");
|
|
|
|
test_mx(8,4,"9999.9999");
|
|
|
|
test_mx(10,5,"99999.99999");
|
|
|
|
test_mx(12,6,"999999.999999");
|
|
|
|
test_mx(14,7,"9999999.9999999");
|
|
|
|
test_mx(16,8,"99999999.99999999");
|
|
|
|
test_mx(18,9,"999999999.999999999");
|
|
|
|
test_mx(20,10,"9999999999.9999999999");
|
|
|
|
test_mx(20,20,"0.99999999999999999999");
|
|
|
|
test_mx(20,0,"99999999999999999999");
|
|
|
|
test_mx(40,20,"99999999999999999999.99999999999999999999");
|
|
|
|
|
|
|
|
printf("==== decimal2string ====\n");
|
|
|
|
test_pr("123.123", 0, 0, 0, "123.123", 0);
|
2021-05-11 20:25:08 +02:00
|
|
|
test_pr("123.123", 7, 3, '0', "0123.123", 0);
|
|
|
|
test_pr("123.123", 9, 3, '0', "000123.123", 0);
|
|
|
|
test_pr("123.123", 9, 4, '0', "00123.1230", 0);
|
|
|
|
test_pr("123.123", 9, 5, '0', "0123.12300", 0);
|
|
|
|
test_pr("123.123", 9, 2, '0', "0000123.12", 1);
|
|
|
|
test_pr("123.123", 8, 6, '0', "23.123000", 2);
|
2005-02-08 23:50:45 +01:00
|
|
|
|
|
|
|
printf("==== decimal_shift ====\n");
|
|
|
|
test_sh("123.123", 1, "1231.23", 0);
|
|
|
|
test_sh("123457189.123123456789000", 1, "1234571891.23123456789", 0);
|
|
|
|
test_sh("123457189.123123456789000", 4, "1234571891231.23456789", 0);
|
|
|
|
test_sh("123457189.123123456789000", 8, "12345718912312345.6789", 0);
|
|
|
|
test_sh("123457189.123123456789000", 9, "123457189123123456.789", 0);
|
|
|
|
test_sh("123457189.123123456789000", 10, "1234571891231234567.89", 0);
|
|
|
|
test_sh("123457189.123123456789000", 17, "12345718912312345678900000", 0);
|
|
|
|
test_sh("123457189.123123456789000", 18, "123457189123123456789000000", 0);
|
|
|
|
test_sh("123457189.123123456789000", 19, "1234571891231234567890000000", 0);
|
|
|
|
test_sh("123457189.123123456789000", 26, "12345718912312345678900000000000000", 0);
|
|
|
|
test_sh("123457189.123123456789000", 27, "123457189123123456789000000000000000", 0);
|
|
|
|
test_sh("123457189.123123456789000", 28, "1234571891231234567890000000000000000", 0);
|
|
|
|
test_sh("000000000000000000000000123457189.123123456789000", 26, "12345718912312345678900000000000000", 0);
|
|
|
|
test_sh("00000000123457189.123123456789000", 27, "123457189123123456789000000000000000", 0);
|
|
|
|
test_sh("00000000000000000123457189.123123456789000", 28, "1234571891231234567890000000000000000", 0);
|
|
|
|
test_sh("123", 1, "1230", 0);
|
|
|
|
test_sh("123", 10, "1230000000000", 0);
|
|
|
|
test_sh(".123", 1, "1.23", 0);
|
|
|
|
test_sh(".123", 10, "1230000000", 0);
|
|
|
|
test_sh(".123", 14, "12300000000000", 0);
|
|
|
|
test_sh("000.000", 1000, "0", 0);
|
|
|
|
test_sh("000.", 1000, "0", 0);
|
|
|
|
test_sh(".000", 1000, "0", 0);
|
|
|
|
test_sh("1", 1000, "1", 2);
|
|
|
|
test_sh("123.123", -1, "12.3123", 0);
|
|
|
|
test_sh("123987654321.123456789000", -1, "12398765432.1123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -2, "1239876543.21123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -3, "123987654.321123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -8, "1239.87654321123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -9, "123.987654321123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -10, "12.3987654321123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -11, "1.23987654321123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -12, "0.123987654321123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -13, "0.0123987654321123456789", 0);
|
|
|
|
test_sh("123987654321.123456789000", -14, "0.00123987654321123456789", 0);
|
|
|
|
test_sh("00000087654321.123456789000", -14, "0.00000087654321123456789", 0);
|
|
|
|
a.len= 2;
|
|
|
|
test_sh("123.123", -2, "1.23123", 0);
|
|
|
|
test_sh("123.123", -3, "0.123123", 0);
|
|
|
|
test_sh("123.123", -6, "0.000123123", 0);
|
|
|
|
test_sh("123.123", -7, "0.0000123123", 0);
|
|
|
|
test_sh("123.123", -15, "0.000000000000123123", 0);
|
|
|
|
test_sh("123.123", -16, "0.000000000000012312", 1);
|
|
|
|
test_sh("123.123", -17, "0.000000000000001231", 1);
|
|
|
|
test_sh("123.123", -18, "0.000000000000000123", 1);
|
|
|
|
test_sh("123.123", -19, "0.000000000000000012", 1);
|
|
|
|
test_sh("123.123", -20, "0.000000000000000001", 1);
|
|
|
|
test_sh("123.123", -21, "0", 1);
|
|
|
|
test_sh(".000000000123", -1, "0.0000000000123", 0);
|
|
|
|
test_sh(".000000000123", -6, "0.000000000000000123", 0);
|
|
|
|
test_sh(".000000000123", -7, "0.000000000000000012", 1);
|
|
|
|
test_sh(".000000000123", -8, "0.000000000000000001", 1);
|
|
|
|
test_sh(".000000000123", -9, "0", 1);
|
|
|
|
test_sh(".000000000123", 1, "0.00000000123", 0);
|
|
|
|
test_sh(".000000000123", 8, "0.0123", 0);
|
|
|
|
test_sh(".000000000123", 9, "0.123", 0);
|
|
|
|
test_sh(".000000000123", 10, "1.23", 0);
|
|
|
|
test_sh(".000000000123", 17, "12300000", 0);
|
|
|
|
test_sh(".000000000123", 18, "123000000", 0);
|
|
|
|
test_sh(".000000000123", 19, "1230000000", 0);
|
|
|
|
test_sh(".000000000123", 20, "12300000000", 0);
|
|
|
|
test_sh(".000000000123", 21, "123000000000", 0);
|
|
|
|
test_sh(".000000000123", 22, "1230000000000", 0);
|
|
|
|
test_sh(".000000000123", 23, "12300000000000", 0);
|
|
|
|
test_sh(".000000000123", 24, "123000000000000", 0);
|
|
|
|
test_sh(".000000000123", 25, "1230000000000000", 0);
|
|
|
|
test_sh(".000000000123", 26, "12300000000000000", 0);
|
|
|
|
test_sh(".000000000123", 27, "123000000000000000", 0);
|
|
|
|
test_sh(".000000000123", 28, "0.000000000123", 2);
|
|
|
|
test_sh("123456789.987654321", -1, "12345678.998765432", 1);
|
|
|
|
test_sh("123456789.987654321", -2, "1234567.899876543", 1);
|
|
|
|
test_sh("123456789.987654321", -8, "1.234567900", 1);
|
|
|
|
test_sh("123456789.987654321", -9, "0.123456789987654321", 0);
|
|
|
|
test_sh("123456789.987654321", -10, "0.012345678998765432", 1);
|
|
|
|
test_sh("123456789.987654321", -17, "0.000000001234567900", 1);
|
|
|
|
test_sh("123456789.987654321", -18, "0.000000000123456790", 1);
|
|
|
|
test_sh("123456789.987654321", -19, "0.000000000012345679", 1);
|
|
|
|
test_sh("123456789.987654321", -26, "0.000000000000000001", 1);
|
|
|
|
test_sh("123456789.987654321", -27, "0", 1);
|
|
|
|
test_sh("123456789.987654321", 1, "1234567900", 1);
|
|
|
|
test_sh("123456789.987654321", 2, "12345678999", 1);
|
|
|
|
test_sh("123456789.987654321", 4, "1234567899877", 1);
|
|
|
|
test_sh("123456789.987654321", 8, "12345678998765432", 1);
|
|
|
|
test_sh("123456789.987654321", 9, "123456789987654321", 0);
|
|
|
|
test_sh("123456789.987654321", 10, "123456789.987654321", 2);
|
|
|
|
test_sh("123456789.987654321", 0, "123456789.987654321", 0);
|
|
|
|
a.len= sizeof(buf1)/sizeof(dec1);
|
|
|
|
|
2005-05-05 17:06:49 +02:00
|
|
|
printf("==== decimal_actual_fraction ====\n");
|
2005-02-08 23:50:45 +01:00
|
|
|
test_fr("1.123456789000000000", "1.123456789");
|
|
|
|
test_fr("1.12345678000000000", "1.12345678");
|
|
|
|
test_fr("1.1234567000000000", "1.1234567");
|
|
|
|
test_fr("1.123456000000000", "1.123456");
|
|
|
|
test_fr("1.12345000000000", "1.12345");
|
|
|
|
test_fr("1.1234000000000", "1.1234");
|
|
|
|
test_fr("1.123000000000", "1.123");
|
|
|
|
test_fr("1.12000000000", "1.12");
|
|
|
|
test_fr("1.1000000000", "1.1");
|
|
|
|
test_fr("1.000000000", "1");
|
|
|
|
test_fr("1.0", "1");
|
|
|
|
test_fr("10000000000000000000.0", "10000000000000000000");
|
2004-11-08 10:06:32 +01:00
|
|
|
|
2004-10-18 14:06:46 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|