~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/util/convert.h

  • Committer: Stewart Smith
  • Date: 2009-05-15 06:57:12 UTC
  • mto: (991.1.5 for-brian)
  • mto: This revision was merged to the branch mainline in revision 1022.
  • Revision ID: stewart@flamingspork.com-20090515065712-bmionylacjmexmmm
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.

Also fix DEFAULT keyword handling for auto-increment so that it defaults to
NULL and not 0 so that the following is valid and generates two auto-inc
values:

create table t1 (a int auto_increment primary key)
insert into t1 (a) values (default);
insert into t1 (a) values (default);

Important to note that 0 is no longer magic. So this gives you duplicate
primary key error:

insert into t1 (a) values(0);
insert into t1 (a) values(0);

as you've inserted the explicit value of 0 twice.

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
 
 
22
 
 
23
 
#ifndef DRIZZLED_UTIL_CONVERT_H
24
 
#define DRIZZLED_UTIL_CONVERT_H
25
 
 
26
 
#include <boost/lexical_cast.hpp>
 
21
#ifndef DRIZZLE_SERVER_UTIL_CONVERT
 
22
#define DRIZZLE_SERVER_UTIL_CONVERT
 
23
 
27
24
#include <string>
28
25
#include <iostream>
29
26
#include <sstream>
30
 
 
31
 
#include "drizzled/visibility.h"
32
 
 
33
 
namespace drizzled
34
 
{
 
27
#include <stdint.h>
35
28
 
36
29
template <class T>
37
30
std::string to_string(T t)
38
31
{
39
 
  return boost::lexical_cast<std::string>(t);
 
32
  std::ostringstream o;
 
33
  o << t;
 
34
  return o.str();
40
35
}
41
36
 
42
37
template <class T>
47
42
  return str;
48
43
}
49
44
 
50
 
void bytesToHexdumpFormat(std::string &s, const unsigned char *from, size_t from_length);
51
 
 
52
 
DRIZZLED_API uint64_t drizzled_string_to_hex(char *to, const char *from,
53
 
                                             uint64_t from_size);
54
 
DRIZZLED_API void drizzled_hex_to_string(char *to, const char *from,
55
 
                                         uint64_t from_size);
56
 
 
57
 
} /* namespace drizzled */
58
 
 
59
 
#endif /* DRIZZLED_UTIL_CONVERT_H */
 
45
extern "C"
 
46
{
 
47
  uint64_t drizzled_string_to_hex(char *to, const char *from,
 
48
                                  uint64_t from_size);
 
49
}
 
50
 
 
51
#endif