~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/item_row.cc

Renamed more stuff to drizzle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
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
 
{
 
16
#include "mysql_priv.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
 
  assert(0);
 
53
  DBUG_ENTER("Item_row::illegal_method_call");
 
54
  DBUG_PRINT("error", ("!!! %s method was called for row item", method));
 
55
  DBUG_ASSERT(0);
61
56
  my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
62
 
  return;
 
57
  DBUG_VOID_RETURN;
63
58
}
64
59
 
65
 
bool Item_row::fix_fields(Session *session, Item **)
 
60
bool Item_row::fix_fields(THD *thd, Item **ref __attribute__((__unused__)))
66
61
{
67
 
  assert(fixed == 0);
 
62
  DBUG_ASSERT(fixed == 0);
68
63
  null_value= 0;
69
64
  maybe_null= 0;
70
65
  Item **arg, **arg_end;
71
66
  for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++)
72
67
  {
73
 
    if ((*arg)->fix_fields(session, arg))
74
 
      return true;
 
68
    if ((*arg)->fix_fields(thd, arg))
 
69
      return TRUE;
75
70
    // we can't assign 'item' before, because fix_fields() can change arg
76
71
    Item *item= *arg;
77
72
    used_tables_cache |= item->used_tables();
90
85
    with_sum_func= with_sum_func || item->with_sum_func;
91
86
  }
92
87
  fixed= 1;
93
 
  return false;
 
88
  return FALSE;
94
89
}
95
90
 
96
91
 
97
92
void Item_row::cleanup()
98
93
{
 
94
  DBUG_ENTER("Item_row::cleanup");
 
95
 
99
96
  Item::cleanup();
100
97
  /* Reset to the original values */
101
98
  used_tables_cache= 0;
102
99
  const_item_cache= 1;
103
100
  with_null= 0;
104
101
 
105
 
  return;
 
102
  DBUG_VOID_RETURN;
106
103
}
107
104
 
108
105
 
109
 
void Item_row::split_sum_func(Session *session, Item **ref_pointer_array,
 
106
void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
110
107
                              List<Item> &fields)
111
108
{
112
109
  Item **arg, **arg_end;
113
110
  for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++)
114
 
    (*arg)->split_sum_func(session, ref_pointer_array, fields, arg, true);
 
111
    (*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg, TRUE);
115
112
}
116
113
 
117
114
 
119
116
{
120
117
  used_tables_cache= 0;
121
118
  const_item_cache= 1;
122
 
  for (uint32_t i= 0; i < arg_count; i++)
 
119
  for (uint i= 0; i < arg_count; i++)
123
120
  {
124
121
    items[i]->update_used_tables();
125
122
    used_tables_cache|= items[i]->used_tables();
127
124
  }
128
125
}
129
126
 
130
 
void Item_row::fix_after_pullout(Select_Lex *new_parent, Item **)
 
127
void Item_row::fix_after_pullout(st_select_lex *new_parent,
 
128
                                 Item **ref __attribute__((__unused__)))
131
129
{
132
130
  used_tables_cache= 0;
133
131
  const_item_cache= 1;
134
 
  for (uint32_t i= 0; i < arg_count; i++)
 
132
  for (uint i= 0; i < arg_count; i++)
135
133
  {
136
134
    items[i]->fix_after_pullout(new_parent, &items[i]);
137
135
    used_tables_cache|= items[i]->used_tables();
139
137
  }
140
138
}
141
139
 
142
 
bool Item_row::check_cols(uint32_t c)
 
140
bool Item_row::check_cols(uint c)
143
141
{
144
142
  if (c != arg_count)
145
143
  {
152
150
void Item_row::print(String *str, enum_query_type query_type)
153
151
{
154
152
  str->append('(');
155
 
  for (uint32_t i= 0; i < arg_count; i++)
 
153
  for (uint i= 0; i < arg_count; i++)
156
154
  {
157
155
    if (i)
158
156
      str->append(',');
162
160
}
163
161
 
164
162
 
165
 
bool Item_row::walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
 
163
bool Item_row::walk(Item_processor processor, bool walk_subquery, uchar *arg)
166
164
{
167
 
  for (uint32_t i= 0; i < arg_count; i++)
 
165
  for (uint i= 0; i < arg_count; i++)
168
166
  {
169
167
    if (items[i]->walk(processor, walk_subquery, arg))
170
168
      return 1;
173
171
}
174
172
 
175
173
 
176
 
Item *Item_row::transform(Item_transformer transformer, unsigned char *arg)
 
174
Item *Item_row::transform(Item_transformer transformer, uchar *arg)
177
175
{
178
 
  for (uint32_t i= 0; i < arg_count; i++)
 
176
  for (uint i= 0; i < arg_count; i++)
179
177
  {
180
178
    Item *new_item= items[i]->transform(transformer, arg);
181
179
    if (!new_item)
182
180
      return 0;
183
181
 
184
182
    /*
185
 
      Session::change_item_tree() should be called only if the tree was
 
183
      THD::change_item_tree() should be called only if the tree was
186
184
      really transformed, i.e. when a new item has been created.
187
185
      Otherwise we'll be allocating a lot of unnecessary memory for
188
186
      change records at each execution.
189
187
    */
190
188
    if (items[i] != new_item)
191
 
      current_session->change_item_tree(&items[i], new_item);
 
189
      current_thd->change_item_tree(&items[i], new_item);
192
190
  }
193
191
  return (this->*transformer)(arg);
194
192
}
195
193
 
196
194
void Item_row::bring_value()
197
195
{
198
 
  for (uint32_t i= 0; i < arg_count; i++)
 
196
  for (uint i= 0; i < arg_count; i++)
199
197
    items[i]->bring_value();
200
198
}
201
 
 
202
 
} /* namespace drizzled */