~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

MergeĀ fromĀ Nathan

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <drizzled/field/varstring.h>
33
33
#include <drizzled/field/double.h>
34
34
#include <string>
 
35
#include <vector>
35
36
 
36
37
#include <drizzled/unireg.h>
37
38
#include <drizzled/message/table.pb.h>
577
578
    field_offsets[fieldnr]= stored_columns_reclength;
578
579
 
579
580
    /* the below switch is very similar to
580
 
       Create_field::create_length_to_internal_length in field.cc
 
581
       CreateField::create_length_to_internal_length in field.cc
581
582
       (which should one day be replace by just this code)
582
583
    */
583
584
    switch(drizzle_field_type)
1651
1652
} /* open_table_error */
1652
1653
 
1653
1654
 
1654
 
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings)
 
1655
TYPELIB *typelib(MEM_ROOT *mem_root, vector<String*> &strings)
1655
1656
{
1656
1657
  TYPELIB *result= (TYPELIB*) alloc_root(mem_root, sizeof(TYPELIB));
1657
1658
  if (!result)
1658
1659
    return 0;
1659
 
  result->count=strings.elements;
1660
 
  result->name="";
 
1660
  result->count= strings.size();
 
1661
  result->name= "";
1661
1662
  uint32_t nbytes= (sizeof(char*) + sizeof(uint32_t)) * (result->count + 1);
 
1663
  
1662
1664
  if (!(result->type_names= (const char**) alloc_root(mem_root, nbytes)))
1663
1665
    return 0;
 
1666
    
1664
1667
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
1665
 
  List_iterator<String> it(strings);
1666
 
  String *tmp;
1667
 
  for (uint32_t i= 0; (tmp=it++) ; i++)
 
1668
 
 
1669
  vector<String*>::iterator it= strings.begin();
 
1670
  for (int i= 0; it != strings.end(); ++it, ++i )
1668
1671
  {
1669
 
    result->type_names[i]= tmp->ptr();
1670
 
    result->type_lengths[i]= tmp->length();
 
1672
    result->type_names[i]= (*it)->c_ptr();
 
1673
    result->type_lengths[i]= (*it)->length();
1671
1674
  }
1672
 
  result->type_names[result->count]= 0;         // End marker
 
1675
 
 
1676
  result->type_names[result->count]= 0;   // End marker
1673
1677
  result->type_lengths[result->count]= 0;
 
1678
 
1674
1679
  return result;
1675
1680
}
1676
1681
 
2333
2338
  unsigned char *null_flags;
2334
2339
  Field **reg_field, **from_field, **default_field;
2335
2340
  uint32_t *blob_field;
2336
 
  Copy_field *copy= 0;
 
2341
  CopyField *copy= 0;
2337
2342
  KEY *keyinfo;
2338
2343
  KEY_PART_INFO *key_part_info;
2339
2344
  Item **copy_func;
2412
2417
  {
2413
2418
    return NULL;                                /* purecov: inspected */
2414
2419
  }
2415
 
  /* Copy_field belongs to Tmp_Table_Param, allocate it in Session mem_root */
2416
 
  if (!(param->copy_field= copy= new (session->mem_root) Copy_field[field_count]))
 
2420
  /* CopyField belongs to Tmp_Table_Param, allocate it in Session mem_root */
 
2421
  if (!(param->copy_field= copy= new (session->mem_root) CopyField[field_count]))
2417
2422
  {
2418
2423
    free_root(&own_root, MYF(0));               /* purecov: inspected */
2419
2424
    return NULL;                                /* purecov: inspected */
2988
2993
    0 if out of memory, Table object in case of success
2989
2994
*/
2990
2995
 
2991
 
Table *create_virtual_tmp_table(Session *session, List<Create_field> &field_list)
 
2996
Table *create_virtual_tmp_table(Session *session, List<CreateField> &field_list)
2992
2997
{
2993
2998
  uint32_t field_count= field_list.elements;
2994
2999
  uint32_t blob_count= 0;
2995
3000
  Field **field;
2996
 
  Create_field *cdef;                           /* column definition */
 
3001
  CreateField *cdef;                           /* column definition */
2997
3002
  uint32_t record_length= 0;
2998
3003
  uint32_t null_count= 0;                 /* number of columns which may be null */
2999
3004
  uint32_t null_pack_length;              /* NULL representation array length */
3021
3026
  table->setup_tmp_table_column_bitmaps(bitmaps);
3022
3027
 
3023
3028
  /* Create all fields and calculate the total length of record */
3024
 
  List_iterator_fast<Create_field> it(field_list);
 
3029
  List_iterator_fast<CreateField> it(field_list);
3025
3030
  while ((cdef= it++))
3026
3031
  {
3027
3032
    *field= make_field(share, NULL, 0, cdef->length,