~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

mergeĀ lp:~linuxjedi/drizzle/trunk-remove-drizzleadmin

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"
 
20
#include <config.h>
21
21
 
22
22
#include <drizzled/function/str/concat.h>
23
23
#include <drizzled/error.h>
24
24
#include <drizzled/session.h>
 
25
#include <drizzled/system_variables.h>
25
26
 
26
27
#include <algorithm>
27
28
 
28
29
using namespace std;
29
30
 
30
 
namespace drizzled
31
 
{
 
31
namespace drizzled {
32
32
 
33
33
String *Item_func_concat::val_str(String *str)
34
34
{
83
83
      }
84
84
      else if (res == &tmp_value)
85
85
      {
86
 
        if (res->append(*res2))                 // Must be a blob
87
 
          goto null;
 
86
        res->append(*res2);
88
87
      }
89
88
      else if (res2 == &tmp_value)
90
89
      {                                         // This can happend only 1 time
91
 
        if (tmp_value.replace(0,0,*res))
92
 
          goto null;
 
90
        tmp_value.replace(0,0,*res);
93
91
        res= &tmp_value;
94
92
        use_as_buff=str;                        // Put next arg here
95
93
      }
105
103
        tmp_value.length((uint32_t) (res2->ptr() - tmp_value.ptr()) +
106
104
                         res2->length());
107
105
        /* Place res2 at start of tmp_value, remove chars before res2 */
108
 
        if (tmp_value.replace(0,(uint32_t) (res2->ptr() - tmp_value.ptr()),
109
 
                              *res))
110
 
          goto null;
 
106
        tmp_value.replace(0,(uint32_t) (res2->ptr() - tmp_value.ptr()), *res);
111
107
        res= &tmp_value;
112
108
        use_as_buff=str;                        // Put next arg here
113
109
      }
127
123
        {
128
124
          if (tmp_value.alloced_length() == 0)
129
125
          {
130
 
            if (tmp_value.alloc(concat_len))
131
 
              goto null;
 
126
            tmp_value.alloc(concat_len);
132
127
          }
133
128
          else
134
129
          {
135
130
            uint32_t new_len= max(tmp_value.alloced_length() * 2, concat_len);
136
131
 
137
 
            if (tmp_value.realloc(new_len))
138
 
              goto null;
 
132
            tmp_value.realloc(new_len);
139
133
          }
140
134
        }
141
135
 
142
 
        if (tmp_value.copy(*res) || tmp_value.append(*res2))
143
 
          goto null;
 
136
        tmp_value.copy(*res);
 
137
        tmp_value.append(*res2);
144
138
 
145
139
        res= &tmp_value;
146
140
        use_as_buff=str;
252
246
    }
253
247
    else if (res == &tmp_value)
254
248
    {
255
 
      if (res->append(*sep_str) || res->append(*res2))
256
 
        goto null; // Must be a blob
 
249
      res->append(*sep_str);
 
250
      res->append(*res2);
257
251
    }
258
252
    else if (res2 == &tmp_value)
259
253
    {                                           // This can happend only 1 time
260
 
      if (tmp_value.replace(0,0,*sep_str) || tmp_value.replace(0,0,*res))
261
 
        goto null;
 
254
      tmp_value.replace(0,0,*sep_str);
 
255
      tmp_value.replace(0,0,*res);
262
256
      res= &tmp_value;
263
257
      use_as_buff=str;                          // Put next arg here
264
258
    }
274
268
      tmp_value.length((uint32_t) (res2->ptr() - tmp_value.ptr()) +
275
269
                       res2->length());
276
270
      /* Place res2 at start of tmp_value, remove chars before res2 */
277
 
      if (tmp_value.replace(0,(uint32_t) (res2->ptr() - tmp_value.ptr()),
278
 
                            *res) ||
279
 
          tmp_value.replace(res->length(),0, *sep_str))
280
 
        goto null;
 
271
      tmp_value.replace(0,(uint32_t) (res2->ptr() - tmp_value.ptr()), *res);
 
272
      tmp_value.replace(res->length(),0, *sep_str);
281
273
      res= &tmp_value;
282
274
      use_as_buff=str;                  // Put next arg here
283
275
    }
297
289
      {
298
290
        if (tmp_value.alloced_length() == 0)
299
291
        {
300
 
          if (tmp_value.alloc(concat_len))
301
 
            goto null;
 
292
          tmp_value.alloc(concat_len);
302
293
        }
303
294
        else
304
295
        {
305
296
          uint32_t new_len= max(tmp_value.alloced_length() * 2, concat_len);
306
297
 
307
 
          if (tmp_value.realloc(new_len))
308
 
            goto null;
 
298
          tmp_value.realloc(new_len);
309
299
        }
310
300
      }
311
301
 
312
 
      if (tmp_value.copy(*res) ||
313
 
          tmp_value.append(*sep_str) ||
314
 
          tmp_value.append(*res2))
315
 
        goto null;
 
302
      tmp_value.copy(*res);
 
303
      tmp_value.append(*sep_str);
 
304
      tmp_value.append(*res2);
316
305
      res= &tmp_value;
317
306
      use_as_buff=str;
318
307
    }