~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Olaf van der Spek
  • Date: 2011-06-22 14:19:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2347.
  • Revision ID: olafvdspek@gmail.com-20110622141944-na0vb0uv30n6u55z
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
208
208
 
209
209
TYPELIB *typelib(memory::Root *mem_root, List<String> &strings)
210
210
{
211
 
  TYPELIB *result= (TYPELIB*) mem_root->alloc_root(sizeof(TYPELIB));
212
 
  if (!result)
213
 
    return 0;
 
211
  TYPELIB *result= (TYPELIB*) mem_root->alloc(sizeof(TYPELIB));
214
212
  result->count= strings.size();
215
213
  result->name= "";
216
214
  uint32_t nbytes= (sizeof(char*) + sizeof(uint32_t)) * (result->count + 1);
217
215
  
218
 
  if (!(result->type_names= (const char**) mem_root->alloc_root(nbytes)))
219
 
    return 0;
220
 
    
 
216
  result->type_names= (const char**) mem_root->alloc_root(nbytes);
221
217
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
222
218
 
223
219
  List<String>::iterator it(strings.begin());
798
794
 
799
795
  table::Singular* table= &session->getInstanceTable(); // This will not go into the tableshare cache, so no key is used.
800
796
 
801
 
  if (not table->getMemRoot()->multi_alloc_root(0,
802
 
                                                &default_field, sizeof(Field*) * (field_count),
803
 
                                                &from_field, sizeof(Field*)*field_count,
804
 
                                                &copy_func, sizeof(*copy_func)*(copy_func_count+1),
805
 
                                                &param->keyinfo, sizeof(*param->keyinfo),
806
 
                                                &key_part_info, sizeof(*key_part_info)*(param->group_parts+1),
807
 
                                                &param->start_recinfo, sizeof(*param->recinfo)*(field_count*2+4),
808
 
                                                &group_buff, (group && ! using_unique_constraint ?
809
 
                                                              param->group_length : 0),
810
 
                                                NULL))
811
 
  {
812
 
    return NULL;
813
 
  }
 
797
  table->getMemRoot()->multi_alloc_root(0,
 
798
    &default_field, sizeof(Field*) * (field_count),
 
799
    &from_field, sizeof(Field*)*field_count,
 
800
    &copy_func, sizeof(*copy_func)*(copy_func_count+1),
 
801
    &param->keyinfo, sizeof(*param->keyinfo),
 
802
    &key_part_info, sizeof(*key_part_info)*(param->group_parts+1),
 
803
    &param->start_recinfo, sizeof(*param->recinfo)*(field_count*2+4),
 
804
    &group_buff, (group && ! using_unique_constraint ? param->group_length : 0),
 
805
    NULL);
814
806
  /* CopyField belongs to Tmp_Table_Param, allocate it in Session mem_root */
815
807
  param->copy_field= copy= new (session->mem_root) CopyField[field_count];
816
808
  param->items_to_copy= copy_func;
1037
1029
  {
1038
1030
    uint32_t alloc_length=ALIGN_SIZE(reclength+MI_UNIQUE_HASH_LENGTH+1);
1039
1031
    table->getMutableShare()->rec_buff_length= alloc_length;
1040
 
    if (!(table->record[0]= (unsigned char*) table->alloc_root(alloc_length*2)))
1041
 
    {
1042
 
      goto err;
1043
 
    }
 
1032
    table->record[0]= (unsigned char*) table->alloc_root(alloc_length*2);
1044
1033
    table->record[1]= table->getInsertRecord()+alloc_length;
1045
1034
    table->getMutableShare()->resizeDefaultValues(alloc_length);
1046
1035
  }
1256
1245
                         (table->getMutableShare()->uniques ? test(null_pack_length) : 0));
1257
1246
    table->distinct= 1;
1258
1247
    table->getMutableShare()->keys= 1;
1259
 
    if (!(key_part_info= (KeyPartInfo*)
1260
 
         table->alloc_root(keyinfo->key_parts * sizeof(KeyPartInfo))))
1261
 
      goto err;
 
1248
    key_part_info= (KeyPartInfo*)table->alloc_root(keyinfo->key_parts * sizeof(KeyPartInfo));
1262
1249
    memset(key_part_info, 0, keyinfo->key_parts * sizeof(KeyPartInfo));
1263
1250
    table->key_info=keyinfo;
1264
1251
    keyinfo->key_part=key_part_info;