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