~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.h

  • Committer: Brian Aker
  • Date: 2011-02-12 10:06:03 UTC
  • mfrom: (2154.2.16 drizzle-build)
  • Revision ID: brian@tangent.org-20110212100603-i5ww0s02p8l4a8q7
Merge in solaris tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#define DRIZZLED_JOIN_H
29
29
 
30
30
#include <drizzled/optimizer/position.h>
31
 
#include "drizzled/sql_select.h"
 
31
#include <drizzled/session.h>
 
32
#include <drizzled/sql_select.h>
32
33
#include <bitset>
33
34
 
34
35
namespace drizzled
35
36
{
36
37
 
 
38
class Session;
 
39
 
37
40
class Join :public memory::SqlAlloc
38
41
{
39
42
  Join(const Join &rhs);                        /**< not implemented */
228
231
  Join(Session *session_arg, 
229
232
       List<Item> &fields_arg, 
230
233
       uint64_t select_options_arg,
231
 
       select_result *result_arg)
232
 
    :
233
 
      join_tab(NULL),
234
 
      best_ref(NULL),
235
 
      map2table(NULL),
236
 
      join_tab_save(NULL),
237
 
      table(NULL),
238
 
      all_tables(NULL),
239
 
      sort_by_table(NULL),
240
 
      tables(0),
241
 
      outer_tables(0),
242
 
      const_tables(0),
243
 
      send_group_parts(0),
244
 
      sort_and_group(false),
245
 
      first_record(false),
246
 
      full_join(false),
247
 
      group(false),
248
 
      no_field_update(false),
249
 
      do_send_rows(true),
250
 
      resume_nested_loop(false),
251
 
      no_const_tables(false),
252
 
      select_distinct(false),
253
 
      group_optimized_away(false),
254
 
      simple_order(false),
255
 
      simple_group(false),
256
 
      no_order(false),
257
 
      skip_sort_order(false),
258
 
      union_part(false),
259
 
      optimized(false),
260
 
      need_tmp(false),
261
 
      hidden_group_fields(false),
262
 
      const_table_map(0),
263
 
      found_const_table_map(0),
264
 
      outer_join(0),
265
 
      send_records(0),
266
 
      found_records(0),
267
 
      examined_rows(0),
268
 
      row_limit(0),
269
 
      select_limit(0),
270
 
      fetch_limit(HA_POS_ERROR),
271
 
      session(session_arg),
272
 
      fields_list(fields_arg), 
273
 
      join_list(NULL),
274
 
      unit(NULL),
275
 
      select_lex(NULL),
276
 
      select(NULL),
277
 
      exec_tmp_table1(NULL),
278
 
      exec_tmp_table2(NULL),
279
 
      sum_funcs(NULL),
280
 
      sum_funcs2(NULL),
281
 
      having(NULL),
282
 
      tmp_having(NULL),
283
 
      having_history(NULL),
284
 
      select_options(select_options_arg),
285
 
      result(result_arg),
286
 
      lock(session_arg->lock),
287
 
      tmp_join(NULL),
288
 
      all_fields(fields_arg),
289
 
      error(0),
290
 
      cond_equal(NULL),
291
 
      return_tab(NULL),
292
 
      ref_pointer_array(NULL),
293
 
      items0(NULL),
294
 
      items1(NULL),
295
 
      items2(NULL),
296
 
      items3(NULL),
297
 
      ref_pointer_array_size(0),
298
 
      zero_result_cause(NULL),
299
 
      sortorder(NULL),
300
 
      table_reexec(NULL),
301
 
      join_tab_reexec(NULL)
302
 
  {
303
 
    select_distinct= test(select_options & SELECT_DISTINCT);
304
 
    if (&fields_list != &fields_arg) /* only copy if not same*/
305
 
      fields_list= fields_arg;
306
 
    memset(&keyuse, 0, sizeof(keyuse));
307
 
    tmp_table_param.init();
308
 
    tmp_table_param.end_write_records= HA_POS_ERROR;
309
 
    rollup.setState(Rollup::STATE_NONE);
310
 
  }
 
234
       select_result *result_arg);
311
235
 
312
236
  /** 
313
237
   * This method is currently only used when a subselect EXPLAIN is performed.
315
239
   * was previously in the init() method.  See the note about the hack in 
316
240
   * sql_union.cc...
317
241
   */
318
 
  inline void reset(Session *session_arg, 
319
 
       List<Item> &fields_arg, 
320
 
       uint64_t select_options_arg,
321
 
       select_result *result_arg)
322
 
  {
323
 
    join_tab= NULL;
324
 
    best_ref= NULL;
325
 
    map2table= NULL;
326
 
    join_tab_save= NULL;
327
 
    table= NULL;
328
 
    all_tables= NULL;
329
 
    sort_by_table= NULL;
330
 
    tables= 0;
331
 
    outer_tables= 0;
332
 
    const_tables= 0;
333
 
    send_group_parts= 0;
334
 
    sort_and_group= false;
335
 
    first_record= false;
336
 
    full_join= false;
337
 
    group= false;
338
 
    no_field_update= false;
339
 
    do_send_rows= true;
340
 
    resume_nested_loop= false;
341
 
    no_const_tables= false;
342
 
    select_distinct= false;
343
 
    group_optimized_away= false;
344
 
    simple_order= false;
345
 
    simple_group= false;
346
 
    no_order= false;
347
 
    skip_sort_order= false;
348
 
    union_part= false;
349
 
    optimized= false;
350
 
    need_tmp= false;
351
 
    hidden_group_fields= false;
352
 
    const_table_map= 0;
353
 
    found_const_table_map= 0;
354
 
    outer_join= 0;
355
 
    send_records= 0;
356
 
    found_records= 0;
357
 
    examined_rows= 0;
358
 
    row_limit= 0;
359
 
    select_limit= 0;
360
 
    fetch_limit= HA_POS_ERROR;
361
 
    session= session_arg;
362
 
    fields_list= fields_arg; 
363
 
    join_list= NULL;
364
 
    unit= NULL;
365
 
    select_lex= NULL;
366
 
    select= NULL;
367
 
    exec_tmp_table1= NULL;
368
 
    exec_tmp_table2= NULL;
369
 
    sum_funcs= NULL;
370
 
    sum_funcs2= NULL;
371
 
    having= NULL;
372
 
    tmp_having= NULL;
373
 
    having_history= NULL;
374
 
    select_options= select_options_arg;
375
 
    result= result_arg;
376
 
    lock= session_arg->lock;
377
 
    tmp_join= NULL;
378
 
    all_fields= fields_arg;
379
 
    error= 0;
380
 
    cond_equal= NULL;
381
 
    return_tab= NULL;
382
 
    ref_pointer_array= NULL;
383
 
    items0= NULL;
384
 
    items1= NULL;
385
 
    items2= NULL;
386
 
    items3= NULL;
387
 
    ref_pointer_array_size= 0;
388
 
    zero_result_cause= NULL;
389
 
    sortorder= NULL;
390
 
    table_reexec= NULL;
391
 
    join_tab_reexec= NULL;
392
 
    select_distinct= test(select_options & SELECT_DISTINCT);
393
 
    if (&fields_list != &fields_arg) /* only copy if not same*/
394
 
      fields_list= fields_arg;
395
 
    memset(&keyuse, 0, sizeof(keyuse));
396
 
    tmp_table_param.init();
397
 
    tmp_table_param.end_write_records= HA_POS_ERROR;
398
 
    rollup.setState(Rollup::STATE_NONE);
399
 
  }
 
242
  void reset(Session *session_arg, 
 
243
             List<Item> &fields_arg, 
 
244
             uint64_t select_options_arg,
 
245
             select_result *result_arg);
400
246
 
401
247
  int prepare(Item ***rref_pointer_array, 
402
248
              TableList *tables,
408
254
              Item *having,
409
255
              Select_Lex *select,
410
256
              Select_Lex_Unit *unit);
 
257
 
411
258
  int optimize();
412
259
  int reinit();
413
260
  void exec();
457
304
            !group_list);
458
305
  }
459
306
  bool change_result(select_result *result);
460
 
  bool is_top_level_join() const
461
 
  {
462
 
    return (unit == &session->lex->unit && (unit->fake_select_lex == 0 ||
463
 
                                        select_lex == unit->fake_select_lex));
464
 
  }
 
307
  bool is_top_level_join() const;
465
308
 
466
309
  /**
467
310
   * Copy the partial query plan into the optimal query plan.