~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_union.cc

code clean move Item_func_abs, Item_func_int_exp, Item_func_ln, Item_func_log to functions directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
  UNION  of select's
18
18
  UNION's  were introduced by Monty and Sinisa <sinisa@mysql.com>
19
19
*/
20
 
#include "config.h"
 
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/sql_select.h>
22
 
#include <drizzled/error.h>
23
 
#include <drizzled/item/type_holder.h>
24
 
#include <drizzled/sql_base.h>
25
 
#include <drizzled/sql_union.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
bool drizzle_union(Session *session, LEX *, select_result *result,
31
 
                   Select_Lex_Unit *unit, uint64_t setup_tables_done_option)
 
22
#include <drizzled/drizzled_error_messages.h>
 
23
 
 
24
bool mysql_union(THD *thd,
 
25
                 LEX *lex __attribute__((unused)),
 
26
                 select_result *result,
 
27
                 SELECT_LEX_UNIT *unit, ulong setup_tables_done_option)
32
28
{
33
29
  bool res;
34
 
  if (!(res= unit->prepare(session, result, SELECT_NO_UNLOCK |
 
30
  if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK |
35
31
                           setup_tables_done_option)))
36
32
    res= unit->exec();
37
33
  if (res)
44
40
** store records in temporary table for UNION
45
41
***************************************************************************/
46
42
 
47
 
int select_union::prepare(List<Item> &, Select_Lex_Unit *u)
 
43
int select_union::prepare(List<Item> &list __attribute__((unused)),
 
44
                          SELECT_LEX_UNIT *u)
48
45
{
49
46
  unit= u;
50
47
  return 0;
59
56
    unit->offset_limit_cnt--;
60
57
    return 0;
61
58
  }
62
 
  fill_record(session, table->field, values, true);
63
 
  if (session->is_error())
 
59
  fill_record(thd, table->field, values, 1);
 
60
  if (thd->is_error())
64
61
    return 1;
65
62
 
66
 
  if ((error= table->cursor->ha_write_row(table->record[0])))
 
63
  if ((error= table->file->ha_write_row(table->record[0])))
67
64
  {
68
65
    /* create_myisam_from_heap will generate error if needed */
69
 
    if (table->cursor->is_fatal_error(error, HA_CHECK_DUP) &&
70
 
        create_myisam_from_heap(session, table, tmp_table_param.start_recinfo,
 
66
    if (table->file->is_fatal_error(error, HA_CHECK_DUP) &&
 
67
        create_myisam_from_heap(thd, table, tmp_table_param.start_recinfo, 
71
68
                                &tmp_table_param.recinfo, error, 1))
72
69
      return 1;
73
70
  }
84
81
bool select_union::flush()
85
82
{
86
83
  int error;
87
 
  if ((error=table->cursor->extra(HA_EXTRA_NO_CACHE)))
 
84
  if ((error=table->file->extra(HA_EXTRA_NO_CACHE)))
88
85
  {
89
 
    table->print_error(error, MYF(0));
 
86
    table->file->print_error(error, MYF(0));
90
87
    return 1;
91
88
  }
92
89
  return 0;
97
94
 
98
95
  SYNOPSIS
99
96
    select_union::create_result_table()
100
 
      session                thread handle
 
97
      thd                thread handle
101
98
      column_types       a list of items used to define columns of the
102
99
                         temporary table
103
100
      is_union_distinct  if set, the temporary table will eliminate
104
101
                         duplicates on insert
105
102
      options            create options
106
103
      table_alias        name of the temporary table
 
104
      bit_fields_as_long convert bit fields to uint64_t
107
105
 
108
106
  DESCRIPTION
109
107
    Create a temporary table that is used to store the result of a UNION,
115
113
*/
116
114
 
117
115
bool
118
 
select_union::create_result_table(Session *session_arg, List<Item> *column_types,
 
116
select_union::create_result_table(THD *thd_arg, List<Item> *column_types,
119
117
                                  bool is_union_distinct, uint64_t options,
120
 
                                  const char *table_alias)
 
118
                                  const char *table_alias,
 
119
                                  bool bit_fields_as_long)
121
120
{
122
 
  assert(table == NULL);
 
121
  assert(table == 0);
123
122
  tmp_table_param.init();
124
123
  tmp_table_param.field_count= column_types->elements;
 
124
  tmp_table_param.bit_fields_as_long= bit_fields_as_long;
125
125
 
126
 
  if (! (table= create_tmp_table(session_arg, &tmp_table_param, *column_types,
127
 
                                 (order_st*) NULL, is_union_distinct, 1,
 
126
  if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types,
 
127
                                 (order_st*) 0, is_union_distinct, 1,
128
128
                                 options, HA_POS_ERROR, (char*) table_alias)))
129
129
    return true;
130
 
  table->cursor->extra(HA_EXTRA_WRITE_CACHE);
131
 
  table->cursor->extra(HA_EXTRA_IGNORE_DUP_KEY);
 
130
  table->file->extra(HA_EXTRA_WRITE_CACHE);
 
131
  table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
132
132
  return false;
133
133
}
134
134
 
142
142
 
143
143
void select_union::cleanup()
144
144
{
145
 
  table->cursor->extra(HA_EXTRA_RESET_STATE);
146
 
  table->cursor->ha_delete_all_rows();
147
 
  table->free_io_cache();
148
 
  table->filesort_free_buffers();
 
145
  table->file->extra(HA_EXTRA_RESET_STATE);
 
146
  table->file->ha_delete_all_rows();
 
147
  free_io_cache(table);
 
148
  filesort_free_buffers(table,0);
149
149
}
150
150
 
151
151
 
153
153
  initialization procedures before fake_select_lex preparation()
154
154
 
155
155
  SYNOPSIS
156
 
    Select_Lex_Unit::init_prepare_fake_select_lex()
157
 
    session             - thread handler
 
156
    st_select_lex_unit::init_prepare_fake_select_lex()
 
157
    thd         - thread handler
158
158
 
159
159
  RETURN
160
160
    options of SELECT
161
161
*/
162
162
 
163
163
void
164
 
Select_Lex_Unit::init_prepare_fake_select_lex(Session *session_arg)
 
164
st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) 
165
165
{
166
 
  session_arg->lex->current_select= fake_select_lex;
 
166
  thd_arg->lex->current_select= fake_select_lex;
167
167
  fake_select_lex->table_list.link_in_list((unsigned char *)&result_table_list,
168
168
                                           (unsigned char **)
169
169
                                           &result_table_list.next_local);
170
 
  fake_select_lex->context.table_list=
171
 
    fake_select_lex->context.first_name_resolution_table=
 
170
  fake_select_lex->context.table_list= 
 
171
    fake_select_lex->context.first_name_resolution_table= 
172
172
    fake_select_lex->get_table_list();
173
173
 
174
174
  for (order_st *order= (order_st *) global_parameters->order_list.first;
186
186
}
187
187
 
188
188
 
189
 
bool Select_Lex_Unit::prepare(Session *session_arg, select_result *sel_result,
190
 
                              uint64_t additional_options)
 
189
bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
 
190
                                 uint32_t additional_options)
191
191
{
192
 
  Select_Lex *lex_select_save= session_arg->lex->current_select;
193
 
  Select_Lex *sl, *first_sl= first_select();
 
192
  SELECT_LEX *lex_select_save= thd_arg->lex->current_select;
 
193
  SELECT_LEX *sl, *first_sl= first_select();
194
194
  select_result *tmp_result;
195
195
  bool is_union_select;
196
196
  Table *empty_table= 0;
225
225
  }
226
226
  prepared= 1;
227
227
  saved_error= false;
228
 
 
229
 
  session_arg->lex->current_select= sl= first_sl;
 
228
  
 
229
  thd_arg->lex->current_select= sl= first_sl;
230
230
  found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS;
231
231
  is_union_select= is_union() || fake_select_lex;
232
232
 
248
248
  {
249
249
    bool can_skip_order_by;
250
250
    sl->options|=  SELECT_NO_UNLOCK;
251
 
    JOIN *join= new JOIN(session_arg, sl->item_list,
252
 
                         sl->options | session_arg->options | additional_options,
 
251
    JOIN *join= new JOIN(thd_arg, sl->item_list, 
 
252
                         sl->options | thd_arg->options | additional_options,
253
253
                         tmp_result);
254
254
    /*
255
255
      setup_tables_done_option should be set only for very first SELECT,
261
261
    if (!join)
262
262
      goto err;
263
263
 
264
 
    session_arg->lex->current_select= sl;
 
264
    thd_arg->lex->current_select= sl;
265
265
 
266
266
    can_skip_order_by= is_union_select && !(sl->braces && sl->explicit_limit);
267
267
 
273
273
                                sl->order_list.elements) +
274
274
                               sl->group_list.elements,
275
275
                               can_skip_order_by ?
276
 
                               (order_st*) NULL : (order_st *)sl->order_list.first,
 
276
                               (order_st*) 0 : (order_st *)sl->order_list.first,
277
277
                               (order_st*) sl->group_list.first,
278
278
                               sl->having,
 
279
                               (is_union_select ? (order_st*) 0 :
 
280
                                (order_st*) thd_arg->lex->proc_list.first),
279
281
                               sl, this);
280
282
    /* There are no * in the statement anymore (for PS) */
281
283
    sl->with_wild= 0;
282
284
 
283
 
    if (saved_error || (saved_error= session_arg->is_fatal_error))
 
285
    if (saved_error || (saved_error= thd_arg->is_fatal_error))
284
286
      goto err;
285
287
    /*
286
288
      Use items list of underlaid select for derived tables to preserve
297
299
        field object without table.
298
300
      */
299
301
      assert(!empty_table);
300
 
      empty_table= (Table*) session->calloc(sizeof(Table));
 
302
      empty_table= (Table*) thd->calloc(sizeof(Table));
301
303
      types.empty();
302
304
      List_iterator_fast<Item> it(sl->item_list);
303
305
      Item *item_tmp;
304
306
      while ((item_tmp= it++))
305
307
      {
306
308
        /* Error's in 'new' will be detected after loop */
307
 
        types.push_back(new Item_type_holder(session_arg, item_tmp));
 
309
        types.push_back(new Item_type_holder(thd_arg, item_tmp));
308
310
      }
309
311
 
310
 
      if (session_arg->is_fatal_error)
 
312
      if (thd_arg->is_fatal_error)
311
313
        goto err; // out of memory
312
314
    }
313
315
    else
319
321
        goto err;
320
322
      }
321
323
      List_iterator_fast<Item> it(sl->item_list);
322
 
      List_iterator_fast<Item> tp(types);
 
324
      List_iterator_fast<Item> tp(types);       
323
325
      Item *type, *item_tmp;
324
326
      while ((type= tp++, item_tmp= it++))
325
327
      {
326
 
        if (((Item_type_holder*)type)->join_types(session_arg, item_tmp))
 
328
        if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp))
327
329
          return(true);
328
330
      }
329
331
    }
