~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/util/test.h

Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types.

This fixes the buffer overflow in https://bugs.launchpad.net/drizzle/+bug/373468

It also removes a handwritten snprintf in field/datetime.cc
However... this caused us to have to change Temporal to have a way to not
"convert" the int64_t value (so 20090101 becomes 20090101000000 etc) as it
has already been converted and we just want the Temporal type to do the
to_string conversion.

This still causes a failure in 'metadata' test due to size of timestamp type. I need feedback from Jay on when the usecond code comes into play to know the correct fix for this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef DRIZZLED_UTIL_TEST_H
22
 
#define DRIZZLED_UTIL_TEST_H
 
21
#ifndef DRIZZLE_SERVER_UTIL_TEST
 
22
#define DRIZZLE_SERVER_UTIL_TEST
23
23
 
24
24
#if defined(__cplusplus)
25
25
 
26
 
namespace drizzled
27
 
{
28
 
 
29
26
template <class T>
30
27
inline bool test(const T a)
31
28
{
38
35
  return ((a & b) == b);
39
36
}
40
37
 
41
 
} /* namespace drizzled */
42
 
 
43
38
#else
44
39
# define test(a)    ((a) ? 1 : 0)
45
40
# define test_all_bits(a,b) (((a) & (b)) == (b))
46
41
#endif
47
42
 
48
 
#endif /* DRIZZLED_UTIL_TEST_H */
 
43
#endif