~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/range.cc

  • Committer: Brian Aker
  • Date: 2010-04-19 17:51:52 UTC
  • Revision ID: brian@gaz-20100419175152-lar9fncw9vhhav0d
Updates to confine memroot

Show diffs side-by-side

added added

removed removed

Lines of Context:
537
537
  uint32_t pk;
538
538
  param->tmp_covered_fields.setBitmap(0);
539
539
  param->fields_bitmap_size= table->s->column_bitmap_size;
540
 
  if (!(tmp= (my_bitmap_map*) alloc_root(param->mem_root,
541
 
                                  param->fields_bitmap_size)) ||
 
540
  if (!(tmp= (my_bitmap_map*) param->mem_root->alloc_root(param->fields_bitmap_size)) ||
542
541
      param->needed_fields.init(tmp, table->s->fields))
 
542
  {
543
543
    return 1;
 
544
  }
544
545
 
545
546
  param->needed_fields= *table->read_set;
546
547
  bitmap_union(&param->needed_fields, table->write_set);
681
682
 
682
683
    session->no_errors=1;                               // Don't warn about NULL
683
684
    memory::init_sql_alloc(&alloc, session->variables.range_alloc_block_size, 0);
684
 
    if (!(param.key_parts= (KEY_PART*) alloc_root(&alloc,
685
 
                                                  sizeof(KEY_PART)*
686
 
                                                  head->s->key_parts)) ||
 
685
    if (!(param.key_parts= (KEY_PART*) alloc.alloc_root( sizeof(KEY_PART) * head->s->key_parts)) ||
687
686
        fill_used_fields_bitmap(&param))
688
687
    {
689
688
      session->no_errors=0;
952
951
  ha_rows roru_total_records;
953
952
  double roru_intersect_part= 1.0;
954
953
 
955
 
  if (! (range_scans= (optimizer::RangeReadPlan**)alloc_root(param->mem_root,
956
 
                                                             sizeof(optimizer::RangeReadPlan*)*
957
 
                                                             n_child_scans)))
 
954
  if (! (range_scans= (optimizer::RangeReadPlan**)param->mem_root->alloc_root(sizeof(optimizer::RangeReadPlan*)* n_child_scans)))
 
955
  {
958
956
    return NULL;
 
957
  }
 
958
 
959
959
  /*
960
960
    Collect best 'range' scan for each of disjuncts, and, while doing so,
961
961
    analyze possibility of ROR scans. Also calculate some values needed by
1034
1034
                                    param->session->variables.sortbuff_size);
1035
1035
  if (param->imerge_cost_buff_size < unique_calc_buff_size)
1036
1036
  {
1037
 
    if (!(param->imerge_cost_buff= (uint*)alloc_root(param->mem_root,
1038
 
                                                     unique_calc_buff_size)))
 
1037
    if (!(param->imerge_cost_buff= (uint*)param->mem_root->alloc_root(unique_calc_buff_size)))
 
1038
    {
1039
1039
      return NULL;
 
1040
    }
 
1041
 
1040
1042
    param->imerge_cost_buff_size= unique_calc_buff_size;
1041
1043
  }
1042
1044
 
1065
1067
  /* Ok, it is possible to build a ROR-union, try it. */
1066
1068
  bool dummy;
1067
1069
  if (! (roru_read_plans=
1068
 
          (optimizer::TableReadPlan **) alloc_root(param->mem_root,
1069
 
                                                   sizeof(optimizer::TableReadPlan*)*
1070
 
                                                   n_child_scans)))
 
1070
          (optimizer::TableReadPlan **) param->mem_root->alloc_root(sizeof(optimizer::TableReadPlan*) * n_child_scans)))
 
1071
  {
1071
1072
    return imerge_trp;
 
1073
  }
1072
1074
skip_to_ror_scan:
1073
1075
  roru_index_costs= 0.0;
1074
1076
  roru_total_records= 0;
1208
1210
 
1209
1211
  uint32_t keynr;
1210
1212
 
1211
 
  if (!(ror_scan= (ROR_SCAN_INFO*)alloc_root(param->mem_root,
1212
 
                                             sizeof(ROR_SCAN_INFO))))
 
1213
  if (!(ror_scan= (ROR_SCAN_INFO*)param->mem_root->alloc_root(sizeof(ROR_SCAN_INFO))))
1213
1214
    return NULL;
1214
1215
 
1215
1216
  ror_scan->idx= idx;
1219
1220
  ror_scan->sel_arg= sel_arg;
1220
1221
  ror_scan->records= param->table->quick_rows[keynr];
1221
1222
 
1222
 
  if (!(bitmap_buf= (my_bitmap_map*) alloc_root(param->mem_root,
1223
 
                                                param->fields_bitmap_size)))
 
1223
  if (!(bitmap_buf= (my_bitmap_map*) param->mem_root->alloc_root(param->fields_bitmap_size)))
 
1224
  {
1224
1225
    return NULL;
 
1226
  }
1225
1227
 
1226
 
  if (ror_scan->covered_fields.init(bitmap_buf,
1227
 
                                    param->table->s->fields))
 
1228
  if (ror_scan->covered_fields.init(bitmap_buf, param->table->s->fields))
 
1229
  {
1228
1230
    return NULL;
 
1231
  }
1229
1232
  ror_scan->covered_fields.clearAll();
1230
1233
 
1231
1234
  KEY_PART_INFO *key_part= param->table->key_info[keynr].key_part;
1301
1304
{
1302
1305
  ROR_INTERSECT_INFO *info;
1303
1306
  my_bitmap_map* buf;
1304
 
  if (!(info= (ROR_INTERSECT_INFO*)alloc_root(param->mem_root,
1305
 
                                              sizeof(ROR_INTERSECT_INFO))))
 
1307
  if (!(info= (ROR_INTERSECT_INFO*)param->mem_root->alloc_root(sizeof(ROR_INTERSECT_INFO))))
1306
1308
    return NULL;
1307
1309
  info->param= param;
1308
 
  if (!(buf= (my_bitmap_map*) alloc_root(param->mem_root,
1309
 
                                         param->fields_bitmap_size)))
 
1310
  if (!(buf= (my_bitmap_map*) param->mem_root->alloc_root(param->fields_bitmap_size)))
1310
1311
    return NULL;
1311
1312
  if (info->covered_fields.init(buf, param->table->s->fields))
1312
1313
    return NULL;
1664
1665
  uint32_t cpk_no= 0;
1665
1666
  bool cpk_scan_used= false;
1666
1667
 
1667
 
  if (! (tree->ror_scans= (ROR_SCAN_INFO**)alloc_root(param->mem_root,
1668
 
                                                      sizeof(ROR_SCAN_INFO*)*
1669
 
                                                      param->keys)))
 
1668
  if (! (tree->ror_scans= (ROR_SCAN_INFO**)param->mem_root->alloc_root(sizeof(ROR_SCAN_INFO*)* param->keys)))
 
1669
  {
1670
1670
    return NULL;
 
1671
  }
1671
1672
  cpk_no= ((param->table->cursor->primary_key_is_clustered()) ?
1672
1673
           param->table->s->primary_key : MAX_KEY);
1673
1674
 
1698
1699
 
1699
1700
  ROR_SCAN_INFO **intersect_scans= NULL; /* ROR scans used in index intersection */
1700
1701
  ROR_SCAN_INFO **intersect_scans_end= NULL;
1701
 
  if (! (intersect_scans= (ROR_SCAN_INFO**)alloc_root(param->mem_root,
1702
 
                                                      sizeof(ROR_SCAN_INFO*)*
1703
 
                                                      tree->n_ror_scans)))
 
1702
  if (! (intersect_scans= (ROR_SCAN_INFO**)param->mem_root->alloc_root(sizeof(ROR_SCAN_INFO*) * tree->n_ror_scans)))
1704
1703
    return NULL;
1705
1704
  intersect_scans_end= intersect_scans;
1706
1705
 
2738
2737
    {
2739
2738
      if (unlikely(length < field_length))
2740
2739
      {
2741
 
        /*
2742
 
          This can only happen in a table created with UNIREG where one key
2743
 
          overlaps many fields
2744
 
        */
2745
 
        length= field_length;
 
2740
        /*
 
2741
          This can only happen in a table created with UNIREG where one key
 
2742
          overlaps many fields
 
2743
        */
 
2744
        length= field_length;
2746
2745
      }
2747
2746
      else
2748
 
        field_length= length;
 
2747
        field_length= length;
2749
2748
    }
2750
2749
    length+=offset;
2751
 
    if (!(min_str= (unsigned char*) alloc_root(alloc, length*2)))
 
2750
    if (!(min_str= (unsigned char*) alloc->alloc_root(length*2)))
 
2751
    {
2752
2752
      goto end;
 
2753
    }
2753
2754
 
2754
2755
    max_str=min_str+length;
2755
2756
    if (maybe_null)
2968
2969
    tree= &optimizer::null_element;                        // cmp with NULL is never true
2969
2970
    goto end;
2970
2971
  }
2971
 
  str= (unsigned char*) alloc_root(alloc, key_part->store_length+1);
 
2972
  str= (unsigned char*) alloc->alloc_root(key_part->store_length+1);
2972
2973
  if (!str)
2973
2974
    goto end;
2974
2975
  if (maybe_null)
4109
4110
 
4110
4111
 
4111
4112
  if (!(quick->key_parts=key_part=(KEY_PART *)
4112
 
        alloc_root(&quick->alloc,sizeof(KEY_PART)*ref->key_parts)))
 
4113
        quick->alloc.alloc_root(sizeof(KEY_PART)*ref->key_parts)))
4113
4114
    goto err;
4114
4115
 
4115
4116
  for (part=0 ; part < ref->key_parts ;part++,key_part++)