~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

Fixes for Solaris with ufs filesystem headers. AT_ALL is already #defined...

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
using namespace std;
56
56
 
57
 
static const string access_type_str[]=
 
57
static const string access_method_str[]=
58
58
{
59
59
  "UNKNOWN",
60
60
  "system",
1708
1708
          key_buff, maybe_null);
1709
1709
      /*
1710
1710
        Remember if we are going to use REF_OR_NULL
1711
 
        But only if field _really_ can be null i.e. we force AT_REF
1712
 
        instead of AT_REF_OR_NULL in case if field can't be null
 
1711
        But only if field _really_ can be null i.e. we force AM_REF
 
1712
        instead of AM_REF_OR_NULL in case if field can't be null
1713
1713
      */
1714
1714
      if ((keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL) && maybe_null)
1715
1715
        null_ref_key= key_buff;
1717
1717
    }
1718
1718
  }
1719
1719
  *ref_key=0;       // end_marker
1720
 
  if (j->type == AT_CONST)
 
1720
  if (j->type == AM_CONST)
1721
1721
    j->table->const_table= 1;
1722
1722
  else if (((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY)) != HA_NOSAME) ||
1723
1723
           keyparts != keyinfo->key_parts || null_ref_key)
1724
1724
  {
1725
1725
    /* Must read with repeat */
1726
 
    j->type= null_ref_key ? AT_REF_OR_NULL : AT_REF;
 
1726
    j->type= null_ref_key ? AM_REF_OR_NULL : AM_REF;
1727
1727
    j->ref.null_ref_key= null_ref_key;
1728
1728
  }
1729
1729
  else if (keyuse_uses_no_tables)
1735
1735
      Here we should not mark the table as a 'const' as a field may
1736
1736
      have a 'normal' value or a NULL value.
1737
1737
    */
1738
 
    j->type= AT_CONST;
 
1738
    j->type= AM_CONST;
1739
1739
  }
1740
1740
  else
1741
 
    j->type= AT_EQ_REF;
 
1741
    j->type= AM_EQ_REF;
1742
1742
  return(0);
1743
1743
}
1744
1744
 
1797
1797
  for (uint32_t i=join->const_tables ; i < join->tables ; i++)
