1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
4
* Copyright (C) 2008-2009 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
24
* Defines the JoinTable class which is the primary class
24
* Defines the JOIN_TAB class which is the primary class
25
25
* used in the nested loops join implementation.
28
#ifndef DRIZZLED_JOIN_TABLE_H
29
#define DRIZZLED_JOIN_TABLE_H
31
#include "drizzled/enum_nested_loop_state.h"
32
#include "drizzled/table_reference.h"
33
#include "drizzled/optimizer/range.h"
34
#include "drizzled/join_cache.h"
35
#include "drizzled/optimizer/key_use.h"
37
#include "drizzled/records.h"
50
/* Values for JoinTable::packed_info */
28
#ifndef DRIZZLED_JOIN_TAB_H
29
#define DRIZZLED_JOIN_TAB_H
31
/* Values for JOIN_TAB::packed_info */
51
32
#define TAB_INFO_HAVE_VALUE 1
52
33
#define TAB_INFO_USING_INDEX 2
53
34
#define TAB_INFO_USING_WHERE 4
54
35
#define TAB_INFO_FULL_SCAN_ON_NULL 8
56
/** Description of an access method */
37
typedef struct st_join_table
84
pre_idx_push_select_cond(NULL),
89
not_null_compl(false),
92
first_unmatched(NULL),
94
read_first_record(NULL),
113
cached_eq_ref_table(0),
115
not_used_in_distinct(0),
119
insideout_match_tab(NULL),
39
st_join_table() {} /* Remove gcc warning */
126
optimizer::KeyUse *keyuse; /**< pointer to first used key */
127
optimizer::SqlSelect *select;
41
KEYUSE *keyuse; /**< pointer to first used key */
128
43
COND *select_cond;
129
optimizer::QuickSelectInterface *quick;
44
QUICK_SELECT_I *quick;
131
46
The value of select_cond before we've attempted to do Index Condition
132
47
Pushdown. We may need to restore everything back if we first choose one
137
52
Item *pre_idx_push_select_cond;
138
53
Item **on_expr_ref; /**< pointer to the associated on expression */
139
54
COND_EQUAL *cond_equal; /**< multiple equalities for the on expression */
140
JoinTable *first_inner; /**< first inner table for including outerjoin */
55
st_join_table *first_inner; /**< first inner table for including outerjoin */
141
56
bool found; /**< true after all matches or null complement */
142
57
bool not_null_compl;/**< true before null complement is added */
143
JoinTable *last_inner; /**< last table table for embedding outer join */
144
JoinTable *first_upper; /**< first inner table for embedding outer join */
145
JoinTable *first_unmatched; /**< used for optimization purposes only */
58
st_join_table *last_inner; /**< last table table for embedding outer join */
59
st_join_table *first_upper; /**< first inner table for embedding outer join */
60
st_join_table *first_unmatched; /**< used for optimization purposes only */
147
62
/* Special content for EXPLAIN 'Extra' column or NULL if none */
155
70
Read_record_func read_first_record;
156
71
Next_select_func next_select;
157
ReadRecord read_record;
72
READ_RECORD read_record;
159
74
Currently the following two fields are used only for a [NOT] IN subquery
160
75
if it is executed by an alternative full table scan when the left operand of
161
76
the subquery predicate is evaluated to NULL.
163
78
Read_record_func save_read_first_record; /**< to save read_first_record */
164
int (*save_read_record) (ReadRecord *); /**< to save read_record.read_record */
79
int (*save_read_record) (READ_RECORD *); /**< to save read_record.read_record */
165
80
double worst_seeks;
166
81
key_map const_keys; /**< Keys with constant part */
167
82
key_map checked_keys; /**< Keys checked in find_best */
190
105
uint32_t used_fields; /**< Number of used fields in join set */
191
106
uint32_t used_fieldlength; /**< Not sure... */
192
107
uint32_t used_blobs; /**< Number of BLOB fields in join set */
193
enum access_method type; /**< Access method. */
108
enum join_type type; /**< Access pattern or join type... */
194
109
bool cached_eq_ref_table;
195
110
bool eq_ref_table;
196
111
bool not_used_in_distinct;
202
117
this number of rows for the table.
205
table_reference_st ref;
125
Embedding SJ-nest (may be not the direct parent), or NULL if none.
126
This variable holds the result of table pullout.
128
TableList *emb_sj_nest;
130
/** Variables for semi-join duplicate elimination */
131
SJ_TMP_TABLE *flush_weedout_table;
132
SJ_TMP_TABLE *check_weed_out_table;
133
struct st_join_table *do_firstmatch;
210
136
ptr - this join tab should do an InsideOut scan. Points
213
139
NULL - Not an insideout scan.
215
JoinTable *insideout_match_tab;
141
struct st_join_table *insideout_match_tab;
216
142
unsigned char *insideout_buf; /**< Buffer to save index tuple to be able to skip dups */
218
144
/** Used by InsideOut scan. Just set to true when have found a row. */
234
160
int rowid_keep_flags;
236
162
/** Bitmap of nested joins this table is part of */
237
std::bitset<64> embedding_map;
163
nested_join_map embedding_map;
241
166
inline bool is_using_loose_index_scan()
243
168
return (select && select->quick &&
244
169
(select->quick->get_type() ==
245
optimizer::QuickSelectInterface::QS_TYPE_GROUP_MIN_MAX));
170
QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX));
248
void readCachedRecord();
249
int joinReadConstTable(optimizer::Position *pos);
250
int joinReadSystem();
253
} /* namespace drizzled */
255
#endif /* DRIZZLED_JOIN_TABLE_H */
174
#endif /* DRIZZLED_JOIN_TAB_H */