~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.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:
314
314
  for (int indx= 0; indx < table.indexes_size(); indx++)
315
315
    share->key_parts+= table.indexes(indx).index_part_size();
316
316
 
317
 
  share->key_info= (KEY*) alloc_root(&share->mem_root,
318
 
                                     table.indexes_size() * sizeof(KEY)
319
 
                                     +share->key_parts*sizeof(KEY_PART_INFO));
 
317
  share->key_info= (KEY*) share->mem_root.alloc_root( table.indexes_size() * sizeof(KEY) +share->key_parts*sizeof(KEY_PART_INFO));
320
318
 
321
319
  KEY_PART_INFO *key_part;
322
320
 
324
322
    (share->key_info+table.indexes_size());
325
323
 
326
324
 
327
 
  ulong *rec_per_key= (ulong*) alloc_root(&share->mem_root,
328
 
                                            sizeof(ulong*)*share->key_parts);
 
325
  ulong *rec_per_key= (ulong*) share->mem_root.alloc_root(sizeof(ulong*)*share->key_parts);
329
326
 
330
327
  share->keynames.count= table.indexes_size();
331
328
  share->keynames.name= NULL;
332
329
  share->keynames.type_names= (const char**)
333
 
    alloc_root(&share->mem_root, sizeof(char*) * (table.indexes_size()+1));
 
330
    share->mem_root.alloc_root(sizeof(char*) * (table.indexes_size()+1));
334
331
 
335
332
  share->keynames.type_lengths= (unsigned int*)
336
 
    alloc_root(&share->mem_root,
337
 
               sizeof(unsigned int) * (table.indexes_size()+1));
 
333
    share->mem_root.alloc_root(sizeof(unsigned int) * (table.indexes_size()+1));
338
334
 
339
335
  share->keynames.type_names[share->keynames.count]= NULL;
340
336
  share->keynames.type_lengths[share->keynames.count]= 0;
461
457
 
462
458
  share->fields= table.field_size();
463
459
 
464
 
  share->field= (Field**) alloc_root(&share->mem_root,
465
 
                                     ((share->fields+1) * sizeof(Field*)));
 
460
  share->field= (Field**) share->mem_root.alloc_root(((share->fields+1) * sizeof(Field*)));
466
461
  share->field[share->fields]= NULL;
467
462
 
468
463
  uint32_t null_fields= 0;
558
553
 
559
554
  unsigned char* record= NULL;
560
555
 
561
 
  if (! (record= (unsigned char *) alloc_root(&share->mem_root,
562
 
                                              rec_buff_length)))
 
556
  if (! (record= (unsigned char *) share->mem_root.alloc_root(rec_buff_length)))
563
557
    abort();
564
558
 
565
559
  memset(record, 0, rec_buff_length);
576
570
 
577
571
  if (interval_count)
578
572
  {
579
 
    share->intervals= (TYPELIB *) alloc_root(&share->mem_root,
580
 
                                           interval_count*sizeof(TYPELIB));
 
573
    share->intervals= (TYPELIB *) share->mem_root.alloc_root(interval_count*sizeof(TYPELIB));
581
574
  }
582
575
  else
583
576
    share->intervals= NULL;
584
577
 
585
 
  share->fieldnames.type_names= (const char **) alloc_root(&share->mem_root,
586
 
                                                          (share->fields + 1) * sizeof(char*));
 
578
  share->fieldnames.type_names= (const char **) share->mem_root.alloc_root((share->fields + 1) * sizeof(char*));
587
579
 
588
 
  share->fieldnames.type_lengths= (unsigned int *) alloc_root(&share->mem_root,
589
 
                                                             (share->fields + 1) * sizeof(unsigned int));
 
580
  share->fieldnames.type_lengths= (unsigned int *) share->mem_root.alloc_root((share->fields + 1) * sizeof(unsigned int));
590
581
 
591
582
  share->fieldnames.type_names[share->fields]= NULL;
