~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Brian Aker
  • Date: 2009-07-28 17:52:18 UTC
  • mto: (1103.1.1 staging)
  • mto: This revision was merged to the branch mainline in revision 1104.
  • Revision ID: brian@gaz-20090728175218-rytjked8peliedop
First pass through removing most of the semi_join code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
*/
25
25
#include "drizzled/server_includes.h"
26
26
#include "drizzled/sql_select.h" /* include join.h */
27
 
#include "drizzled/semi_join_table.h"
28
27
#include "drizzled/table_map_iterator.h"
29
28
 
30
29
#include "drizzled/error.h"
402
401
    }
403
402
  }
404
403
 
405
 
  if (join->flatten_subqueries())
406
 
  {
407
 
    err= 1;
408
 
    goto err;
409
 
  }
410
 
 
411
404
  if ((err= join->optimize()))
412
405
  {
413
406
    goto err;                                   // 1
4039
4032
  return false;
4040
4033
}
4041
4034
 
4042
 
void advance_sj_state(const table_map remaining_tables, const JoinTable *tab)
4043
 
{
4044
 
  TableList *emb_sj_nest;
4045
 
  if ((emb_sj_nest= tab->emb_sj_nest))
4046
 
  {
4047
 
    tab->join->cur_emb_sj_nests |= emb_sj_nest->sj_inner_tables;
4048
 
    /* Remove the sj_nest if all of its SJ-inner tables are in cur_table_map */
4049
 
    if (!(remaining_tables & emb_sj_nest->sj_inner_tables))
4050
 
      tab->join->cur_emb_sj_nests &= ~emb_sj_nest->sj_inner_tables;
4051
 
  }
4052
 
}
4053
 
 
4054
 
/*
4055
 
  we assume remaining_tables doesnt contain @tab.
4056
 
*/
4057
 
void restore_prev_sj_state(const table_map remaining_tables, const JoinTable *tab)
4058
 
{
4059
 
  TableList *emb_sj_nest;
4060
 
  if ((emb_sj_nest= tab->emb_sj_nest))
4061
 
  {
4062
 
    /* If we're removing the last SJ-inner table, remove the sj-nest */
4063
 
    if ((remaining_tables & emb_sj_nest->sj_inner_tables) ==
4064
 
        (emb_sj_nest->sj_inner_tables & ~tab->table->map))
4065
 
    {
4066
 
      tab->join->cur_emb_sj_nests &= ~emb_sj_nest->sj_inner_tables;
4067
 
    }
4068
 
  }
4069
 
}
4070
 
 
4071
4035
COND *optimize_cond(JOIN *join, COND *conds, List<TableList> *join_list, Item::cond_result *cond_value)
4072
4036
{
4073
4037
  Session *session= join->session;
4700
4664
  enum_nested_loop_state rc;
4701
4665
  READ_RECORD *info= &join_tab->read_record;
4702
4666
 
4703
 
  if (join_tab->flush_weedout_table)
4704
 
  {
4705
 
    join_tab->flush_weedout_table->reset();
4706
 
  }
4707
 
 
4708
4667
  if (join->resume_nested_loop)
4709
4668
  {
4710
4669
    /* If not the last table, plunge down the nested loop */
8145
8104
          extra.append(STRING_WITH_LEN("; LooseScan"));
8146
8105
        }
8147
8106
 
8148
 
        if (tab->flush_weedout_table)
8149
 
          extra.append(STRING_WITH_LEN("; Start temporary"));
8150
 
        else if (tab->check_weed_out_table)
8151
 
          extra.append(STRING_WITH_LEN("; End temporary"));
8152
 
        else if (tab->do_firstmatch)
8153
 
        {
8154
 
          extra.append(STRING_WITH_LEN("; FirstMatch("));
8155
 
          Table *prev_table=tab->do_firstmatch->table;
8156
 
          if (prev_table->derived_select_number)
8157
 
          {
8158
 
            char namebuf[NAME_LEN];
8159
 
            /* Derived table name generation */
8160
 
            int len= snprintf(namebuf, sizeof(namebuf)-1,
8161
 
                              "<derived%u>",
8162
 
                              prev_table->derived_select_number);
8163
 
            extra.append(namebuf, len);
8164
 
          }
8165
 
          else
8166
 
            extra.append(prev_table->pos_in_table_list->alias);
8167
 
          extra.append(STRING_WITH_LEN(")"));
8168
 
        }
8169
 
 
8170
8107
        for (uint32_t part= 0; part < tab->ref.key_parts; part++)
8171
8108
        {
8172
8109
          if (tab->ref.cond_guards[part])