1798
1798
  {
1799
1799
    JoinTable *tab=join->join_tab+i;
1800
 
    if ((tab->type == AT_REF || tab->type == AT_EQ_REF ||
1801
 
         tab->type == AT_REF_OR_NULL) &&
 
1800
    if ((tab->type == AM_REF || tab->type == AM_EQ_REF ||
 
1801
         tab->type == AM_REF_OR_NULL) &&
1802
1802
        !tab->table->maybe_null)
1803
1803
    {
1804
1804
      for (uint32_t keypart= 0; keypart < tab->ref.key_parts; keypart++)
2167
2167
    return tab->eq_ref_table;
2168
2168
  tab->cached_eq_ref_table=1;
2169
2169
  /* We can skip const tables only if not an outer table */
2170
 
  if (tab->type == AT_CONST && !tab->first_inner)
 
2170
  if (tab->type == AM_CONST && !tab->first_inner)
2171
2171
    return (tab->eq_ref_table=1);               /* purecov: inspected */
2172
 
  if (tab->type != AT_EQ_REF || tab->table->maybe_null)
 
2172
  if (tab->type != AM_EQ_REF || tab->table->maybe_null)
2173
2173
    return (tab->eq_ref_table=0);               // We must use this
2174
2174
  Item **ref_item=tab->ref.items;
2175
2175
  Item **end=ref_item+tab->ref.key_parts;
4257
4257
  table->null_row=0;
4258
4258
  table->status=STATUS_NO_RECORD;
4259
4259
 
4260
 
  if (tab->type == AT_SYSTEM)
 
4260
  if (tab->type == AM_SYSTEM)
4261
4261
  {
4262
4262
    if ((error=join_read_system(tab)))
4263
4263
    {                                           // Info for DESCRIBE
5461
5461
  {
5462
5462
    ref_key=       tab->ref.key;
5463
5463
    ref_key_parts= tab->ref.key_parts;
5464
 
    if (tab->type == AT_REF_OR_NULL)
 
5464
    if (tab->type == AM_REF_OR_NULL)
5465
5465
      return(0);
5466
5466
  }
5467
5467
  else if (select && select->quick)             // Range found by opt_range
5588
5588
        filesort() and join cache are usually faster than reading in
5589
5589
        index order and not using join cache
5590
5590
        */
5591
 
      if (tab->type == AT_ALL && tab->join->tables > tab->join->const_tables + 1)
 
5591
      if (tab->type == AM_ALL && tab->join->tables > tab->join->const_tables + 1)
5592
5592
        return(0);
5593
5593
      keys= *table->file->keys_to_use_for_scanning();
5594
5594
      keys|= table->covering_keys;
5742
5742
          tab->index= best_key;
5743
5743
          tab->read_first_record= best_key_direction > 0 ?
5744
5744
                                  join_read_first:join_read_last;
5745
 
          tab->type= AT_NEXT;           // Read with index_first(), index_next()
 
5745
          tab->type= AM_NEXT;           // Read with index_first(), index_next()
5746
5746
          if (select && select->quick)
5747
5747
          {
5748
5748
            delete select->quick;
5762
5762
              tab->limit= select_limit;
5763
5763
          }
5764
5764
        }
5765
 
        else if (tab->type != AT_ALL)
 
5765
        else if (tab->type != AM_ALL)
5766
5766
        {
5767
5767
          /*
5768
5768
            We're about to use a quick access to the table.
5770
5770
            method is actually used.
5771
5771
          */
5772
5772
          assert(tab->select->quick);
5773
 
          tab->type= AT_ALL;
 
5773
          tab->type= AM_ALL;
5774
5774
          tab->use_quick=1;
5775
5775
          tab->ref.key= -1;
5776
5776
          tab->ref.key_parts=0;         // Don't use ref key.
5824
5824
        select->quick=tmp;
5825
5825
      }
5826
5826
    }
5827
 
    else if (tab->type != AT_NEXT &&
 
5827
    else if (tab->type != AM_NEXT &&
5828
5828
             tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
5829
5829
    {
5830
5830
      /*
5957
5957
  tab->select_cond=0;
5958
5958
  tab->last_inner= 0;
5959
5959
  tab->first_unmatched= 0;
5960
 
  tab->type= AT_ALL;                            // Read with normal read_record
 
5960
  tab->type= AM_ALL;                            // Read with normal read_record
5961
5961
  tab->read_first_record= join_init_read_record;
5962
5962
  tab->join->examined_rows+=examined_rows;
5963
5963
  if (table->key_read)                          // Restore if we used indexes
7273
7273
      item_list.push_back(new Item_string(table_name_buffer, len, cs));
7274
7274
    }
7275
7275
    /* type */
7276
 
    item_list.push_back(new Item_string(access_type_str[AT_ALL].c_str(),
7277
 
                                        access_type_str[AT_ALL].length(),
 
7276
    item_list.push_back(new Item_string(access_method_str[AM_ALL].c_str(),
 
7277
                                        access_method_str[AM_ALL].length(),
7278
7278
                                        cs));
7279
7279
    /* possible_keys */
7280
7280
    item_list.push_back(item_null);
7329
7329
      item_list.push_back(new Item_string(join->select_lex->type,
7330
7330
                                          strlen(join->select_lex->type),
7331
7331
                                          cs));
7332
 
      if (tab->type == AT_ALL && tab->select && tab->select->quick)
 
7332
      if (tab->type == AM_ALL && tab->select && tab->select->quick)
7333
7333
      {
7334
7334
        quick_type= tab->select->quick->get_type();
7335
7335
        if ((quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE) ||
7336
7336
            (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT) ||
7337
7337
            (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION))
7338
 
          tab->type = AT_INDEX_MERGE;
 
7338
          tab->type = AM_INDEX_MERGE;
7339
7339
        else
7340
 
          tab->type = AT_RANGE;
 
7340
          tab->type = AM_RANGE;
7341
7341
      }
7342
7342
      /* table */
7343
7343
      if (table->derived_select_number)
7356
7356
                                            cs));
7357
7357
      }
7358
7358
      /* "type" column */
7359
 
      item_list.push_back(new Item_string(access_type_str[tab->type].c_str(),
7360
 
                                          access_type_str[tab->type].length(),
 
7359
      item_list.push_back(new Item_string(access_method_str[tab->type].c_str(),
 
7360
                                          access_method_str[tab->type].length(),
7361
7361
                                          cs));
7362
7362
      /* Build "possible_keys" value and add it to item_list */
7363
7363
      if (tab->keys.any())
7401
7401
        }
7402
7402
        item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs));
7403
7403
      }
7404
 
      else if (tab->type == AT_NEXT)
 
7404
      else if (tab->type == AM_NEXT)
7405
7405
      {
7406
7406
        KEY *key_info=table->key_info+ tab->index;
7407
7407
        register uint32_t length;
7465
7465
        double examined_rows;
7466
7466
        if (tab->select && tab->select->quick)
7467
7467
          examined_rows= rows2double(tab->select->quick->records);
7468
 
        else if (tab->type == AT_NEXT || tab->type == AT_ALL)
 
7468
        else if (tab->type == AM_NEXT || tab->type == AM_ALL)
7469
7469
          examined_rows= rows2double(tab->limit ? tab->limit :
7470
7470
                                     tab->table->file->records());
7471
7471
        else
7493
7493
 
7494
7494
      /* Build "Extra" field and add it to item_list. */
7495
7495
      bool key_read=table->key_read;
7496
 
      if ((tab->type == AT_NEXT || tab->type == AT_CONST) &&
 
7496
      if ((tab->type == AM_NEXT || tab->type == AM_CONST) &&
7497
7497
          table->covering_keys.test(tab->index))
7498
7498
        key_read=1;
7499
7499
      if (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT &&