~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/range_param.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLED_OPTIMIZER_RANGE_PARAM_H
21
 
#define DRIZZLED_OPTIMIZER_RANGE_PARAM_H
22
 
 
23
 
#include "drizzled/field.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
 
28
 
typedef class Item COND;
29
 
typedef struct st_key_part KEY_PART;
30
 
 
31
 
namespace optimizer
32
 
{
33
 
 
34
 
class RangeParameter
35
 
{
36
 
public:
37
 
 
38
 
  RangeParameter()
39
 
    :
40
 
      session(NULL),
41
 
      table(NULL),
42
 
      cond(NULL),
43
 
      prev_tables(),
44
 
      read_tables(),
45
 
      current_table(),
46
 
      key_parts(NULL),
47
 
      key_parts_end(NULL),
48
 
      mem_root(NULL),
49
 
      old_root(NULL),
50
 
      keys(0),
51
 
      using_real_indexes(false),
52
 
      remove_jump_scans(false),
53
 
      alloced_sel_args(0),
54
 
      force_default_mrr(false)
55
 
  {}
56
 
 
57
 
  Session       *session;   /* Current thread handle */
58
 
  Table *table; /* Table being analyzed */
59
 
  COND *cond;   /* Used inside get_mm_tree(). */
60
 
  table_map prev_tables;
61
 
  table_map read_tables;
62
 
  table_map current_table; /* Bit of the table being analyzed */
63
 
 
64
 
  /* Array of parts of all keys for which range analysis is performed */
65
 
  KEY_PART *key_parts;
66
 
  KEY_PART *key_parts_end;
67
 
  memory::Root *mem_root; /* Memory that will be freed when range analysis completes */
68
 
  memory::Root *old_root; /* Memory that will last until the query end */
69
 
  /*
70
 
    Number of indexes used in range analysis (In SEL_TREE::keys only first
71
 
    #keys elements are not empty)
72
 
  */
73
 
  uint32_t keys;
74
 
 
75
 
  /*
76
 
    If true, the index descriptions describe real indexes (and it is ok to
77
 
    call field->optimize_range(real_keynr[...], ...).
78
 
    Otherwise index description describes fake indexes.
79
 
  */
80
 
  bool using_real_indexes;
81
 
 
82
 
  bool remove_jump_scans;
83
 
 
84
 
  /*
85
 
    used_key_no -> table_key_no translation table. Only makes sense if
86
 
    using_real_indexes==true
87
 
  */
88
 
  uint32_t real_keynr[MAX_KEY];
89
 
  /* Number of SEL_ARG objects allocated by optimizer::SEL_ARG::clone_tree operations */
90
 
  uint32_t alloced_sel_args;
91
 
  bool force_default_mrr;
92
 
};
93
 
 
94
 
class Parameter : public RangeParameter
95
 
{
96
 
public:
97
 
 
98
 
  Parameter()
99
 
    :
100
 
      RangeParameter(),
101
 
      max_key_part(0),
102
 
      range_count(0),
103
 
      quick(false),
104
 
      fields_bitmap_size(0),
105
 
      needed_fields(),
106
 
      tmp_covered_fields(),
107
 
      needed_reg(NULL),
108
 
      imerge_cost_buff(NULL),
109
 
      imerge_cost_buff_size(0),
110
 
      is_ror_scan(false),
111
 
      n_ranges(0)
112
 
  {}
113
 
 
114
 
  KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */
115
 
  uint32_t max_key_part;
116
 
  /* Number of ranges in the last checked tree->key */
117
 
  uint32_t range_count;
118
 
  unsigned char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
119
 
  unsigned char max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
120
 
  bool quick; // Don't calulate possible keys
121
 
 
122
 
  uint32_t fields_bitmap_size;
123
 
  MyBitmap needed_fields;    /* bitmask of fields needed by the query */
124
 
  MyBitmap tmp_covered_fields;
125
 
 
126
 
  key_map *needed_reg;        /* ptr to SqlSelect::needed_reg */
127
 
 
128
 
  uint32_t *imerge_cost_buff;     /* buffer for index_merge cost estimates */
129
 
  uint32_t imerge_cost_buff_size; /* size of the buffer */
130
 
 
131
 
  /* true if last checked tree->key can be used for ROR-scan */
132
 
  bool is_ror_scan;
133
 
  /* Number of ranges in the last checked tree->key */
134
 
  uint32_t n_ranges;
135
 
};
136
 
 
137
 
} /* namespace optimizer */
138
 
 
139
 
} /* namespace drizzled */
140
 
 
141
 
#endif /* DRIZZLED_OPTIMIZER_RANGE_PARAM_H */