~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
  return (unsigned char*) (*buff)->field_name;
65
65
}
66
66
 
67
 
 
68
 
/*
69
 
  Returns pointer to '.frm' extension of the file name.
70
 
 
71
 
  SYNOPSIS
72
 
    fn_rext()
73
 
    name       file name
74
 
 
75
 
  DESCRIPTION
76
 
    Checks file name part starting with the rightmost '.' character,
77
 
    and returns it if it is equal to '.dfe'.
78
 
 
79
 
  TODO
80
 
    It is a good idea to get rid of this function modifying the code
81
 
    to garantee that the functions presently calling fn_rext() always
82
 
    get arguments in the same format: either with '.frm' or without '.frm'.
83
 
 
84
 
  RETURN VALUES
85
 
    Pointer to the '.frm' extension. If there is no extension,
86
 
    or extension is not '.frm', pointer at the end of file name.
87
 
*/
88
 
 
89
 
char *fn_rext(char *name)
90
 
{
91
 
  char *res= strrchr(name, '.');
92
 
  if (res && !strcmp(res, ".dfe"))
93
 
    return res;
94
 
  return name + strlen(name);
95
 
}
96
 
 
97
67
static TABLE_CATEGORY get_table_category(const LEX_STRING *db)
98
68
{
99
69
  assert(db != NULL);
200
170
    field_type= DRIZZLE_TYPE_BLOB;
201
171
    break;
202
172
  default:
203
 
    field_type= DRIZZLE_TYPE_TINY; /* Set value to kill GCC warning */
 
173
    field_type= DRIZZLE_TYPE_LONG; /* Set value to kill GCC warning */
204
174
    assert(1);
205
175
  }
206
176
 
222
192
 
223
193
  switch(field_type)
224
194
  {
225
 
  case DRIZZLE_TYPE_TINY:
226
195
  case DRIZZLE_TYPE_LONG:
227
196
  case DRIZZLE_TYPE_LONGLONG:
228
197
    default_item= new Item_int(default_value->c_str(),
272
241
  return default_item;
273
242
}
274
243
 
275
 
int drizzled::parse_table_proto(Session *session,
 
244
int drizzled::parse_table_proto(Session& session,
276
245
                                message::Table &table,
277
246
                                TableShare *share)
278
247
{
282
251
  share->setTableProto(new(nothrow) message::Table(table));
283
252
 
284
253
  share->storage_engine= plugin::StorageEngine::findByName(session, table.engine().name());
 
254
  assert(share->storage_engine); // We use an assert() here because we should never get this far and still have no suitable engine.
285
255
 
286
256
  message::Table::TableOptions table_options;
287
257
 
493
463
  share->keys_for_keyread.reset();
494
464
  set_prefix(share->keys_in_use, share->keys);
495
465
 
496
 
  share->key_block_size= table_options.has_key_block_size() ?
497
 
    table_options.key_block_size() : 0;
498
 
 
499
466
  share->fields= table.field_size();
500
467
 
501
468
  share->field= (Field**) alloc_root(&share->mem_root,
849
816
    Table temp_table; /* Use this so that BLOB DEFAULT '' works */
850
817
    memset(&temp_table, 0, sizeof(temp_table));
851
818
    temp_table.s= share;
852
 
    temp_table.in_use= session;
 
819
    temp_table.in_use= &session;
853
820
    temp_table.s->db_low_byte_first= 1; //Cursor->low_byte_first();
854
821
    temp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
855
822
 
883
850
 
884
851
    if (default_value)
885
852
    {
886
 
      enum_check_fields old_count_cuted_fields= session->count_cuted_fields;
887
 
      session->count_cuted_fields= CHECK_FIELD_WARN;
 
853
      enum_check_fields old_count_cuted_fields= session.count_cuted_fields;
 
854
      session.count_cuted_fields= CHECK_FIELD_WARN;
888
855
      int res= default_value->save_in_field(f, 1);
889
 
      session->count_cuted_fields= old_count_cuted_fields;
 
856
      session.count_cuted_fields= old_count_cuted_fields;
890
857
      if (res != 0 && res != 3) /* @TODO Huh? */
891
858
      {
892
859
        my_error(ER_INVALID_DEFAULT, MYF(0), f->field_name);
962
929
  free(field_offsets);
963
930
  free(field_pack_length);
964
931
 
965
 
  if (! (handler_file= share->db_type()->getCursor(share, session->mem_root)))
 
932
  if (! (handler_file= share->db_type()->getCursor(share, session.mem_root)))
966
933
    abort(); // FIXME
967
934
 
968
935
  /* Fix key stuff */
1194
1161
   6    Unknown .frm version
1195
1162
*/
1196
1163
 
1197
 
int open_table_def(Session *session, TableShare *share)
 
1164
int open_table_def(Session& session, TableShare *share)
1198
1165
{
1199
1166
  int error;
1200
1167
  bool error_given;
1204
1171
 
1205
1172
  message::Table table;
1206
1173
 
1207
 
  error= plugin::StorageEngine::getTableProto(share->normalized_path.str,
1208
 
                                              &table);
 
1174
  error= plugin::StorageEngine::getTableDefinition(session, share->normalized_path.str,
 
1175
                                                   share->db.str,
 
1176
                                                   share->table_name.str,
 
1177
                                                   false,
 
1178
                                                   &table);
1209
1179
 
1210
1180
  if (error != EEXIST)
1211
1181
  {
1229
1199
  share->table_category= get_table_category(& share->db);
1230
1200
 
1231
1201
  if (!error)
1232
 
    session->status_var.opened_shares++;
 
1202
    session.status_var.opened_shares++;
1233
1203
 
1234
1204
err_not_open:
1235
1205
  if (error && !error_given)
3235
3205
    if (db_stat)
3236
3206
      file->closeMarkForDelete(s->table_name.str);
3237
3207
 
3238
 
    s->db_type()->doDeleteTable(session, s->table_name.str);
 
3208
    s->db_type()->doDropTable(*session, s->table_name.str);
3239
3209
 
3240
3210
    delete file;
3241
3211
  }
3347
3317
  (void) table->file->ha_rnd_end();
3348
3318
  (void) new_table.file->close();
3349
3319
 err1:
3350
 
  new_table.s->db_type()->doDeleteTable(session, new_table.s->table_name.str);
 
3320
  new_table.s->db_type()->doDropTable(*session, new_table.s->table_name.str);
3351
3321
 err2:
3352
3322
  delete new_table.file;
3353
3323
  session->set_proc_info(save_proc_info);