~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/singular.cc

  • Committer: Olaf van der Spek
  • Date: 2011-03-22 00:06:56 UTC
  • mto: (2245.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2246.
  • Revision ID: olafvdspek@gmail.com-20110322000656-32opecu17jlf2bd8
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
namespace drizzled {
34
34
namespace table {
35
35
 
36
 
Singular::Singular(Session *session, List<CreateField> &field_list) :
 
36
Singular::Singular(Session *session, std::list<CreateField>& field_list) :
37
37
  _share(message::Table::INTERNAL),
38
38
  _has_variable_width(false)
39
39
{
40
40
  uint32_t field_count= field_list.size();
41
41
  uint32_t blob_count= 0;
42
 
  Field **field_arg;
43
 
  CreateField *cdef;                           /* column definition */
44
42
  uint32_t record_length= 0;
45
43
  uint32_t null_count= 0;                 /* number of columns which may be null */
46
44
  uint32_t null_pack_length;              /* NULL representation array length */
47
45
 
48
46
  getMutableShare()->setFields(field_count + 1);
49
47
  setFields(getMutableShare()->getFields(true));
50
 
  field_arg= getMutableShare()->getFields(true);
 
48
  Field** field_arg= getMutableShare()->getFields(true);
51
49
  getMutableShare()->blob_field.resize(field_count+1);
52
50
  getMutableShare()->setFieldSize(field_count);
53
51
  getMutableShare()->blob_ptr_size= portable_sizeof_char_ptr;
56
54
  in_use= session;           /* field_arg->reset() may access in_use */
57
55
 
58
56
  /* Create all fields and calculate the total length of record */
59
 
  List<CreateField>::iterator it(field_list.begin());
60
57
  message::Table::Field null_field;
61
 
  while ((cdef= it++))
 
58
        BOOST_FOREACH(CreateField& it, field_list)
62
59
  {
63
60
    *field_arg= getMutableShare()->make_field(null_field,
64
61
                                              NULL,
65
 
                                              cdef->length,
66
 
                                              (cdef->flags & NOT_NULL_FLAG) ? false : true,
67
 
                                              (unsigned char *) ((cdef->flags & NOT_NULL_FLAG) ? 0 : ""),
68
 
                                              (cdef->flags & NOT_NULL_FLAG) ? 0 : 1,
69
 
                                              cdef->decimals,
70
 
                                              cdef->sql_type,
71
 
                                              cdef->charset,
72
 
                                              cdef->unireg_check,
73
 
                                              cdef->interval,
74
 
                                              cdef->field_name,
75
 
                                              cdef->flags & UNSIGNED_FLAG ? true : false);
76
 
    if (!*field_arg)
77
 
    {
78
 
      throw "Memory allocation failure";
79
 
    }
80
 
 
 
62
                                              it.length,
 
63
                                              (it.flags & NOT_NULL_FLAG) ? false : true,
 
64
                                              (unsigned char *) ((it.flags & NOT_NULL_FLAG) ? 0 : ""),
 
65
                                              (it.flags & NOT_NULL_FLAG) ? 0 : 1,
 
66
                                              it.decimals,
 
67
                                              it.sql_type,
 
68
                                              it.charset,
 
69
                                              it.unireg_check,
 
70
                                              it.interval,
 
71
                                              it.field_name,
 
72
                                              it.flags & UNSIGNED_FLAG ? true : false);
81
73
    (*field_arg)->init(this);
82
74
    record_length+= (*field_arg)->pack_length();
83
75
    if (! ((*field_arg)->flags & NOT_NULL_FLAG))
307
299
 
308
300
Singular::~Singular()
309
301
{
310
 
  const char *save_proc_info;
311
 
 
312
 
  save_proc_info= in_use->get_proc_info();
 
302
  const char* save_proc_info= in_use->get_proc_info();
313
303
  in_use->set_proc_info("removing tmp table");
314
304
 
315
305
  // Release latches since this can take a long time