592
583
  share->fieldnames.type_lengths[share->fields]= 0;
624
615
 
625
616
    TYPELIB *t= &(share->intervals[interval_nr]);
626
617
 
627
 
    t->type_names= (const char**)alloc_root(&share->mem_root,
628
 
                                            (field_options.field_value_size() + 1) * sizeof(char*));
 
618
    t->type_names= (const char**)share->mem_root.alloc_root((field_options.field_value_size() + 1) * sizeof(char*));
629
619
 
630
 
    t->type_lengths= (unsigned int*) alloc_root(&share->mem_root,
631
 
                                                (field_options.field_value_size() + 1) * sizeof(unsigned int));
 
620
    t->type_lengths= (unsigned int*) share->mem_root.alloc_root((field_options.field_value_size() + 1) * sizeof(unsigned int));
632
621
 
633
622
    t->type_names[field_options.field_value_size()]= NULL;
634
623
    t->type_lengths[field_options.field_value_size()]= 0;
1177
1166
 
1178
1167
    /* Store offsets to blob fields to find them fast */
1179
1168
    if (!(share->blob_field= save=
1180
 
          (uint*) alloc_root(&share->mem_root,
1181
 
                             (uint32_t) (share->blob_fields* sizeof(uint32_t)))))
 
1169
          (uint*) share->mem_root.alloc_root((uint32_t) (share->blob_fields* sizeof(uint32_t)))))
1182
1170
      goto err;
1183
1171
    for (k= 0, ptr= share->field ; *ptr ; ptr++, k++)
1184
1172
    {
1192
1180
 
1193
1181
  my_bitmap_map *bitmaps;
1194
1182
 
1195
 
  if (!(bitmaps= (my_bitmap_map*) alloc_root(&share->mem_root,
1196
 
                                             share->column_bitmap_size)))
 
1183
  if (!(bitmaps= (my_bitmap_map*) share->mem_root.alloc_root(share->column_bitmap_size)))
1197
1184
    goto err;
1198
1185
  share->all_set.init(bitmaps, share->fields);
1199
1186
  share->all_set.setAll();
1338
1325
 
1339
1326
  records++;
1340
1327
 
1341
 
  if (!(record= (unsigned char*) alloc_root(&outparam->mem_root,
1342
 
                                   share->rec_buff_length * records)))
 
1328
  if (!(record= (unsigned char*) outparam->mem_root.alloc_root(share->rec_buff_length * records)))
1343
1329
    goto err;
1344
1330
 
1345
1331
  if (records == 0)
1371
1357
  }
1372
1358
#endif
1373
1359
 
1374
 
  if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
1375
 
                                          (uint32_t) ((share->fields+1)*
1376
 
                                                  sizeof(Field*)))))
 
1360
  if (!(field_ptr = (Field **) outparam->mem_root.alloc_root( (uint32_t) ((share->fields+1)* sizeof(Field*)))))
 
1361
  {
1377
1362
    goto err;
 
1363
  }
1378
1364
 
1379
1365
  outparam->field= field_ptr;
1380
1366
 
1404
1390
    KEY_PART_INFO *key_part;
1405
1391
    uint32_t n_length;
1406
1392
    n_length= share->keys*sizeof(KEY) + share->key_parts*sizeof(KEY_PART_INFO);
1407
 
    if (!(key_info= (KEY*) alloc_root(&outparam->mem_root, n_length)))
 
1393
    if (!(key_info= (KEY*) outparam->mem_root.alloc_root(n_length)))
1408
1394
      goto err;
1409
1395
    outparam->key_info= key_info;
1410
1396
    key_part= (reinterpret_cast<KEY_PART_INFO*> (key_info+share->keys));
1446
1432
  /* Allocate bitmaps */
1447
1433
 
1448
1434
  bitmap_size= share->column_bitmap_size;
