Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00028 #include <config.h>
00029 #include <zlib.h>
00030 #include <drizzled/query_id.h>
00031 #include <drizzled/error.h>
00032 #include <drizzled/function/str/strfunc.h>
00033
00034
00035 #include <drizzled/internal/my_static.h>
00036
00037 using namespace std;
00038
00039 namespace drizzled
00040 {
00041
00042 Item_str_func::~Item_str_func() {}
00043
00044 bool Item_str_func::fix_fields(Session *session, Item **ref)
00045 {
00046 bool res= Item_func::fix_fields(session, ref);
00047
00048
00049
00050
00051 maybe_null= (maybe_null || true);
00052 return res;
00053 }
00054
00055
00056 type::Decimal *Item_str_func::val_decimal(type::Decimal *decimal_value)
00057 {
00058 assert(fixed == 1);
00059 char buff[64];
00060 String *res, tmp(buff,sizeof(buff), &my_charset_bin);
00061 res= val_str(&tmp);
00062 if (not res)
00063 return 0;
00064
00065 (void)decimal_value->store(E_DEC_FATAL_ERROR, (char*) res->ptr(), res->length(), res->charset());
00066
00067 return decimal_value;
00068 }
00069
00070
00071 double Item_str_func::val_real()
00072 {
00073 assert(fixed == 1);
00074 int err_not_used;
00075 char *end_not_used, buff[64];
00076 String *res, tmp(buff,sizeof(buff), &my_charset_bin);
00077 res= val_str(&tmp);
00078 return res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
00079 &end_not_used, &err_not_used) : 0.0;
00080 }
00081
00082
00083 int64_t Item_str_func::val_int()
00084 {
00085 assert(fixed == 1);
00086 int err;
00087 char buff[DECIMAL_LONGLONG_DIGITS];
00088 String *res, tmp(buff,sizeof(buff), &my_charset_bin);
00089 res= val_str(&tmp);
00090 return (res ?
00091 my_strntoll(res->charset(), res->ptr(), res->length(), 10, NULL,
00092 &err) :
00093 (int64_t) 0);
00094 }
00095
00096 void Item_str_func::left_right_max_length()
00097 {
00098 max_length=args[0]->max_length;
00099 if (args[1]->const_item())
00100 {
00101 int length=(int) args[1]->val_int()*collation.collation->mbmaxlen;
00102 if (length <= 0)
00103 max_length=0;
00104 else
00105 set_if_smaller(max_length,(uint) length);
00106 }
00107 }
00108
00109 DRIZZLED_API String my_empty_string("",default_charset_info);
00110
00111 }