~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/decimal.h

[patch 112/129] Merge patch for revision 1925 from InnoDB SVN:
revno: 1925
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6169
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6163
committer: calvin
timestamp: Thu 2009-11-12 12:40:43 +0000
message:
  branches/zip: add test case for bug#46676
  
  This crash is reproducible with InnoDB plugin 1.0.4 + MySQL 5.1.37.
  But no longer reproducible after MySQL 5.1.38 (with plugin 1.0.5).
  Add test case to catch future regression.
added:
  mysql-test/innodb_bug46676.result 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.result
  mysql-test/innodb_bug46676.test 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.test
diff:
=== added file 'mysql-test/innodb_bug46676.result'

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
int decimal_is_zero(const decimal_t *from);
64
64
void max_decimal(int precision, int frac, decimal_t *to);
65
65
 
66
 
inline int string2decimal(char *from, decimal_t *to, char **end)
67
 
{
68
 
  return internal_str2dec(from, to, end, false);
69
 
}
 
66
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
70
67
 
71
68
/* set a decimal_t to zero */
72
69
 
73
 
inline void decimal_make_zero(decimal_t *dec)
74
 
{                                                           
75
 
  dec->buf[0]=0;
76
 
  dec->intg=1;
77
 
  dec->frac=0;
78
 
  dec->sign=0; 
79
 
}
 
70
#define decimal_make_zero(dec)        do {                \
 
71
                                        (dec)->buf[0]=0;    \
 
72
                                        (dec)->intg=1;      \
 
73
                                        (dec)->frac=0;      \
 
74
                                        (dec)->sign=0;      \
 
75
                                      } while(0)
80
76
 
81
77
/*
82
78
  returns the length of the buffer to hold string representation
83
79
  of the decimal (including decimal dot, possible sign and \0)
84
80
*/
85
81
 
86
 
inline int decimal_string_size(const decimal_t *dec)
87
 
{
88
 
  return (dec->intg ? dec->intg : 1) + dec->frac + (dec->frac > 0) + 2;
89
 
}
 
82
#define decimal_string_size(dec) (((dec)->intg ? (dec)->intg : 1) + \
 
83
                                  (dec)->frac + ((dec)->frac > 0) + 2)
90
84
 
91
85
/* negate a decimal */
92
 
inline void decimal_neg(decimal_t *dec)
93
 
{
94
 
  dec->sign^=1;
95
 
}
 
86
#define decimal_neg(dec) do { (dec)->sign^=1; } while(0)
96
87
 
97
88
/*
98
89
  conventions:
169
160
  {
170
161
    len= DECIMAL_BUFF_LENGTH;
171
162
    buf= buffer;
172
 
        #if !defined (HAVE_VALGRIND)
 
163
        #if !defined (HAVE_purify)
173
164
                /* Set buffer to 'random' value to find wrong buffer usage */
174
165
                for (uint32_t i= 0; i < DECIMAL_BUFF_LENGTH; i++)
175
166
                  buffer[i]= i;