133
134
static bool add_ref_to_table_cond(Session *session, JoinTable *join_tab);
134
135
static void free_blobs(Field **ptr); /* Rename this method...conflicts with another in global namespace... */
137
Join::Join(Session *session_arg,
138
List<Item> &fields_arg,
139
uint64_t select_options_arg,
140
select_result *result_arg) :
152
sort_and_group(false),
156
no_field_update(false),
158
resume_nested_loop(false),
159
no_const_tables(false),
160
select_distinct(false),
161
group_optimized_away(false),
165
skip_sort_order(false),
169
hidden_group_fields(false),
171
found_const_table_map(0),
178
fetch_limit(HA_POS_ERROR),
179
session(session_arg),
180
fields_list(fields_arg),
185
exec_tmp_table1(NULL),
186
exec_tmp_table2(NULL),
191
having_history(NULL),
192
select_options(select_options_arg),
194
lock(session_arg->lock),
196
all_fields(fields_arg),
200
ref_pointer_array(NULL),
205
ref_pointer_array_size(0),
206
zero_result_cause(NULL),
209
join_tab_reexec(NULL)
211
select_distinct= test(select_options & SELECT_DISTINCT);
212
if (&fields_list != &fields_arg) /* only copy if not same*/
213
fields_list= fields_arg;
214
memset(&keyuse, 0, sizeof(keyuse));
215
tmp_table_param.init();
216
tmp_table_param.end_write_records= HA_POS_ERROR;
217
rollup.setState(Rollup::STATE_NONE);
221
* This method is currently only used when a subselect EXPLAIN is performed.
222
* I pulled out the init() method and have simply reset the values to what
223
* was previously in the init() method. See the note about the hack in
226
void Join::reset(Session *session_arg,
227
List<Item> &fields_arg,
228
uint64_t select_options_arg,
229
select_result *result_arg)
242
sort_and_group= false;
246
no_field_update= false;
248
resume_nested_loop= false;
249
no_const_tables= false;
250
select_distinct= false;
251
group_optimized_away= false;
255
skip_sort_order= false;
259
hidden_group_fields= false;
261
found_const_table_map= 0;
268
fetch_limit= HA_POS_ERROR;
269
session= session_arg;
270
fields_list= fields_arg;
275
exec_tmp_table1= NULL;
276
exec_tmp_table2= NULL;
281
having_history= NULL;
282
select_options= select_options_arg;
284
lock= session_arg->lock;
286
all_fields= fields_arg;
290
ref_pointer_array= NULL;
295
ref_pointer_array_size= 0;
296
zero_result_cause= NULL;
299
join_tab_reexec= NULL;
300
select_distinct= test(select_options & SELECT_DISTINCT);
301
if (&fields_list != &fields_arg) /* only copy if not same*/
302
fields_list= fields_arg;
303
memset(&keyuse, 0, sizeof(keyuse));
304
tmp_table_param.init();
305
tmp_table_param.end_write_records= HA_POS_ERROR;
306
rollup.setState(Rollup::STATE_NONE);
309
bool Join::is_top_level_join() const
311
return (unit == &session->lex->unit && (unit->fake_select_lex == 0 ||
312
select_lex == unit->fake_select_lex));
137
316
Prepare of whole select (including sub queries in future).
4797
4976
current_map, 0)))
4799
4978
tab->cache.select= (optimizer::SqlSelect*)
4800
session->memdup((unsigned char*) sel, sizeof(optimizer::SqlSelect));
4979
session->getMemRoot()->duplicate((unsigned char*) sel, sizeof(optimizer::SqlSelect));
4801
4980
tab->cache.select->cond= tmp;
4802
4981
tab->cache.select->read_tables= join->const_table_map;
5525
5704
table_count= join->tables;
5526
5705
stat= (JoinTable*) join->session->calloc(sizeof(JoinTable)*table_count);
5527
stat_ref= (JoinTable**) join->session->alloc(sizeof(JoinTable*)*MAX_TABLES);
5528
table_vector= (Table**) join->session->alloc(sizeof(Table*)*(table_count*2));
5706
stat_ref= (JoinTable**) join->session->getMemRoot()->allocate(sizeof(JoinTable*)*MAX_TABLES);
5707
table_vector= (Table**) join->session->getMemRoot()->allocate(sizeof(Table*)*(table_count*2));
5529
5708
if (! stat || ! stat_ref || ! table_vector)