~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Mats Kindahl
  • Date: 2008-08-26 07:32:59 UTC
  • mto: (489.1.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 491.
  • Revision ID: mats@mysql.com-20080826073259-9k4evtajgldgolli
Replaced use of thd_proc_info() macro with calls to
set_proc_info() and get_proc_info() internally.  Introduced
functions set_thd_proc_info() and get_thd_proc_info() for
external users, i.e., plug-ins.

The set_thd_proc_info() accepted callers info that can be used to
print debug output, but the information was not used. The return
value was changed to void and the old value is not fetched any
more. To be able to get the value of proc_info for external
users, the function get_thd_proc_info() was introduced.

The thd_proc_info() macro called set_thd_proc_info() but almost
never used the return value of set_thd_proc_info() so the macro
was replaced with a call of THD::set_proc_info().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
2
 
 
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.
6
 
 
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.
11
 
 
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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
 
17
 
/**
18
 
  @file
19
 
 
20
 
  @brief
21
 
  This file defines all string functions
22
 
 
23
 
  @warning
24
 
    Some string functions don't always put and end-null on a String.
25
 
    (This shouldn't be needed)
26
 
*/
27
 
 
28
 
#include "config.h"
29
 
#include <zlib.h>
30
 
#include <drizzled/query_id.h>
31
 
#include <drizzled/error.h>
32
 
#include <drizzled/function/str/strfunc.h>
33
 
 
34
 
// For soundex_map
35
 
#include "drizzled/internal/my_static.h"
36
 
 
37
 
using namespace std;
38
 
 
39
 
namespace drizzled
40
 
{
41
 
 
42
 
Item_str_func::~Item_str_func() {}
43
 
 
44
 
bool Item_str_func::fix_fields(Session *session, Item **ref)
45
 
{
46
 
  bool res= Item_func::fix_fields(session, ref);
47
 
  /*
48
 
    In Item_str_func::check_well_formed_result() we may set null_value
49
 
    flag on the same condition as in test() below.
50
 
  */
51
 
  maybe_null= (maybe_null || true);
52
 
  return res;
53
 
}
54
 
 
55
 
 
56
 
my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value)
57
 
{
58
 
  assert(fixed == 1);
59
 
  char buff[64];
60
 
  String *res, tmp(buff,sizeof(buff), &my_charset_bin);
61
 
  res= val_str(&tmp);
62
 
  if (!res)
63
 
    return 0;
64
 
  (void)str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
65
 
                       res->length(), res->charset(), decimal_value);
66
 
  return decimal_value;
67
 
}
68
 
 
69
 
 
70
 
double Item_str_func::val_real()
71
 
{
72
 
  assert(fixed == 1);
73
 
  int err_not_used;
74
 
  char *end_not_used, buff[64];
75
 
  String *res, tmp(buff,sizeof(buff), &my_charset_bin);
76
 
  res= val_str(&tmp);
77
 
  return res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
78
 
                          &end_not_used, &err_not_used) : 0.0;
79
 
}
80
 
 
81
 
 
82
 
int64_t Item_str_func::val_int()
83
 
{
84
 
  assert(fixed == 1);
85
 
  int err;
86
 
  char buff[22];
87
 
  String *res, tmp(buff,sizeof(buff), &my_charset_bin);
88
 
  res= val_str(&tmp);
89
 
  return (res ?
90
 
          my_strntoll(res->charset(), res->ptr(), res->length(), 10, NULL,
91
 
                      &err) :
92
 
          (int64_t) 0);
93
 
}
94
 
 
95
 
void Item_str_func::left_right_max_length()
96
 
{
97
 
  max_length=args[0]->max_length;
98
 
  if (args[1]->const_item())
99
 
  {
100
 
    int length=(int) args[1]->val_int()*collation.collation->mbmaxlen;
101
 
    if (length <= 0)
102
 
      max_length=0;
103
 
    else
104
 
      set_if_smaller(max_length,(uint) length);
105
 
  }
106
 
}
107
 
 
108
 
String my_empty_string("",default_charset_info);
109
 
 
110
 
} /* namespace drizzled */