~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

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/make_set.h>
23
23
#include <drizzled/session.h>
24
24
 
25
 
namespace drizzled {
 
25
namespace drizzled
 
26
{
26
27
 
27
28
void Item_func_make_set::update_used_tables()
28
29
{
86
87
            result=res;                         // Use original string
87
88
          else
88
89
          {
89
 
            tmp_str.copy(*res);
 
90
            if (tmp_str.copy(*res))             // Don't use 'str'
 
91
              return &my_empty_string;
90
92
            result= &tmp_str;
91
93
          }
92
94
        }
94
96
        {
95
97
          if (result != &tmp_str)
96
98
          {                                     // Copy data to tmp_str
97
 
      tmp_str.alloc(result->length()+res->length()+1);
98
 
            tmp_str.copy(*result);
 
99
            if (tmp_str.alloc(result->length()+res->length()+1) ||
 
100
                tmp_str.copy(*result))
 
101
              return &my_empty_string;
99
102
            result= &tmp_str;
100
103
          }
101
 
          tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin);
102
 
    tmp_str.append(*res);
 
104
          if (tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin) || tmp_str.append(*res))
 
105
            return &my_empty_string;
103
106
        }
104
107
      }
105
108
    }
113
116
  Item *new_item= item->transform(transformer, arg);
114
117
  if (!new_item)
115
118
    return 0;
116
 
  item= new_item;
 
119
 
 
120
  /*
 
121
    Session::change_item_tree() should be called only if the tree was
 
122
    really transformed, i.e. when a new item has been created.
 
123
    Otherwise we'll be allocating a lot of unnecessary memory for
 
124
    change records at each execution.
 
125
  */
 
126
  if (item != new_item)
 
127
    session.change_item_tree(&item, new_item);
 
128
 
117
129
  return Item_str_func::transform(transformer, arg);
118
130
}
119
131
 
120
132
 
121
 
void Item_func_make_set::print(String *str)
 
133
void Item_func_make_set::print(String *str, enum_query_type query_type)
122
134
{
123
135
  str->append(STRING_WITH_LEN("make_set("));
124
 
  item->print(str);
 
136
  item->print(str, query_type);
125
137
  if (arg_count)
126
138
  {
127
139
    str->append(',');
128
 
    print_args(str, 0);
 
140
    print_args(str, 0, query_type);
129
141
  }
130
142
  str->append(')');
131
143
}