1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21
This file defines all string functions
24
Some string functions don't always put and end-null on a String.
25
(This shouldn't be needed)
28
#include <drizzled/server_includes.h>
29
#include <mysys/sha1.h>
31
#include <drizzled/query_id.h>
32
#include <uuid/uuid.h>
33
#include <drizzled/data_home.h>
34
#include <drizzled/error.h>
37
#include <mysys/my_static.h>
40
#if defined(CMATH_NAMESPACE)
41
using namespace CMATH_NAMESPACE;
46
bool Item_str_func::fix_fields(Session *session, Item **ref)
48
bool res= Item_func::fix_fields(session, ref);
50
In Item_str_func::check_well_formed_result() we may set null_value
51
flag on the same condition as in test() below.
53
maybe_null= (maybe_null || true);
58
my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value)
62
String *res, tmp(buff,sizeof(buff), &my_charset_bin);
66
(void)str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
67
res->length(), res->charset(), decimal_value);
72
double Item_str_func::val_real()
76
char *end_not_used, buff[64];
77
String *res, tmp(buff,sizeof(buff), &my_charset_bin);
79
return res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
80
&end_not_used, &err_not_used) : 0.0;
84
int64_t Item_str_func::val_int()
89
String *res, tmp(buff,sizeof(buff), &my_charset_bin);
92
my_strntoll(res->charset(), res->ptr(), res->length(), 10, NULL,
97
void Item_str_func::left_right_max_length()
99
max_length=args[0]->max_length;
100
if (args[1]->const_item())
102
int length=(int) args[1]->val_int()*collation.collation->mbmaxlen;
106
set_if_smaller(max_length,(uint) length);