mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge with MySQL 5.1.60
This commit is contained in:
@ -93,25 +93,51 @@ inline int my_decimal_int_part(uint precision, uint decimals)
|
||||
|
||||
class my_decimal :public decimal_t
|
||||
{
|
||||
/*
|
||||
Several of the routines in strings/decimal.c have had buffer
|
||||
overrun/underrun problems. These are *not* caught by valgrind.
|
||||
To catch them, we allocate dummy fields around the buffer,
|
||||
and test that their values do not change.
|
||||
*/
|
||||
#if !defined(DBUG_OFF) && defined(HAVE_valgrind)
|
||||
int foo1;
|
||||
#endif
|
||||
|
||||
decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
|
||||
|
||||
#if !defined(DBUG_OFF)
|
||||
int foo2;
|
||||
static const int test_value= 123;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
void init()
|
||||
{
|
||||
#if !defined(DBUG_OFF)
|
||||
foo1= test_value;
|
||||
foo2= test_value;
|
||||
#endif
|
||||
len= DECIMAL_BUFF_LENGTH;
|
||||
buf= buffer;
|
||||
#if !defined (HAVE_valgrind) && !defined(DBUG_OFF)
|
||||
/* Set buffer to 'random' value to find wrong buffer usage */
|
||||
for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++)
|
||||
buffer[i]= i;
|
||||
#endif
|
||||
TRASH(buffer, sizeof(buffer));
|
||||
}
|
||||
|
||||
my_decimal()
|
||||
{
|
||||
init();
|
||||
}
|
||||
~my_decimal()
|
||||
{
|
||||
sanity_check();
|
||||
}
|
||||
|
||||
void sanity_check()
|
||||
{
|
||||
DBUG_ASSERT(foo1 == test_value);
|
||||
DBUG_ASSERT(foo2 == test_value);
|
||||
}
|
||||
|
||||
void fix_buffer_pointer() { buf= buffer; }
|
||||
|
||||
bool sign() const { return decimal_t::sign; }
|
||||
|
Reference in New Issue
Block a user