348
350
        goto err;
349
351
      }
350
352
    }
351
 
 
352
 
    create_options= (first_sl->options | session_arg->options |
 
353
    
 
354
    create_options= (first_sl->options | thd_arg->options |
353
355
                     TMP_TABLE_ALL_COLUMNS);
354
356
 
355
 
    if (union_result->create_result_table(session, &types, test(union_distinct),
356
 
                                          create_options, ""))
 
357
    if (union_result->create_result_table(thd, &types, test(union_distinct),
 
358
                                          create_options, "", false))
357
359
      goto err;
358
360
    memset(&result_table_list, 0, sizeof(result_table_list));
359
361
    result_table_list.db= (char*) "";
360
 
    result_table_list.alias= "union";
361
 
    result_table_list.table_name= (char *) "union";
 
362
    result_table_list.table_name= result_table_list.alias= (char*) "union";
362
363
    result_table_list.table= table= union_result->table;
363
364
 
364
 
    session_arg->lex->current_select= lex_select_save;
 
365
    thd_arg->lex->current_select= lex_select_save;
365
366
    if (!item_list.elements)
366
367
    {
367
368
      saved_error= table->fill_item_list(&item_list);
378
379
    }
379
380
  }
380
381
 
381
 
  session_arg->lex->current_select= lex_select_save;
 
382
  thd_arg->lex->current_select= lex_select_save;
382
383
 
383
 
  return(saved_error || session_arg->is_fatal_error);
 
384
  return(saved_error || thd_arg->is_fatal_error);
384
385
 
385
386
err:
386
 
  session_arg->lex->current_select= lex_select_save;
 
387
  thd_arg->lex->current_select= lex_select_save;
387
388
  return(true);
388
389
}
389
390
 
390
391
 
391
 
bool Select_Lex_Unit::exec()
 
392
bool st_select_lex_unit::exec()
392
393
{
393
 
  Select_Lex *lex_select_save= session->lex->current_select;
394
 
  Select_Lex *select_cursor=first_select();
 
394
  SELECT_LEX *lex_select_save= thd->lex->current_select;
 
395
  SELECT_LEX *select_cursor=first_select();
395
396
  uint64_t add_rows=0;
396
397
  ha_rows examined_rows= 0;
397
398
 
398
399
  if (executed && !uncacheable && !describe)
399
400
    return(false);
400
401
  executed= 1;
401
 
 
 
402
  
402
403
  if (uncacheable || !item || !item->assigned() || describe)
403
404
  {
404
405
    if (item)
409
410
      {
410
411
        item->assigned(0); // We will reinit & rexecute unit
411
412
        item->reset();
412
 
        table->cursor->ha_delete_all_rows();
 
413
        table->file->ha_delete_all_rows();
413
414
      }
414
415
      /* re-enabling indexes for next subselect iteration */
415
 
      if (union_distinct && table->cursor->ha_enable_indexes(HA_KEY_SWITCH_ALL))
 
416
      if (union_distinct && table->file->ha_enable_indexes(HA_KEY_SWITCH_ALL))
416
417
      {
417
418
        assert(0);
418
419
      }
419
420
    }
420
 
    for (Select_Lex *sl= select_cursor; sl; sl= sl->next_select())
 
421
    for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
421
422
    {
422
423
      ha_rows records_at_start= 0;
423
 
      session->lex->current_select= sl;
 
424
      thd->lex->current_select= sl;
424
425
 
425
426
      if (optimized)
426
427
        saved_error= sl->join->reinit();
431
432
        {
432
433
          offset_limit_cnt= 0;
433
434
          /*
434
 
            We can't use LIMIT at this stage if we are using ORDER BY for the
 
435
            We can't use LIMIT at this stage if we are using order_st BY for the
435
436
            whole query
436
437
          */
437
438
          if (sl->order_list.first || describe)
443
444
          we don't calculate found_rows() per union part.
444
445
          Otherwise, SQL_CALC_FOUND_ROWS should be done on all sub parts.
445
446
        */
446
 
        sl->join->select_options=
 
447
        sl->join->select_options= 
447
448
          (select_limit_cnt == HA_POS_ERROR || sl->braces) ?
448
449
          sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union;
449
450
 
 
451
        /* dump_TableList_struct(select_lex, select_lex->leaf_tables); */
 
452
        if (sl->join->flatten_subqueries())
 
453
          return(true);
 
454
 
 
455
        /* dump_TableList_struct(select_lex, select_lex->leaf_tables); */
450
456
        saved_error= sl->join->optimize();
451
457
      }
452
458
      if (!saved_error)
453
459
      {
454
 
        records_at_start= table->cursor->stats.records;
 
460
        records_at_start= table->file->stats.records;
455
461
        sl->join->exec();
456
462
        if (sl == union_distinct)
457
463
        {
458
 
          if (table->cursor->ha_disable_indexes(HA_KEY_SWITCH_ALL))
 
464
          if (table->file->ha_disable_indexes(HA_KEY_SWITCH_ALL))
459
465
            return(true);
460
466
          table->no_keyread=1;
461
467
        }
465
471
                                    0);
466
472
        if (!saved_error)
467
473
        {
468
 
          examined_rows+= session->examined_row_count;
 
474
          examined_rows+= thd->examined_row_count;
469
475
          if (union_result->flush())
470
476
          {
471
 
            session->lex->current_select= lex_select_save;
 
477
            thd->lex->current_select= lex_select_save;
472
478
            return(1);
473
479
          }
474
480
        }
475
481
      }
476
482
      if (saved_error)
477
483
      {
478
 
        session->lex->current_select= lex_select_save;
 
484
        thd->lex->current_select= lex_select_save;
479
485
        return(saved_error);
480
486
      }
481
487
      /* Needed for the following test and for records_at_start in next loop */
482
 
      int error= table->cursor->info(HA_STATUS_VARIABLE);
483
 
      if (error)
 
488
      int error= table->file->info(HA_STATUS_VARIABLE);
 
489
      if(error)
484
490
      {
485
 
        table->print_error(error, MYF(0));
 
491
        table->file->print_error(error, MYF(0));
486
492
        return(1);
487
493
      }
488
 
      if (found_rows_for_union && !sl->braces &&
 
494
      if (found_rows_for_union && !sl->braces && 
489
495
          select_limit_cnt != HA_POS_ERROR)
490
496
      {
491
497
        /*
494
500
          We get this from the difference of between total number of possible
495
501
          rows and actual rows added to the temporary table.
496
502
        */
497
 
        add_rows+= (uint64_t) (session->limit_found_rows - (uint64_t)
498
 
                              ((table->cursor->stats.records -  records_at_start)));
 
503
        add_rows+= (uint64_t) (thd->limit_found_rows - (uint64_t)
 
504
                              ((table->file->stats.records -  records_at_start)));
499
505
      }
500
506
    }
501
507
  }
504
510
  /* Send result to 'result' */
505
511
  saved_error= true;
506
512
  {
507
 
    if (!session->is_fatal_error)                               // Check if EOM
 
513
    if (!thd->is_fatal_error)                           // Check if EOM
508
514
    {
509
515
      set_limit(global_parameters);
510
 
      init_prepare_fake_select_lex(session);
 
516
      init_prepare_fake_select_lex(thd);
511
517
      JOIN *join= fake_select_lex->join;
512
518
      if (!join)
513
519
      {
519
525
          don't let it allocate the join. Perhaps this is because we need
520
526
          some special parameter values passed to join constructor?
521
527
        */
522
 
        if (!(fake_select_lex->join= new JOIN(session, item_list,
 
528
        if (!(fake_select_lex->join= new JOIN(thd, item_list,
523
529
                                              fake_select_lex->options, result)))
524
530
        {
525
531
          fake_select_lex->table_list.empty();
528
534
        fake_select_lex->join->no_const_tables= true;
529
535
 
530
536
        /*
531
 
          Fake Select_Lex should have item list for correctref_array
 
537
          Fake st_select_lex should have item list for correctref_array
532
538
          allocation.
533
539
        */
534
540
        fake_select_lex->item_list= item_list;
535
 
        saved_error= mysql_select(session, &fake_select_lex->ref_pointer_array,
 
541
        saved_error= mysql_select(thd, &fake_select_lex->ref_pointer_array,
536
542
                              &result_table_list,
537
543
                              0, item_list, NULL,
538
544
                              global_parameters->order_list.elements,
539
545
                              (order_st*)global_parameters->order_list.first,
540
 
                              (order_st*) NULL, NULL,
 
546
                              (order_st*) NULL, NULL, (order_st*) NULL,
541
547
                              fake_select_lex->options | SELECT_NO_UNLOCK,
542
548
                              result, this, fake_select_lex);
543
549
      }
551
557
             - 1st time is a real evaluation to get the subquery value
552
558
             - 2nd time is to produce EXPLAIN output rows.
553
559
            1st execution sets certain members (e.g. select_result) to perform
554
 
            subquery execution rather than EXPLAIN line production. In order
 
560
            subquery execution rather than EXPLAIN line production. In order 
555
561
            to reset them back, we re-do all of the actions (yes it is ugly):
556
562
          */
557
 
                join->reset(session, item_list, fake_select_lex->options, result);
558
 
          saved_error= mysql_select(session, &fake_select_lex->ref_pointer_array,
 
563
          join->init(thd, item_list, fake_select_lex->options, result);
 
564
          saved_error= mysql_select(thd, &fake_select_lex->ref_pointer_array,
559
565
                                &result_table_list,
560
566
                                0, item_list, NULL,
561
567
                                global_parameters->order_list.elements,
562
568
                                (order_st*)global_parameters->order_list.first,
563
 
                                (order_st*) NULL, NULL,
 
569
                                (order_st*) NULL, NULL, (order_st*) NULL,
564
570
                                fake_select_lex->options | SELECT_NO_UNLOCK,
565
571
                                result, this, fake_select_lex);
566
572
        }
575
581
      fake_select_lex->table_list.empty();
576
582
      if (!saved_error)
577
583
      {
578
 
        session->limit_found_rows = (uint64_t)table->cursor->stats.records + add_rows;
579
 
        session->examined_row_count+= examined_rows;
 
584
        thd->limit_found_rows = (uint64_t)table->file->stats.records + add_rows;
 
585
        thd->examined_row_count+= examined_rows;
580
586
      }
581
587
      /*
582
588
        Mark for slow query log if any of the union parts didn't use
584
590
      */
585
591
    }
586
592
  }
587
 
  session->lex->current_select= lex_select_save;
 
593
  thd->lex->current_select= lex_select_save;
588
594
  return(saved_error);
589
595
}
590
596
 
591
597
 
592
 
bool Select_Lex_Unit::cleanup()
 
598
bool st_select_lex_unit::cleanup()
593
599
{
594
600
  int error= 0;
595
601
 
604
610
    delete union_result;
605
611
    union_result=0; // Safety
606
612
    if (table)
607
 
      table->free_tmp_table(session);
 
613
      table->free_tmp_table(thd);
608
614
    table= 0; // Safety
609
615
  }
610
616
 
611
 
  for (Select_Lex *sl= first_select(); sl; sl= sl->next_select())
 
617
  for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
612
618
    error|= sl->cleanup();
613
619
 
614
620
  if (fake_select_lex)
632
638
}
633
639
 
634
640
 
635
 
void Select_Lex_Unit::reinit_exec_mechanism()
 
641
void st_select_lex_unit::reinit_exec_mechanism()
636
642
{
637
643
  prepared= optimized= executed= 0;
638
644
}
642
648
  change select_result object of unit
643
649
 
644
650
  SYNOPSIS
645
 
    Select_Lex_Unit::change_result()
 
651
    st_select_lex_unit::change_result()
646
652
    result      new select_result object
647
653
    old_result  old select_result object
648
654
 
651
657
    true  - error
652
658
*/
653
659
 
654
 
bool Select_Lex_Unit::change_result(select_result_interceptor *new_result,
 
660
bool st_select_lex_unit::change_result(select_result_interceptor *new_result,
655
661
                                       select_result_interceptor *old_result)
656
662
{
657
663
  bool res= false;
658
 
  for (Select_Lex *sl= first_select(); sl; sl= sl->next_select())
 
664
  for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
659
665
  {
660
666
    if (sl->join && sl->join->result == old_result)
661
667
      if (sl->join->change_result(new_result))
670
676
  Get column type information for this unit.
671
677
 
672
678
  SYNOPSIS
673
 
    Select_Lex_Unit::get_unit_column_types()
 
679
    st_select_lex_unit::get_unit_column_types()
674
680
 
675
681
  DESCRIPTION
676
682
    For a single-select the column types are taken
677
683
    from the list of selected items. For a union this function
678
 
    assumes that Select_Lex_Unit::prepare has been called
 
684
    assumes that st_select_lex_unit::prepare has been called
679
685
    and returns the type holders that were created for unioned
680
686
    column types of all selects.
681
687
 
682
688
  NOTES
683
689
    The implementation of this function should be in sync with
684
 
    Select_Lex_Unit::prepare()
 
690
    st_select_lex_unit::prepare()
685
691
*/
686
692
 
687
 
List<Item> *Select_Lex_Unit::get_unit_column_types()
 
693
List<Item> *st_select_lex_unit::get_unit_column_types()
688
694
{
689
 
  Select_Lex *sl= first_select();
 
695
  SELECT_LEX *sl= first_select();
690
696
 
691
697
  if (is_union())
692
698
  {
698
704
  return &sl->item_list;
699
705
}
700
706
 
701
 
bool Select_Lex::cleanup()
 
707
bool st_select_lex::cleanup()
702
708
{
703
709
  bool error= false;
704
710
 
705
711
  if (join)
706
712
  {
707
 
    assert((Select_Lex*)join->select_lex == this);
 
713
    assert((st_select_lex*)join->select_lex == this);
708
714
    error= join->destroy();
709
715
    delete join;
710
716
    join= 0;
711
717
  }
712
 
  for (Select_Lex_Unit *lex_unit= first_inner_unit(); lex_unit ;
 
718
  for (SELECT_LEX_UNIT *lex_unit= first_inner_unit(); lex_unit ;
713
719
       lex_unit= lex_unit->next_unit())
714
720
  {
715
 
    error= (bool) ((uint32_t) error | (uint32_t) lex_unit->cleanup());
 
721
    error= (bool) ((uint) error | (uint) lex_unit->cleanup());
716
722
  }
717
723
  non_agg_fields.empty();
718
724
  inner_refs_list.empty();
720
726
}
721
727
 
722
728
 
723
 
void Select_Lex::cleanup_all_joins(bool full)
 
729
void st_select_lex::cleanup_all_joins(bool full)
724
730
{
725
 
  Select_Lex_Unit *unit;
726
 
  Select_Lex *sl;
 
731
  SELECT_LEX_UNIT *unit;
 
732
  SELECT_LEX *sl;
727
733
 
728
734
  if (join)
729
735
    join->cleanup(full);
732
738
    for (sl= unit->first_select(); sl; sl= sl->next_select())
733
739
      sl->cleanup_all_joins(full);
734
740
}
735
 
 
736
 
} /* namespace drizzled */