~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_row.cc

  • Committer: Jay Pipes
  • Date: 2008-09-11 16:03:22 UTC
  • mto: (383.5.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: jay@mysql.com-20080911160322-vrl0k1djo6q6ytv1
Removed SQL_MODE variances from comment_table.test and ensured correct error thrown when a comment that is too long was input.  After moving to proto buffer definition for table, the 2048 length will go away.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
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
 
#include "config.h"
17
 
#include <drizzled/error.h>
18
 
#include <drizzled/session.h>
19
 
 
20
 
#include <drizzled/item/row.h>
21
 
 
22
 
namespace drizzled
23
 
{
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include <drizzled/server_includes.h>
24
17
 
25
18
/**
26
19
  Row items used for comparing rows and IN operations on rows:
42
35
 
43
36
  //TODO: think placing 2-3 component items in item (as it done for function)
44
37
  if ((arg_count= arg.elements))
45
 
    items= (Item**) memory::sql_alloc(sizeof(Item*)*arg_count);
 
38
    items= (Item**) sql_alloc(sizeof(Item*)*arg_count);
46
39
  else
47
40
    items= 0;
48
41
  List_iterator<Item> li(arg);
49
 
  uint32_t i= 0;
 
42
  uint i= 0;
50
43
  Item *item;
51
44
  while ((item= li++))
52
45
  {
53
46
    items[i]= item;
54
 
    i++;
 
47
    i++;    
55
48
  }
56
49
}
57
50
 
58
 
void Item_row::illegal_method_call(const char *)
 
51
void Item_row::illegal_method_call(const char *method __attribute__((unused)))
59
52
{
60
53
  assert(0);
61
54
  my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
62
55
  return;
63
56
}
64
57
 
65
 
bool Item_row::fix_fields(Session *session, Item **)
 
58
bool Item_row::fix_fields(THD *thd, Item **ref __attribute__((unused)))
66
59
{
67
60
  assert(fixed == 0);
68
61
  null_value= 0;
70
63
  Item **arg, **arg_end;
71
64
  for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++)
72
65
  {
73
 
    if ((*arg)->fix_fields(session, arg))
 
66
    if ((*arg)->fix_fields(thd, arg))
74
67
      return true;
75
68
    // we can't assign 'item' before, because fix_fields() can change arg
76
69
    Item *item= *arg;
106
99
}
107
100
 
108
101
 
109
 
void Item_row::split_sum_func(Session *session, Item **ref_pointer_array,
 
102
void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
110
103
                              List<Item> &fields)
111
104
{
112
105
  Item **arg, **arg_end;
113
106
  for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++)
114
 
    (*arg)->split_sum_func(session, ref_pointer_array, fields, arg, true);
 
107
    (*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg, true);
115
108
}
116
109
 
117
110
 
119
112
{
120
113
  used_tables_cache= 0;
121
114
  const_item_cache= 1;
122
 
  for (uint32_t i= 0; i < arg_count; i++)
 
115
  for (uint i= 0; i < arg_count; i++)
123
116
  {
124
117
    items[i]->update_used_tables();
125
118
    used_tables_cache|= items[i]->used_tables();
127
120
  }
128
121
}
129
122
 
130
 
void Item_row::fix_after_pullout(Select_Lex *new_parent, Item **)
 
123
void Item_row::fix_after_pullout(st_select_lex *new_parent,
 
124
                                 Item **ref __attribute__((unused)))
131
125
{
132
126
  used_tables_cache= 0;
133
127
  const_item_cache= 1;
134
 
  for (uint32_t i= 0; i < arg_count; i++)
 
128
  for (uint i= 0; i < arg_count; i++)
135
129
  {
136
130
    items[i]->fix_after_pullout(new_parent, &items[i]);
137
131
    used_tables_cache|= items[i]->used_tables();
139
133
  }
140
134
}
141
135
 
142
 
bool Item_row::check_cols(uint32_t c)
 
136
bool Item_row::check_cols(uint c)
143
137
{
144
138
  if (c != arg_count)
145
139
  {
152
146
void Item_row::print(String *str, enum_query_type query_type)
153
147
{
154
148
  str->append('(');
155
 
  for (uint32_t i= 0; i < arg_count; i++)
 
149
  for (uint i= 0; i < arg_count; i++)
156
150
  {
157
151
    if (i)
158
152
      str->append(',');
162
156
}
163
157
 
164
158
 
165
 
bool Item_row::walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
 
159
bool Item_row::walk(Item_processor processor, bool walk_subquery, uchar *arg)
166
160
{
167
 
  for (uint32_t i= 0; i < arg_count; i++)
 
161
  for (uint i= 0; i < arg_count; i++)
168
162
  {
169
163
    if (items[i]->walk(processor, walk_subquery, arg))
170
164
      return 1;
173
167
}
174
168
 
175
169
 
176
 
Item *Item_row::transform(Item_transformer transformer, unsigned char *arg)
 
170
Item *Item_row::transform(Item_transformer transformer, uchar *arg)
177
171
{
178
 
  for (uint32_t i= 0; i < arg_count; i++)
 
172
  for (uint i= 0; i < arg_count; i++)
179
173
  {
180
174
    Item *new_item= items[i]->transform(transformer, arg);
181
175
    if (!new_item)
182
176
      return 0;
183
177
 
184
178
    /*
185
 
      Session::change_item_tree() should be called only if the tree was
 
179
      THD::change_item_tree() should be called only if the tree was
186
180
      really transformed, i.e. when a new item has been created.
187
181
      Otherwise we'll be allocating a lot of unnecessary memory for
188
182
      change records at each execution.
189
183
    */
190
184
    if (items[i] != new_item)
191
 
      current_session->change_item_tree(&items[i], new_item);
 
185
      current_thd->change_item_tree(&items[i], new_item);
192
186
  }
193
187
  return (this->*transformer)(arg);
194
188
}
195
189
 
196
190
void Item_row::bring_value()
197
191
{
198
 
  for (uint32_t i= 0; i < arg_count; i++)
 
192
  for (uint i= 0; i < arg_count; i++)
199
193
    items[i]->bring_value();
200
194
}
201
 
 
202
 
} /* namespace drizzled */