~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/range_param.h

Big merge.

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
typedef class Item COND;
 
26
typedef struct st_key_part KEY_PART;
 
27
 
 
28
namespace drizzled
 
29
{
 
30
 
 
31
namespace optimizer
 
32
{
 
33
 
 
34
class RangeParameter
 
35
{
 
36
public:
 
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 */
 
43
 
 
44
  /* Array of parts of all keys for which range analysis is performed */
 
45
  KEY_PART *key_parts;
 
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 */
 
49
  /*
 
50
    Number of indexes used in range analysis (In SEL_TREE::keys only first
 
51
    #keys elements are not empty)
 
52
  */
 
53
  uint32_t keys;
 
54
 
 
55
  /*
 
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.
 
59
  */
 
60
  bool using_real_indexes;
 
61
 
 
62
  bool remove_jump_scans;
 
63
 
 
64
  /*
 
65
    used_key_no -> table_key_no translation table. Only makes sense if
 
66
    using_real_indexes==true
 
67
  */
 
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;
 
72
};
 
73
 
 
74
class Parameter : public RangeParameter
 
75
{
 
76
public:
 
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 */
 
80
  uint32_t range_count;
 
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
 
84
 
 
85
  uint32_t fields_bitmap_size;
 
86
  MyBitmap needed_fields;    /* bitmask of fields needed by the query */
 
87
  MyBitmap tmp_covered_fields;
 
88
 
 
89
  key_map *needed_reg;        /* ptr to SqlSelect::needed_reg */
 
90
 
 
91
  uint32_t *imerge_cost_buff;     /* buffer for index_merge cost estimates */
 
92
  uint32_t imerge_cost_buff_size; /* size of the buffer */
 
93
 
 
94
  /* true if last checked tree->key can be used for ROR-scan */
 
95
  bool is_ror_scan;
 
96
  /* Number of ranges in the last checked tree->key */
 
97
  uint32_t n_ranges;
 
98
};
 
99
 
 
100
} /* namespace optimizer */
 
101
 
 
102
} /* namespace drizzled */
 
103
 
 
104
#endif /* DRIZZLED_OPTIMIZER_RANGE_PARAM_H */