~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/subselect.cc

  • Committer: Paul McCullagh
  • Date: 2010-09-22 13:04:27 UTC
  • mto: (1787.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1788.
  • Revision ID: paul.mccullagh@primebase.org-20100922130427-utakdj4ec4uiv1kc
Fixed PBXT recovery and shutdown, added shutdownPlugin() call to all plugins before the plugins are deleted

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 */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/**
17
17
  @file
181
181
bool Item_subselect::fix_fields(Session *session_param, Item **ref)
182
182
{
183
183
  char const *save_where= session_param->where;
 
184
  uint8_t uncacheable;
184
185
  bool res;
185
186
 
186
187
  assert(fixed == 0);
208
209
 
209
210
      // did we changed top item of WHERE condition
210
211
      if (unit->outer_select()->where == (*ref))
211
 
      {
212
 
        unit->outer_select()->where= substitution; // correct WHERE for PS
213
 
      }
 
212
        unit->outer_select()->where= substitution; // correct WHERE for PS
214
213
      else if (unit->outer_select()->having == (*ref))
215
 
      {
216
 
        unit->outer_select()->having= substitution; // correct HAVING for PS
217
 
      }
 
214
        unit->outer_select()->having= substitution; // correct HAVING for PS
218
215
 
219
216
      (*ref)= substitution;
220
217
      substitution->name= name;
221
218
      if (have_to_be_excluded)
222
 
      {
223
 
        engine->exclude();
224
 
      }
 
219
        engine->exclude();
225
220
      substitution= 0;
226
221
      session->where= "checking transformed subquery";
227
 
      if (! (*ref)->fixed)
228
 
      {
229
 
        ret= (*ref)->fix_fields(session, ref);
230
 
      }
 
222
      if (!(*ref)->fixed)
 
223
        ret= (*ref)->fix_fields(session, ref);
231
224
      session->where= save_where;
232
225
      return ret;
233
226
    }
242
235
  else
243
236
    goto err;
244
237
 
245
 
  if (engine->uncacheable())
 
238
  if ((uncacheable= engine->uncacheable()))
246
239
  {
247
240
    const_item_cache= 0;
248
 
    if (engine->uncacheable(UNCACHEABLE_RAND))
249
 
    {
 
241
    if (uncacheable & UNCACHEABLE_RAND)
250
242
      used_tables_cache|= RAND_TABLE_BIT;
251
 
    }
252
243
  }
253
244
  fixed= 1;
254
245
 
268
259
    {
269
260
      List_iterator<Item> li(lex->item_list);
270
261
      Item *item;
271
 
      Order *order;
 
262
      order_st *order;
272
263
 
273
264
      if (lex->where && (lex->where)->walk(processor, walk_subquery, argument))
274
265
        return 1;
281
272
        if (item->walk(processor, walk_subquery, argument))
282
273
          return 1;
283
274
      }
284
 
      for (order= (Order*) lex->order_list.first ; order; order= order->next)
 
275
      for (order= (order_st*) lex->order_list.first ; order; order= order->next)
285
276
      {
286
277
        if ((*order->item)->walk(processor, walk_subquery, argument))
287
278
          return 1;
288
279
      }
289
 
      for (order= (Order*) lex->group_list.first ; order; order= order->next)
 
280
      for (order= (order_st*) lex->group_list.first ; order; order= order->next)
290
281
      {
291
282
        if ((*order->item)->walk(processor, walk_subquery, argument))
292
283
          return 1;
390
381
 
391
382
void Item_subselect::update_used_tables()
392
383
{
393
 
  if (! engine->uncacheable())
 
384
  if (!engine->uncacheable())
394
385
  {
395
386
    // did all used tables become static?
396
387
    if (!(used_tables_cache & ~engine->upper_select_const_tables()))
1013
1004
    later in this method.
1014
1005
  */
1015
1006
  if ((abort_on_null || (upper_item && upper_item->top_level())) &&
1016
 
      select_lex->master_unit()->uncacheable.none() && !func->eqne_op())
 
1007
      !select_lex->master_unit()->uncacheable && !func->eqne_op())
1017
1008
  {
1018
1009
    if (substitution)
1019
1010
    {
1109
1100
                              (char *)"<no matter>",
1110
1101
                              (char *)in_left_expr_name);
1111
1102
 
1112
 
    master_unit->uncacheable.set(UNCACHEABLE_DEPENDENT);
 
1103
    master_unit->uncacheable|= UNCACHEABLE_DEPENDENT;
1113
1104
  }
1114
1105
 
