~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_union.cc

  • Committer: Siddharth Prakash Singh
  • Date: 2010-03-26 17:24:57 UTC
  • mto: This revision was merged to the branch mainline in revision 1425.
  • Revision ID: spsneo@spsneo-laptop-20100326172457-vni09y22ktvvefmn
some more sprintf --> snprintf

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/*
17
17
  UNION  of select's
59
59
    unit->offset_limit_cnt--;
60
60
    return 0;
61
61
  }
62
 
  fill_record(session, table->getFields(), values, true);
 
62
  fill_record(session, table->field, values, true);
63
63
  if (session->is_error())
64
64
    return 1;
65
65
 
66
 
  if ((error= table->cursor->insertRecord(table->getInsertRecord())))
 
66
  if ((error= table->cursor->ha_write_row(table->record[0])))
67
67
  {
68
68
    /* create_myisam_from_heap will generate error if needed */
69
 
    if (table->cursor->is_fatal_error(error, HA_CHECK_DUP))
70
 
    {
71
 
      my_error(ER_USE_SQL_BIG_RESULT, MYF(0));
72
 
      return true;
73
 
    }
 
69
    if (table->cursor->is_fatal_error(error, HA_CHECK_DUP) &&
 
70
        create_myisam_from_heap(session, table, tmp_table_param.start_recinfo,
 
71
                                &tmp_table_param.recinfo, error, 1))
 
72
      return 1;
74
73
  }
75
74
  return 0;
76
75
}
125
124
  tmp_table_param.field_count= column_types->elements;
126
125
 
127
126
  if (! (table= create_tmp_table(session_arg, &tmp_table_param, *column_types,
128
 
                                 (Order*) NULL, is_union_distinct, 1,
 
127
                                 (order_st*) NULL, is_union_distinct, 1,
129
128
                                 options, HA_POS_ERROR, (char*) table_alias)))
130
 
  {
131
129
    return true;
132
 
  }
133
 
 
134
130
  table->cursor->extra(HA_EXTRA_WRITE_CACHE);
135
131
  table->cursor->extra(HA_EXTRA_IGNORE_DUP_KEY);
136
 
 
137
132
  return false;
138
133
}
139
134
 
176
171
    fake_select_lex->context.first_name_resolution_table=
177
172
    fake_select_lex->get_table_list();
178
173
 
179
 
  for (Order *order= (Order *) global_parameters->order_list.first;
 
174
  for (order_st *order= (order_st *) global_parameters->order_list.first;
180
175
       order;
181
176
       order= order->next)
182
177
    order->item= &order->item_ptr;
183
178
 
184
 
  for (Order *order= (Order *)global_parameters->order_list.first;
 
179
  for (order_st *order= (order_st *)global_parameters->order_list.first;
185
180
       order;
186
181
       order=order->next)
187
182
  {
253
248
  {
254
249
    bool can_skip_order_by;
255
250
    sl->options|=  SELECT_NO_UNLOCK;
256
 
    Join *join= new Join(session_arg, sl->item_list,
 
251
    JOIN *join= new JOIN(session_arg, sl->item_list,
257
252
                         sl->options | session_arg->options | additional_options,
258
253
                         tmp_result);
259
254
    /*
278
273
                                sl->order_list.elements) +
279
274
                               sl->group_list.elements,
280
275
                               can_skip_order_by ?
281
 
                               (Order*) NULL : (Order *)sl->order_list.first,
282
 
                               (Order*) sl->group_list.first,
 
276
                               (order_st*) NULL : (order_st *)sl->order_list.first,
 
277
                               (order_st*) sl->group_list.first,
283
278
                               sl->having,
284
279
                               sl, this);
285
280
    /* There are no * in the statement anymore (for PS) */
361
356
                                          create_options, ""))
362
357
      goto err;
363
358
    memset(&result_table_list, 0, sizeof(result_table_list));
364
 
    result_table_list.setSchemaName((char*) "");
 
359
    result_table_list.db= (char*) "";
365
360
    result_table_list.alias= "union";
366
 
    result_table_list.setTableName((char *) "union");
 
361
    result_table_list.table_name= (char *) "union";
367
362
    result_table_list.table= table= union_result->table;
368
363
 
369
364
    session_arg->lex->current_select= lex_select_save;
400
395
  uint64_t add_rows=0;
401
396
  ha_rows examined_rows= 0;
402
397
 
403
 
  if (executed && uncacheable.none() && ! describe)
404
 
    return false;
 
398
  if (executed && !uncacheable && !describe)
 
399
    return(false);
405
400
  executed= 1;
406
401
 
407
 
  if (uncacheable.any() || ! item || ! item->assigned() || describe)
 
402
  if (uncacheable || !item || !item->assigned() || describe)
408
403
  {
409
404
    if (item)
410
405
      item->reset_value_registration();
513
508
    {
514
509
      set_limit(global_parameters);
515
510
      init_prepare_fake_select_lex(session);
516
 
      Join *join= fake_select_lex->join;
 
511
      JOIN *join= fake_select_lex->join;
517
512
      if (!join)
518
513
      {
519
514
        /*
524
519
          don't let it allocate the join. Perhaps this is because we need
525
520
          some special parameter values passed to join constructor?
526
521
        */
527
 
        if (!(fake_select_lex->join= new Join(session, item_list,
 
522
        if (!(fake_select_lex->join= new JOIN(session, item_list,
528
523
                                              fake_select_lex->options, result)))
529
524
        {
530
525
          fake_select_lex->table_list.empty();
541
536
                              &result_table_list,
542
537
                              0, item_list, NULL,
543
538
                              global_parameters->order_list.elements,
544
 
                              (Order*)global_parameters->order_list.first,
545
 
                              (Order*) NULL, NULL,
 
539
                              (order_st*)global_parameters->order_list.first,
 
540
                              (order_st*) NULL, NULL,
546
541
                              fake_select_lex->options | SELECT_NO_UNLOCK,
547
542
                              result, this, fake_select_lex);
548
543
      }
564
559
                                &result_table_list,
565
560
                                0, item_list, NULL,
566
561
                                global_parameters->order_list.elements,
567
 
                                (Order*)global_parameters->order_list.first,
568
 
                                (Order*) NULL, NULL,
 
562
                                (order_st*)global_parameters->order_list.first,
 
563
                                (order_st*) NULL, NULL,
569
564
                                fake_select_lex->options | SELECT_NO_UNLOCK,
570
565
                                result, this, fake_select_lex);
571
566
        }
608
603
  {
609
604
    delete union_result;
610
605
    union_result=0; // Safety
 
606
    if (table)
 
607
      table->free_tmp_table(session);
611
608
    table= 0; // Safety
612
609
  }
613
610
 
616
613
 
617
614
  if (fake_select_lex)
618
615
  {
619
 
    Join *join;
 
616
    JOIN *join;
620
617
    if ((join= fake_select_lex->join))
621
618
    {
622
619
      join->tables_list= 0;
625
622
    error|= fake_select_lex->cleanup();
626
623
    if (fake_select_lex->order_list.elements)
627
624
    {
628
 
      Order *ord;
629
 
      for (ord= (Order*)fake_select_lex->order_list.first; ord; ord= ord->next)
 
625
      order_st *ord;
 
626
      for (ord= (order_st*)fake_select_lex->order_list.first; ord; ord= ord->next)
630
627
        (*ord->item)->cleanup();
631
628
    }
632
629
  }