1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLE_OPTIMIZER_RANGE_PARAM_H
21
#define DRIZZLE_OPTIMIZER_RANGE_PARAM_H
23
#include "drizzled/field.h"
25
typedef class Item COND;
26
typedef struct st_key_part KEY_PART;
37
Session *session; /* Current thread handle */
38
Table *table; /* Table being analyzed */
39
COND *cond; /* Used inside get_mm_tree(). */
40
table_map prev_tables;
41
table_map read_tables;
42
table_map current_table; /* Bit of the table being analyzed */
44
/* Array of parts of all keys for which range analysis is performed */
46
KEY_PART *key_parts_end;
47
MEM_ROOT *mem_root; /* Memory that will be freed when range analysis completes */
48
MEM_ROOT *old_root; /* Memory that will last until the query end */
50
Number of indexes used in range analysis (In SEL_TREE::keys only first
51
#keys elements are not empty)
56
If true, the index descriptions describe real indexes (and it is ok to
57
call field->optimize_range(real_keynr[...], ...).
58
Otherwise index description describes fake indexes.
60
bool using_real_indexes;
62
bool remove_jump_scans;
65
used_key_no -> table_key_no translation table. Only makes sense if
66
using_real_indexes==true
68
uint32_t real_keynr[MAX_KEY];
69
/* Number of SEL_ARG objects allocated by optimizer::SEL_ARG::clone_tree operations */
70
uint32_t alloced_sel_args;
71
bool force_default_mrr;
74
class PARAM : public RANGE_OPT_PARAM
77
KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */
78
uint32_t max_key_part;
79
/* Number of ranges in the last checked tree->key */
81
unsigned char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH],
82
max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
83
bool quick; // Don't calulate possible keys
85
uint32_t fields_bitmap_size;
86
MyBitmap needed_fields; /* bitmask of fields needed by the query */
87
MyBitmap tmp_covered_fields;
89
key_map *needed_reg; /* ptr to SqlSelect::needed_reg */
91
uint32_t *imerge_cost_buff; /* buffer for index_merge cost estimates */
92
uint32_t imerge_cost_buff_size; /* size of the buffer */
94
/* true if last checked tree->key can be used for ROR-scan */
96
/* Number of ranges in the last checked tree->key */
100
} /* namespace optimizer */
102
} /* namespace drizzled */
104
#endif /* DRIZZLE_OPTIMIZER_RANGE_PARAM_H */