00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #pragma once
00029
00030 #include <drizzled/enum_nested_loop_state.h>
00031 #include <drizzled/table_reference.h>
00032 #include <drizzled/optimizer/range.h>
00033 #include <drizzled/join_cache.h>
00034 #include <drizzled/optimizer/key_use.h>
00035
00036 #include <drizzled/records.h>
00037
00038 #include <bitset>
00039
00040 namespace drizzled
00041 {
00042
00043 class Table;
00044
00045 namespace optimizer
00046 {
00047 class Position;
00048 }
00049
00050 #define TAB_INFO_HAVE_VALUE 1
00051 #define TAB_INFO_USING_INDEX 2
00052 #define TAB_INFO_USING_WHERE 4
00053 #define TAB_INFO_FULL_SCAN_ON_NULL 8
00054
00056 enum access_method
00057 {
00058 AM_UNKNOWN,
00059 AM_SYSTEM,
00060 AM_CONST,
00061 AM_EQ_REF,
00062 AM_REF,
00063 AM_MAYBE_REF,
00064 AM_ALL,
00065 AM_RANGE,
00066 AM_NEXT,
00067 AM_REF_OR_NULL,
00068 AM_UNIQUE_SUBQUERY,
00069 AM_INDEX_SUBQUERY,
00070 AM_INDEX_MERGE
00071 };
00072
00073
00074 class JoinTable
00075 {
00076 public:
00077 JoinTable() :
00078 table(NULL),
00079 keyuse(NULL),
00080 select(NULL),
00081 select_cond(NULL),
00082 quick(NULL),
00083 pre_idx_push_select_cond(NULL),
00084 on_expr_ref(NULL),
00085 cond_equal(NULL),
00086 first_inner(NULL),
00087 found(false),
00088 not_null_compl(false),
00089 last_inner(NULL),
00090 first_upper(NULL),
00091 first_unmatched(NULL),
00092 packed_info(0),
00093 read_first_record(NULL),
00094 next_select(NULL),
00095 worst_seeks(0.0),
00096 const_keys(0),
00097 checked_keys(0),
00098 needed_reg(0),
00099 keys(0),
00100 records(0),
00101 found_records(0),
00102 read_time(0),
00103 dependent(0),
00104 key_dependent(0),
00105 use_quick(0),
00106 index(0),
00107 status(0),
00108 used_fields(0),
00109 used_fieldlength(0),
00110 used_blobs(0),
00111 type(AM_UNKNOWN),
00112 cached_eq_ref_table(0),
00113 eq_ref_table(0),
00114 not_used_in_distinct(0),
00115 sorted(0),
00116 limit(0),
00117 join(NULL),
00118 insideout_match_tab(NULL),
00119 insideout_buf(NULL),
00120 found_match(false),
00121 rowid_keep_flags(0),
00122 embedding_map(0)
00123 {}
00124 Table *table;
00125 optimizer::KeyUse *keyuse;
00126 optimizer::SqlSelect *select;
00127 COND *select_cond;
00128 optimizer::QuickSelectInterface *quick;
00136 Item *pre_idx_push_select_cond;
00137 Item **on_expr_ref;
00138 COND_EQUAL *cond_equal;
00139 JoinTable *first_inner;
00140 bool found;
00141 bool not_null_compl;
00142 JoinTable *last_inner;
00143 JoinTable *first_upper;
00144 JoinTable *first_unmatched;
00146
00147 const char *info;
00148
00149
00150
00151
00152 uint32_t packed_info;
00153
00154 Read_record_func read_first_record;
00155 Next_select_func next_select;
00156 ReadRecord read_record;
00157
00158
00159
00160
00161
00162 Read_record_func save_read_first_record;
00163 int (*save_read_record) (ReadRecord *);
00164 double worst_seeks;
00165 key_map const_keys;
00166 key_map checked_keys;
00167 key_map needed_reg;
00168 key_map keys;
00171 ha_rows records;
00176 ha_rows found_records;
00182 ha_rows read_time;
00183
00184 table_map dependent;
00185 table_map key_dependent;
00186 uint32_t use_quick;
00187 uint32_t index;
00188 uint32_t status;
00189 uint32_t used_fields;
00190 uint32_t used_fieldlength;
00191 uint32_t used_blobs;
00192 enum access_method type;
00193 bool cached_eq_ref_table;
00194 bool eq_ref_table;
00195 bool not_used_in_distinct;
00197 bool sorted;
00203 ha_rows limit;
00204 table_reference_st ref;
00205 JoinCache cache;
00206 Join *join;
00207
00214 JoinTable *insideout_match_tab;
00215 unsigned char *insideout_buf;
00218 bool found_match;
00219
00220 enum
00221 {
00222
00223 KEEP_ROWID=1,
00224
00225
00226
00227
00228
00229
00230 CALL_POSITION=2
00231 };
00233 int rowid_keep_flags;
00234
00236 std::bitset<64> embedding_map;
00237
00238 void cleanup();
00239
00240 inline bool is_using_loose_index_scan()
00241 {
00242 return (select && select->quick &&
00243 (select->quick->get_type() ==
00244 optimizer::QuickSelectInterface::QS_TYPE_GROUP_MIN_MAX));
00245 }
00246
00247 void readCachedRecord();
00248 int joinReadConstTable(optimizer::Position *pos);
00249 int joinReadSystem();
00250 };
00251
00252 }
00253