~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.h

Reverted my change to interval_list

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#ifndef DRIZZLED_JOIN_H
28
28
#define DRIZZLED_JOIN_H
29
29
 
30
 
#include <drizzled/optimizer/position.h>
31
 
#include "drizzled/sql_select.h"
32
 
#include <bitset>
33
 
 
34
 
namespace drizzled
35
 
{
36
 
 
37
 
class JOIN :public memory::SqlAlloc
 
30
class JOIN :public Sql_alloc
38
31
{
39
32
  JOIN(const JOIN &rhs);                        /**< not implemented */
40
33
  JOIN& operator=(const JOIN &rhs);             /**< not implemented */
41
 
 
42
 
  /**
43
 
   * Contains a partial query execution plan which is extended during
44
 
   * cost-based optimization.
45
 
   */
46
 
  optimizer::Position positions[MAX_TABLES+1];
47
 
 
48
 
  /**
49
 
   * Contains the optimal query execution plan after cost-based optimization
50
 
   * has taken place. 
51
 
   */
52
 
  optimizer::Position best_positions[MAX_TABLES+1];
53
 
 
54
34
public:
55
35
  JoinTable *join_tab;
56
36
  JoinTable **best_ref;
109
89
  bool simple_group;
110
90
  /**
111
91
    Is set only in case if we have a GROUP BY clause
112
 
    and no ORDER BY after constant elimination of 'order'.
 
92
    and no order_st BY after constant elimination of 'order'.
113
93
  */
114
94
  bool no_order;
115
 
  /** Is set if we have a GROUP BY and we have ORDER BY on a constant. */
 
95
  /** Is set if we have a GROUP BY and we have order_st BY on a constant. */
116
96
  bool skip_sort_order;
117
97
  bool union_part; /**< this subselect is part of union */
118
98
  bool optimized; /**< flag to avoid double optimization in EXPLAIN */
147
127
  Select_Lex_Unit *unit;
148
128
  /** select that processed */
149
129
  Select_Lex *select_lex;
150
 
  optimizer::SqlSelect *select; /**< created in optimization phase */
 
130
  SQL_SELECT *select; /**< created in optimisation phase */
 
131
  Array<Item_in_subselect> sj_subselects;
 
132
 
 
133
  POSITION positions[MAX_TABLES+1];
 
134
  POSITION best_positions[MAX_TABLES+1];
151
135
 
152
136
  /**
153
137
    Bitmap of nested joins embedding the position at the end of the current
154
138
    partial join (valid only during join optimizer run).
155
139
  */
156
 
  std::bitset<64> cur_embedding_map;
 
140
  nested_join_map cur_embedding_map;
157
141
 
158
 
  /**
159
 
   * The cost for the final query execution plan chosen after optimization
160
 
   * has completed. The QEP is stored in the best_positions variable.
161
 
   */
162
142
  double best_read;
163
143
  List<Cached_item> group_fields;
164
144
  List<Cached_item> group_fields_cache;
274
254
      unit(NULL),
275
255
      select_lex(NULL),
276
256
      select(NULL),
 
257
      sj_subselects(session_arg->mem_root, 4),
277
258
      exec_tmp_table1(NULL),
278
259
      exec_tmp_table2(NULL),
279
260
      sum_funcs(NULL),
462
443
    return (unit == &session->lex->unit && (unit->fake_select_lex == 0 ||
463
444
                                        select_lex == unit->fake_select_lex));
464
445
  }
465
 
 
466
 
  /**
467
 
   * Copy the partial query plan into the optimal query plan.
468
 
   *
469
 
   * @param[in] size the size of the plan which is to be copied
470
 
   */
471
 
  void copyPartialPlanIntoOptimalPlan(uint32_t size)
472
 
  {
473
 
    memcpy(best_positions, positions, 
474
 
           sizeof(optimizer::Position) * size);
475
 
  }
476
 
 
477
 
  void cache_const_exprs();
478
 
 
479
 
  /**
480
 
   * @param[in] index the index of the position to retrieve
481
 
   * @return a reference to the specified position in the optimal
482
 
   *         query plan
483
 
   */
484
 
  optimizer::Position &getPosFromOptimalPlan(uint32_t index)
485
 
  {
486
 
    return best_positions[index];
487
 
  }
488
 
 
489
 
  /**
490
 
   * @param[in] index the index of the position to retrieve
491
 
   * @return a reference to the specified position in the partial
492
 
   *         query plan
493
 
   */
494
 
  optimizer::Position &getPosFromPartialPlan(uint32_t index)
495
 
  {
496
 
    return positions[index];
497
 
  }
498
 
 
499
 
  /**
500
 
   * @param[in] index the index of the position to set
501
 
   * @param[in] in_pos the value to set the position to
502
 
   */
503
 
  void setPosInPartialPlan(uint32_t index, optimizer::Position &in_pos)
504
 
  {
505
 
    positions[index]= in_pos;
506
 
  }
507
 
 
508
 
  /**
509
 
   * @return a pointer to the first position in the partial query plan
510
 
   */
511
 
  optimizer::Position *getFirstPosInPartialPlan()
512
 
  {
513
 
    return positions;
514
 
  }
515
 
 
516
 
  /**
517
 
   * @param[in] index the index of the operator to retrieve from the partial
518
 
   *                  query plan
519
 
   * @return a pointer to the position in the partial query plan
520
 
   */
521
 
  optimizer::Position *getSpecificPosInPartialPlan(int32_t index)
522
 
  {
523
 
    return positions + index;
524
 
  }
525
 
 
526
446
};
527
447
 
528
448
enum_nested_loop_state evaluate_join_record(JOIN *join, JoinTable *join_tab, int error);
533
453
enum_nested_loop_state end_update(JOIN *join, JoinTable *join_tab, bool end_of_records);
534
454
enum_nested_loop_state end_unique_update(JOIN *join, JoinTable *join_tab, bool end_of_records);
535
455
 
536
 
} /* namespace drizzled */
537
 
 
538
456
#endif /* DRIZZLED_JOIN_H */