~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Jay Pipes
  • Date: 2009-02-21 16:00:06 UTC
  • mto: (907.1.1 trunk-with-temporal)
  • mto: This revision was merged to the branch mainline in revision 908.
  • Revision ID: jpipes@serialcoder-20090221160006-vnk3wt4qbcz62eru
Removes the TIME column type and related time functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
22
22
#include <drizzled/function/str/replace.h>
23
23
#include <drizzled/error.h>
24
24
#include <drizzled/session.h>
25
25
 
26
 
namespace drizzled
27
 
{
28
 
 
29
26
/**
30
27
  Replace all occurences of string2 in string1 with string3.
31
28
 
32
29
  Don't reallocate val_str() if not needed.
33
30
 
34
31
  @todo
35
 
    Fix that this works with binary strings
 
32
    Fix that this works with binary strings when using USE_MB
36
33
*/
37
34
 
38
35
String *Item_func_replace::val_str(String *str)
42
39
  int offset;
43
40
  uint32_t from_length,to_length;
44
41
  bool alloced=0;
 
42
#ifdef USE_MB
45
43
  const char *ptr,*end,*strend,*search,*search_end;
46
44
  register uint32_t l;
47
45
  bool binary_cmp;
 
46
#endif
48
47
 
49
48
  null_value=0;
50
49
  res=args[0]->val_str(str);
56
55
 
57
56
  res->set_charset(collation.collation);
58
57
 
 
58
#ifdef USE_MB
59
59
  binary_cmp = ((res->charset()->state & MY_CS_BINSORT) || !use_mb(res->charset()));
 
60
#endif
60
61
 
61
62
  if (res2->length() == 0)
62
63
    return res;
 
64
#ifndef USE_MB
 
65
  if ((offset=res->strstr(*res2)) < 0)
 
66
    return res;
 
67
#else
63
68
  offset=0;
64
69
  if (binary_cmp && (offset=res->strstr(*res2)) < 0)
65
70
    return res;
 
71
#endif
66
72
  if (!(res3=args[2]->val_str(&tmp_value2)))
67
73
    goto null;
68
74
  from_length= res2->length();
69
75
  to_length=   res3->length();
70
76
 
 
77
#ifdef USE_MB
71
78
  if (!binary_cmp)
72
79
  {
73
80
    search=res2->ptr();
111
118
    }
112
119
  }
113
120
  else
 
121
#endif /* USE_MB */
114
122
    do
115
123
    {
116
124
      if (res->length()-from_length + to_length >
160
168
}
161
169
 
162
170
 
163
 
} /* namespace drizzled */