1115
1106
  if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
1172
1163
{
1173
1164
  Select_Lex *select_lex= join->select_lex;
1174
1165
 
1175
 
  select_lex->uncacheable.set(UNCACHEABLE_DEPENDENT);
 
1166
  select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
1176
1167
  if (join->having || select_lex->with_sum_func ||
1177
1168
      select_lex->group_list.elements)
1178
1169
  {
1378
1369
    optimizer->keep_top_level_cache();
1379
1370
 
1380
1371
    session->lex->current_select= current;
1381
 
    master_unit->uncacheable.set(UNCACHEABLE_DEPENDENT);
 
1372
    master_unit->uncacheable|= UNCACHEABLE_DEPENDENT;
1382
1373
 
1383
1374
    if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
1384
1375
    {
1430
1421
                        select_lex->group_list.first ||
1431
1422
                        !select_lex->table_list.elements);
1432
1423
 
1433
 
  select_lex->uncacheable.set(UNCACHEABLE_DEPENDENT);
 
1424
  select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
1434
1425
  if (is_having_used)
1435
1426
  {
1436
1427
    /*
2039
2030
                    select_lex->where,
2040
2031
                    select_lex->order_list.elements +
2041
2032
                    select_lex->group_list.elements,
2042
 
                    (Order*) select_lex->order_list.first,
2043
 
                    (Order*) select_lex->group_list.first,
 
2033
                    (order_st*) select_lex->order_list.first,
 
2034
                    (order_st*) select_lex->group_list.first,
2044
2035
                    select_lex->having,
2045
2036
                    select_lex, select_lex->master_unit()))
2046
2037
    return 1;
2161
2152
      session->lex->current_select= save_select;
2162
2153
      return(join->error ? join->error : 1);
2163
2154
    }
2164
 
    if (select_lex->uncacheable.none() && session->lex->describe &&
 
2155
    if (!select_lex->uncacheable && session->lex->describe &&
2165
2156
        !(join->select_options & SELECT_DESCRIBE) &&
2166
2157
        join->need_tmp && item->const_item())
2167
2158
    {
2171
2162
        called by EXPLAIN and we need to preserve the initial query structure
2172
2163
        so we can display it.
2173
2164
       */
2174
 
      select_lex->uncacheable.set(UNCACHEABLE_EXPLAIN);
2175
 
      select_lex->master_unit()->uncacheable.set(UNCACHEABLE_EXPLAIN);
 
2165
      select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
 
2166
      select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
2176
2167
      if (join->init_save_join_tab())
2177
2168
        return(1);
2178
2169
    }
2181
2172
      return(1);
2182
2173
    }
2183
2174
  }
2184
 
  if (select_lex->uncacheable.any() &&
2185
 
      ! select_lex->uncacheable.test(UNCACHEABLE_EXPLAIN) &&
2186
 
      executed)
 
2175
  if (select_lex->uncacheable &&
 
2176
      select_lex->uncacheable != UNCACHEABLE_EXPLAIN
 
2177
      && executed)
2187
2178
  {
2188
2179
    if (join->reinit())
2189
2180
    {
2190
2181
      session->where= save_where;
2191
2182
      session->lex->current_select= save_select;
2192
 
      return 1;
 
2183
      return(1);
2193
2184
    }
2194
2185
    item->reset();
2195
2186
    item->assigned((executed= 0));
2642
2633
}
2643
2634
 
2644
2635
 
2645
 
bool subselect_single_select_engine::uncacheable()
2646
 
{
2647
 
  return select_lex->uncacheable.any();
2648
 
}
2649
 
 
2650
 
 
2651
 
bool subselect_single_select_engine::uncacheable(uint32_t bit_pos)
2652
 
{
2653
 
  return select_lex->uncacheable.test(bit_pos);
2654
 
}
2655
 
 
2656
 
 
2657
 
bool subselect_union_engine::uncacheable()
2658
 
{
2659
 
  return unit->uncacheable.any();
2660
 
}
2661
 
 
2662
 
 
2663
 
bool subselect_union_engine::uncacheable(uint32_t bit_pos)
2664
 
{
2665
 
  return unit->uncacheable.test(bit_pos);
 
2636
uint8_t subselect_single_select_engine::uncacheable()
 
2637
{
 
2638
  return select_lex->uncacheable;
 
2639
}
 
2640
 
 
2641
 
 
2642
uint8_t subselect_union_engine::uncacheable()
 
2643
{
 
2644
  return unit->uncacheable;
2666
2645
}
2667
2646
 
2668
2647