~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/subselect.cc

  • Committer: lbieber at stabletransit
  • Date: 2010-10-18 20:26:50 UTC
  • mfrom: (1859.1.4 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101018202650-hcvsp7yuaf1xy04s
Merge Monty - Adds support for a const std::string sys_var type.
Merge Monty - Make it possible to use sys_var directly from plugins.
Merge Padraig - Replaced a few unit8_t types that were being used as bitmaps with std::bitset

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
185
184
  bool res;
186
185
 
187
186
  assert(fixed == 0);
209
208
 
210
209
      // did we changed top item of WHERE condition
211
210
      if (unit->outer_select()->where == (*ref))
212
 
        unit->outer_select()->where= substitution; // correct WHERE for PS
 
211
      {
 
212
        unit->outer_select()->where= substitution; // correct WHERE for PS
 
213
      }
213
214
      else if (unit->outer_select()->having == (*ref))
214
 
        unit->outer_select()->having= substitution; // correct HAVING for PS
 
215
      {
 
216
        unit->outer_select()->having= substitution; // correct HAVING for PS
 
217
      }
215
218
 
216
219
      (*ref)= substitution;
217
220
      substitution->name= name;
218
221
      if (have_to_be_excluded)
219
 
        engine->exclude();
 
222
      {
 
223
        engine->exclude();
 
224
      }
220
225
      substitution= 0;
221
226
      session->where= "checking transformed subquery";
222
 
      if (!(*ref)->fixed)
223
 
        ret= (*ref)->fix_fields(session, ref);
 
227
      if (! (*ref)->fixed)
 
228
      {
 
229
        ret= (*ref)->fix_fields(session, ref);
 
230
      }
224
231
      session->where= save_where;
225
232
      return ret;
226
233
    }
235
242
  else
236
243
    goto err;
237
244
 
238
 
  if ((uncacheable= engine->uncacheable()))
 
245
  if (engine->uncacheable())
239
246
  {
240
247
    const_item_cache= 0;
241
 
    if (uncacheable & UNCACHEABLE_RAND)
 
248
    if (engine->uncacheable(UNCACHEABLE_RAND))
 
249
    {
242
250
      used_tables_cache|= RAND_TABLE_BIT;
 
251
    }
243
252
  }
244
253
  fixed= 1;
245
254
 
381
390
 
382
391
void Item_subselect::update_used_tables()
383
392
{
384
 
  if (!engine->uncacheable())
 
393
  if (! engine->uncacheable())
385
394
  {
386
395
    // did all used tables become static?
387
396
    if (!(used_tables_cache & ~engine->upper_select_const_tables()))
1004
1013
    later in this method.
1005
1014
  */
1006
1015
  if ((abort_on_null || (upper_item && upper_item->top_level())) &&
1007
 
      !select_lex->master_unit()->uncacheable && !func->eqne_op())
 
1016
      select_lex->master_unit()->uncacheable.none() && !func->eqne_op())
1008
1017
  {
1009
1018
    if (substitution)
1010
1019
    {
1100
1109
                              (char *)"<no matter>",
1101
1110
                              (char *)in_left_expr_name);
1102
1111
 
1103
 
    master_unit->uncacheable|= UNCACHEABLE_DEPENDENT;
 
1112
    master_unit->uncacheable.set(UNCACHEABLE_DEPENDENT);
1104
1113
  }
1105
1114
 
1106
1115
  if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
1163
1172
{
1164
1173
  Select_Lex *select_lex= join->select_lex;
1165
1174
 
1166
 
  select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
 
1175
  select_lex->uncacheable.set(UNCACHEABLE_DEPENDENT);
1167
1176
  if (join->having || select_lex->with_sum_func ||
1168
1177
      select_lex->group_list.elements)
1169
1178
  {
1369
1378
    optimizer->keep_top_level_cache();
1370
1379
 
1371
1380
    session->lex->current_select= current;
1372
 
    master_unit->uncacheable|= UNCACHEABLE_DEPENDENT;
 
1381
    master_unit->uncacheable.set(UNCACHEABLE_DEPENDENT);
1373
1382
 
1374
1383
    if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
1375
1384
    {
1421
1430
                        select_lex->group_list.first ||
1422
1431
                        !select_lex->table_list.elements);
1423
1432
 
1424
 
  select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
 
1433
  select_lex->uncacheable.set(UNCACHEABLE_DEPENDENT);
1425
1434
  if (is_having_used)
1426
1435
  {
1427
1436
    /*
2152
2161
      session->lex->current_select= save_select;
2153
2162
      return(join->error ? join->error : 1);
2154
2163
    }
2155
 
    if (!select_lex->uncacheable && session->lex->describe &&
 
2164
    if (select_lex->uncacheable.none() && session->lex->describe &&
2156
2165
        !(join->select_options & SELECT_DESCRIBE) &&
2157
2166
        join->need_tmp && item->const_item())
2158
2167
    {
2162
2171
        called by EXPLAIN and we need to preserve the initial query structure
2163
2172
        so we can display it.
2164
2173
       */
2165
 
      select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
2166
 
      select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
 
2174
      select_lex->uncacheable.set(UNCACHEABLE_EXPLAIN);
 
2175
      select_lex->master_unit()->uncacheable.set(UNCACHEABLE_EXPLAIN);
2167
2176
      if (join->init_save_join_tab())
2168
2177
        return(1);
2169
2178
    }
2172
2181
      return(1);
2173
2182
    }
2174
2183
  }
2175
 
  if (select_lex->uncacheable &&
2176
 
      select_lex->uncacheable != UNCACHEABLE_EXPLAIN
2177
 
      && executed)
 
2184
  if (select_lex->uncacheable.any() &&
 
2185
      ! select_lex->uncacheable.test(UNCACHEABLE_EXPLAIN) &&
 
2186
      executed)
2178
2187
  {
2179
2188
    if (join->reinit())
2180
2189
    {
2181
2190
      session->where= save_where;
2182
2191
      session->lex->current_select= save_select;
2183
 
      return(1);
 
2192
      return 1;
2184
2193
    }
2185
2194
    item->reset();
2186
2195
    item->assigned((executed= 0));
2633
2642
}
2634
2643
 
2635
2644
 
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;
 
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);
2645
2666
}
2646
2667
 
2647
2668