1449
 
  if (!(bitmaps= (unsigned char*) alloc_root(&outparam->mem_root, bitmap_size*3)))
 
1435
  if (!(bitmaps= (unsigned char*) outparam->mem_root.alloc_root(bitmap_size*3)))
 
1436
  {
1450
1437
    goto err;
 
1438
  }
1451
1439
  outparam->def_read_set.init((my_bitmap_map*) bitmaps, share->fields);
1452
1440
  outparam->def_write_set.init((my_bitmap_map*) (bitmaps+bitmap_size), share->fields);
1453
1441
  outparam->tmp_set.init((my_bitmap_map*) (bitmaps+bitmap_size*2), share->fields);
1732
1720
 
1733
1721
TYPELIB *typelib(memory::Root *mem_root, List<String> &strings)
1734
1722
{
1735
 
  TYPELIB *result= (TYPELIB*) alloc_root(mem_root, sizeof(TYPELIB));
 
1723
  TYPELIB *result= (TYPELIB*) mem_root->alloc_root(sizeof(TYPELIB));
1736
1724
  if (!result)
1737
1725
    return 0;
1738
1726
  result->count= strings.elements;
1739
1727
  result->name= "";
1740
1728
  uint32_t nbytes= (sizeof(char*) + sizeof(uint32_t)) * (result->count + 1);
1741
1729
  
1742
 
  if (!(result->type_names= (const char**) alloc_root(mem_root, nbytes)))
 
1730
  if (!(result->type_names= (const char**) mem_root->alloc_root(nbytes)))
1743
1731
    return 0;
1744
1732
    
1745
1733
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
2655
2643
    uint32_t alloc_length=ALIGN_SIZE(reclength+MI_UNIQUE_HASH_LENGTH+1);
2656
2644
    share->rec_buff_length= alloc_length;
2657
2645
    if (!(table->record[0]= (unsigned char*)
2658
 
                            alloc_root(&table->mem_root, alloc_length*3)))
 
2646
                            table->mem_root.alloc_root(alloc_length*3)))
 
2647
    {
2659
2648
      goto err;
 
2649
    }
2660
2650
    table->record[1]= table->record[0]+alloc_length;
2661
2651
    share->default_values= table->record[1]+alloc_length;
2662
2652
  }
2873
2863
    table->distinct= 1;
2874
2864
    share->keys= 1;
2875
2865
    if (!(key_part_info= (KEY_PART_INFO*)
2876
 
          alloc_root(&table->mem_root,
2877
 
                     keyinfo->key_parts * sizeof(KEY_PART_INFO))))
 
2866
         table->mem_root.alloc_root(keyinfo->key_parts * sizeof(KEY_PART_INFO))))
2878
2867
      goto err;
2879
2868
    memset(key_part_info, 0, keyinfo->key_parts * sizeof(KEY_PART_INFO));
2880
2869
    table->key_info=keyinfo;
3157
3146
  if (share->keys)
3158
3147
  {                                             // Get keys for ni_create
3159
3148
    bool using_unique_constraint= false;
3160
 
    HA_KEYSEG *seg= (HA_KEYSEG*) alloc_root(&this->mem_root,
3161
 
                                            sizeof(*seg) * keyinfo->key_parts);
 
3149
    HA_KEYSEG *seg= (HA_KEYSEG*) this->mem_root.alloc_root(sizeof(*seg) * keyinfo->key_parts);
3162
3150
    if (!seg)
3163
3151
      goto err;
3164
3152
 
3650
3638
  uint32_t key_length;
3651
3639
  TableShare *share= s;
3652
3640
 
3653
 
  if (not (key=(char*) alloc_root(&share->mem_root, MAX_DBKEY_LENGTH)))
 
3641
  if (not (key=(char*) share->mem_root.alloc_root(MAX_DBKEY_LENGTH)))
3654
3642
    return true;
3655
3643
 
3656
3644
  key_length= TableShare::createKey(key, identifier);