~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

  • Committer: Prafulla Tekawade
  • Date: 2010-07-18 03:36:32 UTC
  • mto: (1662.1.4 rollup)
  • mto: This revision was merged to the branch mainline in revision 1664.
  • Revision ID: prafulla_t@users.sourceforge.net-20100718033632-p7q6qtgliqbhe38p
Fix for Bug 592444

There were two problems:
o. In greedy_search optimizer method, best_extension_by_limited search
   maintains join embedding(nestedness) of tables added so far, so that 
   correct(valid)  join order is selected
   These are requirements from nested outer join executioner.
   The problem was, embedding_map was not correctly updated when a table 
   is added to optimal plan outside best_extension_by_limited search, 
   by greedy_search method. We need to update join->cur_embedding_map
   correctly here so that execution plan for other tables get
   generated.
   Invoked checked_interleaving_with_nj from greedy_search on the
   best_table selected. Fixed its prototype to take only one JoinTab
   This is same as mysql 5.1 source tree.
o. The other problem was, join->cur_embedding_map was not restored correctly
   when a table is added to the optimal plan to reflect the current embedding 
   map. 
   Taken good documented method restore_prev_nj_state which restores 
   cur_embedding_map from mysql 5.1 source tree and modified it for drizzled 
   code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
239
239
 
240
240
              ref.key_buff= key_buff;
241
241
              Item_field *item_field= (Item_field*) (expr->real_item());
242
 
              Table *table= item_field->field->getTable();
 
242
              Table *table= item_field->field->table;
243
243
 
244
244
              /*
245
245
                 Look for a partial key that can be used for optimization.
407
407
 
408
408
              ref.key_buff= key_buff;
409
409
              Item_field *item_field= (Item_field*) (expr->real_item());
410
 
              Table *table= item_field->field->getTable();
 
410
              Table *table= item_field->field->table;
411
411
 
412
412
              /*
413
413
                 Look for a partial key that can be used for optimization.
662
662
 
663
663
  field->setWriteSet();
664
664
 
665
 
  if (! (cond->used_tables() & field->getTable()->map))
 
665
  if (! (cond->used_tables() & field->table->map))
666
666
  {
667
667
    /* Condition doesn't restrict the used table */
668
668
    return 1;
907
907
    return 0; // Not key field
908
908
  }
909
909
 
910
 
  Table *table= field->getTable();
 
910
  Table *table= field->table;
911
911
  uint32_t idx= 0;
912
912
 
913
913
  KeyInfo *keyinfo,*keyinfo_end= NULL;
1028
1028
                           uint32_t range_fl,
1029
1029
                           uint32_t prefix_len)
1030
1030
{
1031
 
  if (key_cmp_if_same(field->getTable(), ref->key_buff, ref->key, prefix_len))
 
1031
  if (key_cmp_if_same(field->table, ref->key_buff, ref->key, prefix_len))
1032
1032
  {
1033
1033
    return 1;
1034
1034
  }
1069
1069
    return 0;
1070
1070
  }
1071
1071
 
1072
 
  if (cond->used_tables() != field->getTable()->map)
 
1072
  if (cond->used_tables() != field->table->map)
1073
1073
  {
1074
1074
    return 0;
1075
1075
  }