~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/explain_plan.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-12-09 01:08:44 UTC
  • mto: This revision was merged to the branch mainline in revision 1247.
  • Revision ID: osullivan.padraig@gmail.com-20091209010844-kgtpbf7elmg0vef9
Used std::string for the type in Select_Lex instead of char *.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
  {
71
71
    item_list.push_back(new Item_int((int32_t)
72
72
                        join->select_lex->select_number));
73
 
    item_list.push_back(new Item_string(join->select_lex->type,
74
 
                                        strlen(join->select_lex->type), 
 
73
    item_list.push_back(new Item_string(join->select_lex->type.c_str(),
 
74
                                        join->select_lex->type.length(),
75
75
                                        cs));
76
76
    for (uint32_t i= 0; i < 7; i++)
77
77
      item_list.push_back(item_null);
97
97
    /* id */
98
98
    item_list.push_back(new Item_null);
99
99
    /* select_type */
100
 
    item_list.push_back(new Item_string(join->select_lex->type,
101
 
                                        strlen(join->select_lex->type),
 
100
    item_list.push_back(new Item_string(join->select_lex->type.c_str(),
 
101
                                        join->select_lex->type.length(),
102
102
                                        cs));
103
103
    /* table */
104
104
    {
177
177
      item_list.push_back(new Item_uint((uint32_t)
178
178
            join->select_lex->select_number));
179
179
      /* select_type */
180
 
      item_list.push_back(new Item_string(join->select_lex->type,
181
 
                                          strlen(join->select_lex->type),
 
180
      item_list.push_back(new Item_string(join->select_lex->type.c_str(),
 
181
                                          join->select_lex->type.length(),
182
182
                                          cs));
183
183
      if (tab->type == AM_ALL && tab->select && tab->select->quick)
184
184
      {
204
204
      {
205
205
        TableList *real_table= table->pos_in_table_list;
206
206
        item_list.push_back(new Item_string(real_table->alias,
207
 
              strlen(real_table->alias),
208
 
              cs));
 
207
                                            strlen(real_table->alias),
 
208
                                            cs));
209
209
      }
210
210
      /* "type" column */
211
211
      item_list.push_back(new Item_string(access_method_str[tab->type].c_str(),
235
235
      if (tab->ref.key_parts)
236
236
      {
237
237
        KEY *key_info= table->key_info+ tab->ref.key;
238
 
        register uint32_t length;
239
238
        item_list.push_back(new Item_string(key_info->name,
240
239
                                            strlen(key_info->name),
241
240
                                            system_charset_info));
242
 
        length= int64_t2str(tab->ref.key_length, keylen_str_buf, 10) -
243
 
                            keylen_str_buf;
 
241
        uint32_t length= int64_t2str(tab->ref.key_length, keylen_str_buf, 10) -
 
242
                                     keylen_str_buf;
244
243
        item_list.push_back(new Item_string(keylen_str_buf, 
245
244
                                            length,
246
245
                                            system_charset_info));
257
256
      else if (tab->type == AM_NEXT)
258
257
      {
259
258
        KEY *key_info=table->key_info+ tab->index;
260
 
        register uint32_t length;
261
259
        item_list.push_back(new Item_string(key_info->name,
262
260
              strlen(key_info->name),cs));
263
 
        length= int64_t2str(key_info->key_length, keylen_str_buf, 10) -
264
 
          keylen_str_buf;
 
261
        uint32_t length= int64_t2str(key_info->key_length, keylen_str_buf, 10) -
 
262
                                     keylen_str_buf;
265
263
        item_list.push_back(new Item_string(keylen_str_buf,
266
264
                                            length,
267
265
                                            system_charset_info));
284
282
      /* Add "rows" field to item_list. */
285
283
      double examined_rows;
286
284
      if (tab->select && tab->select->quick)
 
285
      {
287
286
        examined_rows= rows2double(tab->select->quick->records);
 
287
      }
288
288
      else if (tab->type == AM_NEXT || tab->type == AM_ALL)
 
289
      {
289
290
        examined_rows= rows2double(tab->limit ? tab->limit :
290
 
            tab->table->cursor->records());
 
291
                                                tab->table->cursor->records());
 
292
      }
291
293
      else
292
294
      {
293
295
        optimizer::Position cur_pos= join->getPosFromOptimalPlan(i);
295
297
      }
296
298
 
297
299
      item_list.push_back(new Item_int((int64_t) (uint64_t) examined_rows,
298
 
            MY_INT64_NUM_DECIMAL_DIGITS));
 
300
                                       MY_INT64_NUM_DECIMAL_DIGITS));
299
301
 
300
302
      /* Add "filtered" field to item_list. */
301
303
      if (join->session->lex->describe & DESCRIBE_EXTENDED)
304
306
        if (examined_rows)
305
307
        {
306
308
          optimizer::Position cur_pos= join->getPosFromOptimalPlan(i);
307
 
          f= (float) (100.0 * cur_pos.getFanout() /
308
 
              examined_rows);
 
309
          f= static_cast<float>(100.0 * cur_pos.getFanout() / examined_rows);
309
310
        }
310
311
        item_list.push_back(new Item_float(f, 2));
311
312
      }
469
470
    {
470
471
      if (sl->first_inner_unit() || sl->next_select())
471
472
      {
472
 
        sl->type= "PRIMARY";
 
473
        sl->type.assign("PRIMARY");
473
474
      }
474
475
      else
475
476
      {
476
 
        sl->type= "SIMPLE";
 
477
        sl->type.assign("SIMPLE");
477
478
      }
478
479
    }
479
480
    else
482
483
      {
483
484
        if (sl->linkage == DERIVED_TABLE_TYPE)
484
485
        {
485
 
          sl->type= "DERIVED";
 
486
          sl->type.assign("DERIVED");
486
487
        }
487
488
        else
488
489
        {
489
490
          if (uncacheable & UNCACHEABLE_DEPENDENT)
490
491
          {
491
 
            sl->type= "DEPENDENT SUBQUERY";
 
492
            sl->type.assign("DEPENDENT SUBQUERY");
492
493
          }
493
494
          else
494
495
          {
495
496
            if (uncacheable)
496
497
            {
497
 
              sl->type= "UNCACHEABLE SUBQUERY";
 
498
              sl->type.assign("UNCACHEABLE SUBQUERY");
498
499
            }
499
500
            else
500
501
            {
501
 
              sl->type= "SUBQUERY";
 
502
              sl->type.assign("SUBQUERY");
502
503
            }
503
504
          }
504
505
        }
507
508
      {
508
509
        if (uncacheable & UNCACHEABLE_DEPENDENT)
509
510
        {
510
 
          sl->type= "DEPENDENT UNION";
 
511
          sl->type.assign("DEPENDENT UNION");
511
512
        }
512
513
        else
513
514
        {
514
515
          if (uncacheable)
515
516
          {
516
 
            sl->type= "UNCACHEABLE_UNION";
 
517
            sl->type.assign("UNCACHEABLE_UNION");
517
518
          }
518
519
          else
519
520
          {
520
 
            sl->type= "UNION";
 
521
            sl->type.assign("UNION");
521
522
          }
522
523
        }
523
524
      }
528
529
  if (unit->is_union())
529
530
  {
530
531
    unit->fake_select_lex->select_number= UINT_MAX; // just for initialization
531
 
    unit->fake_select_lex->type= "UNION RESULT";
 
532
    unit->fake_select_lex->type.assign("UNION RESULT");
532
533
    unit->fake_select_lex->options|= SELECT_DESCRIBE;
533
534
    if (! (res= unit->prepare(session, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE)))
534
535
    {