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 */
83
83
#include <drizzled/function/math/tan.h>
84
84
#include <drizzled/function/units.h>
86
#include "drizzled/function/cast/boolean.h"
87
#include "drizzled/function/cast/signed.h"
88
#include "drizzled/function/cast/time.h"
89
#include "drizzled/function/cast/unsigned.h"
91
86
using namespace std;
2058
2053
find_native_function_builder(LEX_STRING name)
2055
Native_func_registry *func;
2060
2056
Create_func *builder= NULL;
2062
2058
string func_name(name.str, name.length);
2064
FunctionContainer::Map::iterator func_iter=
2060
NativeFunctionsMap::iterator func_iter=
2065
2061
FunctionContainer::getMap().find(func_name);
2067
2063
if (func_iter != FunctionContainer::getMap().end())
2069
builder= (*func_iter).second;
2065
func= (*func_iter).second;
2066
builder= func->builder;
2072
2069
return builder;
2086
2083
const char *c_len, const char *c_dec,
2087
2084
const CHARSET_INFO * const cs)
2093
2090
switch (cast_type) {
2094
case ITEM_CAST_SIGNED:
2095
res= new (session->mem_root) function::cast::Signed(a);
2098
case ITEM_CAST_UNSIGNED:
2099
res= new (session->mem_root) function::cast::Unsigned(a);
2102
2091
case ITEM_CAST_BINARY:
2103
2092
res= new (session->mem_root) Item_func_binary(a);
2106
case ITEM_CAST_BOOLEAN:
2107
res= new (session->mem_root) function::cast::Boolean(a);
2110
case ITEM_CAST_TIME:
2111
res= new (session->mem_root) function::cast::Time(a);
2114
2094
case ITEM_CAST_DATE:
2115
2095
res= new (session->mem_root) Item_date_typecast(a);
2118
2097
case ITEM_CAST_DATETIME:
2119
2098
res= new (session->mem_root) Item_datetime_typecast(a);
2122
2100
case ITEM_CAST_DECIMAL:
2124
len= c_len ? atoi(c_len) : 0;
2125
dec= c_dec ? atoi(c_dec) : 0;
2126
class_decimal_trim(&len, &dec);
2129
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
2132
if (len > DECIMAL_MAX_PRECISION)
2134
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
2135
DECIMAL_MAX_PRECISION);
2138
if (dec > DECIMAL_MAX_SCALE)
2140
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
2144
res= new (session->mem_root) Item_decimal_typecast(a, len, dec);
2102
len= c_len ? atoi(c_len) : 0;
2103
dec= c_dec ? atoi(c_dec) : 0;
2104
my_decimal_trim(&len, &dec);
2107
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
2110
if (len > DECIMAL_MAX_PRECISION)
2112
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
2113
DECIMAL_MAX_PRECISION);
2116
if (dec > DECIMAL_MAX_SCALE)
2118
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
2122
res= new (session->mem_root) Item_decimal_typecast(a, len, dec);
2147
2125
case ITEM_CAST_CHAR:
2149
len= c_len ? atoi(c_len) : -1;
2150
res= create_func_char_cast(session, a, len, cs);
2127
len= c_len ? atoi(c_len) : -1;
2128
res= create_func_char_cast(session, a, len, cs);