~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

Merge Nathan

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
#include <string>
53
53
#include <iostream>
 
54
#include <algorithm>
54
55
 
55
56
using namespace std;
56
57
 
1591
1592
  uint  and_level,i,found_eq_constant;
1592
1593
  KEY_FIELD *key_fields, *end, *field;
1593
1594
  uint32_t sz;
1594
 
  uint32_t m= cmax(select_lex->max_equal_elems,(uint32_t)1);
 
1595
  uint32_t m= max(select_lex->max_equal_elems,(uint32_t)1);
1595
1596
 
1596
1597
  /*
1597
1598
    We use the same piece of memory to store both  KEY_FIELD
1614
1615
    can be not more than select_lex->max_equal_elems such
1615
1616
    substitutions.
1616
1617
  */
1617
 
  sz= cmax(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
 
1618
  sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
1618
1619
      (((session->lex->current_select->cond_count+1)*2 +
1619
1620
        session->lex->current_select->between_count)*m+1);
1620
1621
  if (!(key_fields=(KEY_FIELD*) session->alloc(sz)))
1754
1755
      if (map == 1)                     // Only one table
1755
1756
      {
1756
1757
        Table *tmp_table=join->all_tables[tablenr];
1757
 
        keyuse->ref_table_rows= cmax(tmp_table->file->stats.records, (ha_rows)100);
 
1758
        keyuse->ref_table_rows= max(tmp_table->file->stats.records, (ha_rows)100);
1758
1759
      }
1759
1760
    }
1760
1761
    /*
1952
1953
  if (blobs)
1953
1954
  {
1954
1955
    uint32_t blob_length=(uint32_t) (join_tab->table->file->stats.mean_rec_length-
1955
 
                             (join_tab->table->getRecordLength()- rec_length));
1956
 
    rec_length+=(uint32_t) cmax((uint32_t)4,blob_length);
 
1956
                                     (join_tab->table->getRecordLength()- rec_length));
 
1957
    rec_length+= max((uint32_t)4,blob_length);
1957
1958
  }
1958
1959
  join_tab->used_fields= fields;
1959
1960
  join_tab->used_fieldlength= rec_length;
6218
6219
            index entry.
6219
6220
          */
6220
6221
          index_scan_time= select_limit/rec_per_key *
6221
 
                           cmin(rec_per_key, table->file->scan_time());
 
6222
                           min(rec_per_key, table->file->scan_time());
6222
6223
          if (is_covering || (ref_key < 0 && (group || table->force_index)) ||
6223
6224
              index_scan_time < read_time)
6224
6225
          {
6228
6229
            if (table->quick_keys.test(nr))
6229
6230
              quick_records= table->quick_rows[nr];
6230
6231
            if (best_key < 0 ||
6231
 
                (select_limit <= cmin(quick_records,best_records) ?
 
6232
                (select_limit <= min(quick_records,best_records) ?
6232
6233
                 keyinfo->key_parts < best_key_parts :
6233
6234
                 quick_records < best_records))
6234
6235
            {
6695
6696
    count++;
6696
6697
  if (!sortorder)
6697
6698
    sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
6698
 
                                       (cmax(count, *length) + 1));
 
6699
                                       (max(count, *length) + 1));
6699
6700
  pos= sort= sortorder;
6700
6701
 
6701
6702
  if (!pos)