~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_union.cc

  • Committer: Stewart Smith
  • Date: 2008-07-13 08:00:16 UTC
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080713080016-8qtjv9ypt42azzr6
CRC32() as UDF

Show diffs side-by-side

added added

removed removed

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