~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_ror_union_select.cc

  • Committer: Mark Atwood
  • Date: 2011-06-24 11:45:17 UTC
  • mfrom: (2318.6.64 rf)
  • Revision ID: me@mark.atwood.name-20110624114517-1mq8no6jlp2nrg7m
mergeĀ lp:~olafvdspek/drizzle/refactor15

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
  have_prev_rowid= false;
82
82
  if (! scans_inited)
83
83
  {
84
 
    for (vector<optimizer::QuickSelectInterface *>::iterator it= quick_selects.begin();
85
 
         it != quick_selects.end();
86
 
         ++it)
 
84
    BOOST_FOREACH(QuickSelectInterface* it, quick_selects)
87
85
    {
88
 
      if ((*it)->init_ror_merged_scan(false))
 
86
      if (it->init_ror_merged_scan(false))
89
87
      {
90
88
        return 0;
91
89
      }
100
98
    Initialize scans for merged quick selects and put all merged quick
101
99
    selects into the queue.
102
100
  */
103
 
  for (vector<optimizer::QuickSelectInterface *>::iterator it= quick_selects.begin();
104
 
       it != quick_selects.end();
105
 
       ++it)
 
101
  BOOST_FOREACH(QuickSelectInterface* it, quick_selects)
106
102
  {
107
 
    if ((*it)->reset())
108
 
    {
 
103
    if (it->reset())
109
104
      return 0;
110
 
    }
111
 
    
112
 
    int error= (*it)->get_next();
113
 
    if (error)
114
 
    {
115
 
      if (error == HA_ERR_END_OF_FILE)
116
 
      {
117
 
        continue;
118
 
      }
119
 
    }
120
 
    (*it)->save_last_pos();
121
 
    queue->push(*it);
 
105
    if (it->get_next() == HA_ERR_END_OF_FILE)
 
106
      continue;
 
107
    it->save_last_pos();
 
108
    queue->push(it);
122
109
  }
123
 
 
124
110
  if (head->cursor->startTableScan(1))
125
 
  {
126
111
    return 0;
127
 
  }
128
 
 
129
112
  return 0;
130
113
}
131
114
 
157
140
 
158
141
bool optimizer::QuickRorUnionSelect::is_keys_used(const boost::dynamic_bitset<>& fields)
159
142
{
160
 
  for (vector<optimizer::QuickSelectInterface *>::iterator it= quick_selects.begin();
161
 
       it != quick_selects.end();
162
 
       ++it)
 
143
  BOOST_FOREACH(QuickSelectInterface* it, quick_selects)
163
144
  {
164
 
    if ((*it)->is_keys_used(fields))
165
 
    {
 
145
    if (it->is_keys_used(fields))
166
146
      return true;
167
 
    }
168
147
  }
169
148
  return false;
170
149
}
226
205
{
227
206
  bool first= true;
228
207
  str->append("union(");
229
 
  for (vector<optimizer::QuickSelectInterface *>::iterator it= quick_selects.begin();
230
 
       it != quick_selects.end();
231
 
       ++it)
 
208
  BOOST_FOREACH(QuickSelectInterface* it, quick_selects)
232
209
  {
233
 
    if (! first)
 
210
    if (first)
 
211
      first= false;
 
212
    else
234
213
      str->append(",");
235
 
    else
236
 
      first= false;
237
 
    (*it)->add_info_string(str);
 
214
    it->add_info_string(str);
238
215
  }
239
216
  str->append(")");
240
217
}
241
218
 
242
219
 
243
 
void optimizer::QuickRorUnionSelect::add_keys_and_lengths(string *key_names,
244
 
                                                          string *used_lengths)
 
220
void optimizer::QuickRorUnionSelect::add_keys_and_lengths(string *key_names, string *used_lengths)
245
221
{
246
222
  bool first= true;
247
 
  for (vector<optimizer::QuickSelectInterface *>::iterator it= quick_selects.begin();
248
 
       it != quick_selects.end();
249
 
       ++it)
 
223
  BOOST_FOREACH(QuickSelectInterface* it, quick_selects)
250
224
  {
251
225
    if (first)
252
 
    {
253
226
      first= false;
254
 
    }
255
227
    else
256
228
    {
257
229
      used_lengths->append(",");
258
230
      key_names->append(",");
259
231
    }
260
 
    (*it)->add_keys_and_lengths(key_names, used_lengths);
 
232
    it->add_keys_and_lengths(key_names, used_lengths);
261
233
  }
262
234
}
263
235