drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
join_table.h
Go to the documentation of this file.
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, Inc.
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; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
27
28#pragma once
29
30#include <drizzled/enum_nested_loop_state.h>
32#include <drizzled/optimizer/range.h>
33#include <drizzled/join_cache.h>
34#include <drizzled/optimizer/key_use.h>
35
36#include <drizzled/records.h>
37
38#include <bitset>
39
40namespace drizzled {
41
42/* Values for JoinTable::packed_info */
43#define TAB_INFO_HAVE_VALUE 1
44#define TAB_INFO_USING_INDEX 2
45#define TAB_INFO_USING_WHERE 4
46#define TAB_INFO_FULL_SCAN_ON_NULL 8
47
50{
51 AM_UNKNOWN,
52 AM_SYSTEM,
53 AM_CONST,
54 AM_EQ_REF,
55 AM_REF,
56 AM_MAYBE_REF,
57 AM_ALL,
58 AM_RANGE,
59 AM_NEXT,
60 AM_REF_OR_NULL,
61 AM_UNIQUE_SUBQUERY,
62 AM_INDEX_SUBQUERY,
63 AM_INDEX_MERGE
64};
65
66
67class JoinTable
68{
69public:
70 JoinTable() :
71 table(NULL),
72 keyuse(NULL),
73 select(NULL),
74 select_cond(NULL),
75 quick(NULL),
77 on_expr_ref(NULL),
78 cond_equal(NULL),
79 first_inner(NULL),
80 found(false),
81 not_null_compl(false),
82 last_inner(NULL),
83 first_upper(NULL),
84 first_unmatched(NULL),
85 packed_info(0),
86 read_first_record(NULL),
87 next_select(NULL),
88 worst_seeks(0.0),
89 const_keys(0),
90 checked_keys(0),
91 needed_reg(0),
92 keys(0),
93 records(0),
95 read_time(0),
96 dependent(0),
97 key_dependent(0),
98 use_quick(0),
99 index(0),
100 status(0),
101 used_fields(0),
103 used_blobs(0),
104 type(AM_UNKNOWN),
105 cached_eq_ref_table(0),
106 eq_ref_table(0),
107 not_used_in_distinct(0),
108 sorted(0),
109 limit(0),
110 join(NULL),
112 insideout_buf(NULL),
113 found_match(false),
116 {}
117 Table *table;
119 optimizer::SqlSelect *select;
120 COND *select_cond;
132 JoinTable *first_inner;
133 bool found;
135 JoinTable *last_inner;
136 JoinTable *first_upper;
137 JoinTable *first_unmatched;
138
139 /* Special content for EXPLAIN 'Extra' column or NULL if none */
140 const char *info;
141 /*
142 Bitmap of TAB_INFO_* bits that encodes special line for EXPLAIN 'Extra'
143 column, or 0 if there is no info.
144 */
145 uint32_t packed_info;
146
147 Read_record_func read_first_record;
148 Next_select_func next_select;
149 ReadRecord read_record;
150 /*
151 Currently the following two fields are used only for a [NOT] IN subquery
152 if it is executed by an alternative full table scan when the left operand of
153 the subquery predicate is evaluated to NULL.
154 */
155 Read_record_func save_read_first_record;
157 double worst_seeks;
158 key_map const_keys;
159 key_map checked_keys;
160 key_map needed_reg;
161 key_map keys;
162
164 ha_rows records;
175 ha_rows read_time;
176
177 table_map dependent;
178 table_map key_dependent;
179 uint32_t use_quick;
180 uint32_t index;
181 uint32_t status;
182 uint32_t used_fields;
184 uint32_t used_blobs;
186 bool cached_eq_ref_table;
187 bool eq_ref_table;
188 bool not_used_in_distinct;
190 bool sorted;
196 ha_rows limit;
198 JoinCache cache;
199 Join *join;
200
208 unsigned char *insideout_buf;
209
212
213 enum
214 {
215 /* If set, the rowid of this table must be put into the temptable. */
216 KEEP_ROWID=1,
217 /*
218 If set, one should call h->position() to obtain the rowid,
219 otherwise, the rowid is assumed to already be in h->ref
220 (this is because join caching and filesort() save the rowid and then
221 put it back into h->ref)
222 */
223 CALL_POSITION=2
224 };
227
229 std::bitset<64> embedding_map;
230
231 void cleanup();
232
233 inline bool is_using_loose_index_scan()
234 {
235 return (select && select->quick &&
236 (select->quick->get_type() ==
237 optimizer::QuickSelectInterface::QS_TYPE_GROUP_MIN_MAX));
238 }
239
240 void readCachedRecord();
241 int joinReadConstTable(optimizer::Position *pos);
242 int joinReadSystem();
243};
244
245int join_read_system(JoinTable *tab);
246
247} /* namespace drizzled */
248
JoinTable * first_unmatched
Definition join_table.h:137
uint32_t used_fieldlength
Definition join_table.h:183
COND_EQUAL * cond_equal
Definition join_table.h:131
Read_record_func save_read_first_record
Definition join_table.h:155
enum access_method type
Definition join_table.h:185
JoinTable * first_upper
Definition join_table.h:136
Item * pre_idx_push_select_cond
Definition join_table.h:129
int(* save_read_record)(ReadRecord *)
Definition join_table.h:156
unsigned char * insideout_buf
Definition join_table.h:208
JoinTable * insideout_match_tab
Definition join_table.h:207
JoinTable * first_inner
Definition join_table.h:132
std::bitset< 64 > embedding_map
Definition join_table.h:229
JoinTable * last_inner
Definition join_table.h:135
optimizer::KeyUse * keyuse
Definition join_table.h:118
TODO: Rename this file - func.h is stupid.