~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/instance.cc

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
namespace table
37
37
{
38
38
 
39
 
Singular::Singular(Session *session, List<CreateField> &field_list) :
 
39
Instance::Instance(Session *session, List<CreateField> &field_list) :
40
40
  _share(message::Table::INTERNAL),
41
41
  _has_variable_width(false)
42
42
{
52
52
  setFields(getMutableShare()->getFields(true));
53
53
  field_arg= getMutableShare()->getFields(true);
54
54
  getMutableShare()->blob_field.resize(field_count+1);
55
 
  getMutableShare()->setFieldSize(field_count);
 
55
  getMutableShare()->fields= field_count;
56
56
  getMutableShare()->blob_ptr_size= portable_sizeof_char_ptr;
57
57
  setup_tmp_table_column_bitmaps();
58
58
 
60
60
 
61
61
  /* Create all fields and calculate the total length of record */
62
62
  List_iterator_fast<CreateField> it(field_list);
63
 
  message::Table::Field null_field;
64
63
  while ((cdef= it++))
65
64
  {
66
 
    *field_arg= getMutableShare()->make_field(null_field,
67
 
                                              NULL,
68
 
                                              cdef->length,
69
 
                                              (cdef->flags & NOT_NULL_FLAG) ? false : true,
70
 
                                              (unsigned char *) ((cdef->flags & NOT_NULL_FLAG) ? 0 : ""),
71
 
                                              (cdef->flags & NOT_NULL_FLAG) ? 0 : 1,
72
 
                                              cdef->decimals,
73
 
                                              cdef->sql_type,
74
 
                                              cdef->charset,
75
 
                                              cdef->unireg_check,
76
 
                                              cdef->interval,
77
 
                                              cdef->field_name,
78
 
                                              cdef->flags & UNSIGNED_FLAG ? true : false);
 
65
    *field_arg= getMutableShare()->make_field(NULL,
 
66
                                                 cdef->length,
 
67
                                                 (cdef->flags & NOT_NULL_FLAG) ? false : true,
 
68
                                                 (unsigned char *) ((cdef->flags & NOT_NULL_FLAG) ? 0 : ""),
 
69
                                                 (cdef->flags & NOT_NULL_FLAG) ? 0 : 1,
 
70
                                                 cdef->decimals,
 
71
                                                 cdef->sql_type,
 
72
                                                 cdef->charset,
 
73
                                                 cdef->unireg_check,
 
74
                                                 cdef->interval,
 
75
                                                 cdef->field_name);
79
76
    if (!*field_arg)
80
77
    {
81
78
      throw "Memory allocation failure";
98
95
  null_pack_length= (null_count + 7)/8;
99
96
  getMutableShare()->setRecordLength(record_length + null_pack_length);
100
97
  getMutableShare()->rec_buff_length= ALIGN_SIZE(getMutableShare()->getRecordLength() + 1);
101
 
  record[0]= (unsigned char*)session->getMemRoot()->allocate(getMutableShare()->rec_buff_length);
 
98
  record[0]= (unsigned char*)session->alloc(getMutableShare()->rec_buff_length);
102
99
  if (not getInsertRecord())
103
100
  {
104
101
    throw "Memory allocation failure";
138
135
  }
139
136
}
140
137
 
141
 
bool Singular::open_tmp_table()
 
138
bool Instance::open_tmp_table()
142
139
{
143
140
  int error;
144
141
  
145
 
  identifier::Table identifier(getShare()->getSchemaName(), getShare()->getTableName(), getShare()->getPath());
 
142
  TableIdentifier identifier(getShare()->getSchemaName(), getShare()->getTableName(), getShare()->getPath());
146
143
  if ((error=cursor->ha_open(identifier,
147
144
                             O_RDWR,
148
145
                             HA_OPEN_TMP_TABLE | HA_OPEN_INTERNAL_TABLE)))
185
182
     true  - Error
186
183
*/
187
184
 
188
 
bool Singular::create_myisam_tmp_table(KeyInfo *keyinfo,
 
185
bool Instance::create_myisam_tmp_table(KeyInfo *keyinfo,
189
186
                                                 MI_COLUMNDEF *start_recinfo,
190
187
                                                 MI_COLUMNDEF **recinfo,
191
188
                                                 uint64_t options)
294
291
    a tmp_set bitmap to be used by things like filesort.
295
292
*/
296
293
 
297
 
void Singular::setup_tmp_table_column_bitmaps()
 
294
void Instance::setup_tmp_table_column_bitmaps()
298
295
{
299
296
  uint32_t field_count= getShare()->sizeFields();
300
297
 
308
305
  default_column_bitmaps();
309
306
}
310
307
 
311
 
Singular::~Singular()
 
308
Instance::~Instance()
312
309
{
313
310
  const char *save_proc_info;
314
311
 
325
322
      cursor->closeMarkForDelete(getShare()->getTableName());
326
323
    }
327
324
 
328
 
    identifier::Table identifier(getShare()->getSchemaName(), getShare()->getTableName(), getShare()->getTableName());
329
 
    drizzled::error_t ignored;
330
 
    plugin::StorageEngine::dropTable(*in_use,
331
 
                                     *getShare()->getEngine(),
332
 
                                     identifier,
333
 
                                     ignored);
 
325
    TableIdentifier identifier(getShare()->getSchemaName(), getShare()->getTableName(), getShare()->getTableName());
 
326
    getShare()->getEngine()->doDropTable(*in_use, identifier);
334
327
 
335
328
    delete cursor;
336
329
  }