~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Brian Aker
  • Date: 2009-11-30 19:13:19 UTC
  • mfrom: (1225.1.39 figure)
  • Revision ID: brian@gaz-20091130191319-zyt51fidacic3brf
Merge Padraig

Show diffs side-by-side

added added

removed removed

Lines of Context:
5293
5293
    }
5294
5294
  }
5295
5295
 
5296
 
  /* Fill schema tables with data before filesort if it's necessary */
5297
 
  if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
5298
 
      get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX))
5299
 
    goto err;
5300
 
 
5301
5296
  if (table->s->tmp_table)
5302
5297
    table->cursor->info(HA_STATUS_VARIABLE);    // Get record count
5303
5298
  table->sort.found_records=filesort(session, table,join->sortorder, length,
6660
6655
    {
6661
6656
      JoinTable *tab=join->join_tab+i;
6662
6657
      Table *table=tab->table;
6663
 
      TableList *table_list= tab->table->pos_in_table_list;
6664
6658
      char buff[512];
6665
6659
      char buff1[512], buff2[512], buff3[512];
6666
6660
      char keylen_str_buf[64];
6777
6771
      }
6778
6772
      else
6779
6773
      {
6780
 
        if (table_list->schema_table && 
6781
 
            table_list->schema_table->getRequestedObject() & OPTIMIZE_I_S_TABLE)
6782
 
        {
6783
 
          if (table_list->has_db_lookup_value)
6784
 
          {
6785
 
            int f_idx= table_list->schema_table->getFirstColumnIndex();
6786
 
            const string &tmp_buff= table_list->schema_table->getColumnName(f_idx);
6787
 
            tmp2.append(tmp_buff.c_str(), tmp_buff.length(), cs);
6788
 
          }
6789
 
          if (table_list->has_table_lookup_value)
6790
 
          {
6791
 
            if (table_list->has_db_lookup_value)
6792
 
              tmp2.append(',');
6793
 
            int f_idx= table_list->schema_table->getSecondColumnIndex();
6794
 
            const string &tmp_buff= table_list->schema_table->getColumnName(f_idx);
6795
 
            tmp2.append(tmp_buff.c_str(), tmp_buff.length(), cs);
6796
 
          }
6797
 
          if (tmp2.length())
6798
 
            item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs));
6799
 
          else
6800
 
            item_list.push_back(item_null);
6801
 
        }
6802
 
        else
6803
 
          item_list.push_back(item_null);
 
6774
        item_list.push_back(item_null);
6804
6775
        item_list.push_back(item_null);
6805
6776
        item_list.push_back(item_null);
6806
6777
      }
6807
6778
 
6808
6779
      /* Add "rows" field to item_list. */
6809
 
      if (table_list->schema_table)
 
6780
      double examined_rows;
 
6781
      if (tab->select && tab->select->quick)
 
6782
        examined_rows= rows2double(tab->select->quick->records);
 
6783
      else if (tab->type == AM_NEXT || tab->type == AM_ALL)
 
6784
        examined_rows= rows2double(tab->limit ? tab->limit :
 
6785
            tab->table->cursor->records());
 
6786
      else
6810
6787
      {
6811
 
        /* in_rows */
6812
 
        if (join->session->lex->describe & DESCRIBE_EXTENDED)
6813
 
          item_list.push_back(item_null);
6814
 
        /* rows */
6815
 
        item_list.push_back(item_null);
 
6788
        optimizer::Position cur_pos= join->getPosFromOptimalPlan(i);
 
6789
        examined_rows= cur_pos.getFanout();
6816
6790
      }
6817
 
      else
 
6791
 
 
6792
      item_list.push_back(new Item_int((int64_t) (uint64_t) examined_rows,
 
6793
            MY_INT64_NUM_DECIMAL_DIGITS));
 
6794
 
 
6795
      /* Add "filtered" field to item_list. */
 
6796
      if (join->session->lex->describe & DESCRIBE_EXTENDED)
6818
6797
      {
6819
 
        double examined_rows;
6820
 
        if (tab->select && tab->select->quick)
6821
 
          examined_rows= rows2double(tab->select->quick->records);
6822
 
        else if (tab->type == AM_NEXT || tab->type == AM_ALL)
6823
 
          examined_rows= rows2double(tab->limit ? tab->limit :
6824
 
                                     tab->table->cursor->records());
6825
 
        else
 
6798
        float f= 0.0;
 
6799
        if (examined_rows)
6826
6800
        {
6827
6801
          optimizer::Position cur_pos= join->getPosFromOptimalPlan(i);
6828
 
          examined_rows= cur_pos.getFanout();
6829
 
        }
6830
 
 
6831
 
        item_list.push_back(new Item_int((int64_t) (uint64_t) examined_rows,
6832
 
                                         MY_INT64_NUM_DECIMAL_DIGITS));
6833
 
 
6834
 
        /* Add "filtered" field to item_list. */
6835
 
        if (join->session->lex->describe & DESCRIBE_EXTENDED)
6836
 
        {
6837
 
          float f= 0.0;
6838
 
          if (examined_rows)
6839
 
          {
6840
 
            optimizer::Position cur_pos= join->getPosFromOptimalPlan(i);
6841
 
            f= (float) (100.0 * cur_pos.getFanout() /
6842
 
                        examined_rows);
6843
 
          }
6844
 
          item_list.push_back(new Item_float(f, 2));
6845
 
        }
 
6802
          f= (float) (100.0 * cur_pos.getFanout() /
 
6803
              examined_rows);
 
6804
        }
 
6805
        item_list.push_back(new Item_float(f, 2));
6846
6806
      }
6847
6807
 
6848
6808
      /* Build "Extra" field and add it to item_list. */
6931
6891
        if (table->reginfo.not_exists_optimize)
6932
6892
          extra.append(STRING_WITH_LEN("; Not exists"));
6933
6893
 
6934
 
        if (table_list->schema_table &&
6935
 
            table_list->schema_table->getRequestedObject() & OPTIMIZE_I_S_TABLE)
6936
 
        {
6937
 
          if (!table_list->table_open_method)
6938
 
            extra.append(STRING_WITH_LEN("; Skip_open_table"));
6939
 
          else if (table_list->table_open_method == OPEN_FRM_ONLY)
6940
 
            extra.append(STRING_WITH_LEN("; Open_frm_only"));
6941
 
          else
6942
 
            extra.append(STRING_WITH_LEN("; Open_full_table"));
6943
 
          if (table_list->has_db_lookup_value &&
6944
 
              table_list->has_table_lookup_value)
6945
 
            extra.append(STRING_WITH_LEN("; Scanned 0 databases"));
6946
 
          else if (table_list->has_db_lookup_value ||
6947
 
                   table_list->has_table_lookup_value)
6948
 
            extra.append(STRING_WITH_LEN("; Scanned 1 database"));
6949
 
          else
6950
 
            extra.append(STRING_WITH_LEN("; Scanned all databases"));
6951
 
        }
6952
6894
        if (need_tmp_table)
6953
6895
        {
6954
6896
          need_tmp_table=0;