~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/str/strfunc.cc

  • 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:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
 
17
17
/**
25
25
    (This shouldn't be needed)
26
26
*/
27
27
 
28
 
#include "config.h"
 
28
#include <drizzled/server_includes.h>
 
29
#include <mysys/sha1.h>
29
30
#include <zlib.h>
30
31
#include <drizzled/query_id.h>
 
32
#include <uuid/uuid.h>
 
33
#include <drizzled/data_home.h>
31
34
#include <drizzled/error.h>
32
35
#include <drizzled/function/str/strfunc.h>
33
36
 
34
37
// For soundex_map
35
 
#include "drizzled/internal/my_static.h"
 
38
#include <mysys/my_static.h>
36
39
 
37
40
using namespace std;
38
41
 
39
 
namespace drizzled
40
 
{
41
 
 
42
 
Item_str_func::~Item_str_func() {}
43
 
 
44
42
bool Item_str_func::fix_fields(Session *session, Item **ref)
45
43
{
46
44
  bool res= Item_func::fix_fields(session, ref);
53
51
}
54
52
 
55
53
 
56
 
type::Decimal *Item_str_func::val_decimal(type::Decimal *decimal_value)
 
54
my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value)
57
55
{
58
56
  assert(fixed == 1);
59
57
  char buff[64];
60
58
  String *res, tmp(buff,sizeof(buff), &my_charset_bin);
61
59
  res= val_str(&tmp);
62
 
  if (not res)
 
60
  if (!res)
63
61
    return 0;
64
 
 
65
 
  (void)decimal_value->store(E_DEC_FATAL_ERROR, (char*) res->ptr(), res->length(), res->charset());
66
 
 
 
62
  (void)str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
 
63
                       res->length(), res->charset(), decimal_value);
67
64
  return decimal_value;
68
65
}
69
66
 
84
81
{
85
82
  assert(fixed == 1);
86
83
  int err;
87
 
  char buff[DECIMAL_LONGLONG_DIGITS];
 
84
  char buff[22];
88
85
  String *res, tmp(buff,sizeof(buff), &my_charset_bin);
89
86
  res= val_str(&tmp);
90
87
  return (res ?
106
103
  }
107
104
}
108
105
 
109
 
DRIZZLED_API String my_empty_string("",default_charset_info);
 
106
String my_empty_string("",default_charset_info);
110
107
 
111
 
} /* namespace drizzled */