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 #define TAB_INFO_HAVE_VALUE 1
00044 #define TAB_INFO_USING_INDEX 2
00045 #define TAB_INFO_USING_WHERE 4
00046 #define TAB_INFO_FULL_SCAN_ON_NULL 8
00047
00049 enum access_method
00050 {
00051 AM_UNKNOWN,
00052 AM_SYSTEM,
00053 AM_CONST,
00054 AM_EQ_REF,
00055 AM_REF,
00056 AM_MAYBE_REF,
00057 AM_ALL,
00058 AM_RANGE,
00059 AM_NEXT,
00060 AM_REF_OR_NULL,
00061 AM_UNIQUE_SUBQUERY,
00062 AM_INDEX_SUBQUERY,
00063 AM_INDEX_MERGE
00064 };
00065
00066
00067 class JoinTable
00068 {
00069 public:
00070 JoinTable() :
00071 table(NULL),
00072 keyuse(NULL),
00073 select(NULL),
00074 select_cond(NULL),
00075 quick(NULL),
00076 pre_idx_push_select_cond(NULL),
00077 on_expr_ref(NULL),
00078 cond_equal(NULL),
00079 first_inner(NULL),
00080 found(false),
00081 not_null_compl(false),
00082 last_inner(NULL),
00083 first_upper(NULL),
00084 first_unmatched(NULL),
00085 packed_info(0),
00086 read_first_record(NULL),
00087 next_select(NULL),
00088 worst_seeks(0.0),
00089 const_keys(0),
00090 checked_keys(0),
00091 needed_reg(0),
00092 keys(0),
00093 records(0),
00094 found_records(0),
00095 read_time(0),
00096 dependent(0),
00097 key_dependent(0),
00098 use_quick(0),
00099 index(0),
00100 status(0),
00101 used_fields(0),
00102 used_fieldlength(0),
00103 used_blobs(0),
00104 type(AM_UNKNOWN),
00105 cached_eq_ref_table(0),
00106 eq_ref_table(0),
00107 not_used_in_distinct(0),
00108 sorted(0),
00109 limit(0),
00110 join(NULL),
00111 insideout_match_tab(NULL),
00112 insideout_buf(NULL),
00113 found_match(false),
00114 rowid_keep_flags(0),
00115 embedding_map(0)
00116 {}
00117 Table *table;
00118 optimizer::KeyUse *keyuse;
00119 optimizer::SqlSelect *select;
00120 COND *select_cond;
00121 optimizer::QuickSelectInterface *quick;
00129 Item *pre_idx_push_select_cond;
00130 Item **on_expr_ref;
00131 COND_EQUAL *cond_equal;
00132 JoinTable *first_inner;
00133 bool found;
00134 bool not_null_compl;
00135 JoinTable *last_inner;
00136 JoinTable *first_upper;
00137 JoinTable *first_unmatched;
00139
00140 const char *info;
00141
00142
00143
00144
00145 uint32_t packed_info;
00146
00147 Read_record_func read_first_record;
00148 Next_select_func next_select;
00149 ReadRecord read_record;
00150
00151
00152
00153
00154
00155 Read_record_func save_read_first_record;
00156 int (*save_read_record) (ReadRecord *);
00157 double worst_seeks;
00158 key_map const_keys;
00159 key_map checked_keys;
00160 key_map needed_reg;
00161 key_map keys;
00164 ha_rows records;
00169 ha_rows found_records;
00175 ha_rows read_time;
00176
00177 table_map dependent;
00178 table_map key_dependent;
00179 uint32_t use_quick;
00180 uint32_t index;
00181 uint32_t status;
00182 uint32_t used_fields;
00183 uint32_t used_fieldlength;
00184 uint32_t used_blobs;
00185 enum access_method type;
00186 bool cached_eq_ref_table;
00187 bool eq_ref_table;
00188 bool not_used_in_distinct;
00190 bool sorted;
00196 ha_rows limit;
00197 table_reference_st ref;
00198 JoinCache cache;
00199 Join *join;
00200
00207 JoinTable *insideout_match_tab;
00208 unsigned char *insideout_buf;
00211 bool found_match;
00212
00213 enum
00214 {
00215
00216 KEEP_ROWID=1,
00217
00218
00219
00220
00221
00222
00223 CALL_POSITION=2
00224 };
00226 int rowid_keep_flags;
00227
00229 std::bitset<64> embedding_map;
00230
00231 void cleanup();
00232
00233 inline bool is_using_loose_index_scan()
00234 {
00235 return (select && select->quick &&
00236 (select->quick->get_type() ==
00237 optimizer::QuickSelectInterface::QS_TYPE_GROUP_MIN_MAX));
00238 }
00239
00240 void readCachedRecord();
00241 int joinReadConstTable(optimizer::Position *pos);
00242 int joinReadSystem();
00243 };
00244
00245 int join_read_system(JoinTable *tab);
00246
00247 }
00248