~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.cc

  • Committer: Brian Aker
  • Date: 2011-01-17 06:41:24 UTC
  • mfrom: (2087.4.2 drizzle)
  • mto: This revision was merged to the branch mainline in revision 2089.
  • Revision ID: brian@gir-3-20110117064124-cytq2o0d5h5c6fi2
Merge in identifier naming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
}
102
102
 
103
103
 
104
 
int StorageEngine::renameTable(Session &session, const TableIdentifier &from, const TableIdentifier &to)
 
104
int StorageEngine::renameTable(Session &session, const identifier::Table &from, const identifier::Table &to)
105
105
{
106
106
  int error;
107
107
  setTransactionReadWrite(session);
137
137
  @retval
138
138
    !0  Error
139
139
*/
140
 
int StorageEngine::doDropTable(Session&, const TableIdentifier &identifier)
 
140
int StorageEngine::doDropTable(Session&, const identifier::Table &identifier)
141
141
                               
142
142
{
143
143
  int error= 0;
287
287
class StorageEngineGetTableDefinition: public std::unary_function<StorageEngine *,bool>
288
288
{
289
289
  Session& session;
290
 
  const TableIdentifier &identifier;
 
290
  const identifier::Table &identifier;
291
291
  message::Table &table_message;
292
292
  drizzled::error_t &err;
293
293
 
294
294
public:
295
295
  StorageEngineGetTableDefinition(Session& session_arg,
296
 
                                  const TableIdentifier &identifier_arg,
 
296
                                  const identifier::Table &identifier_arg,
297
297
                                  message::Table &table_message_arg,
298
298
                                  drizzled::error_t &err_arg) :
299
299
    session(session_arg), 
315
315
class StorageEngineDoesTableExist: public std::unary_function<StorageEngine *, bool>
316
316
{
317
317
  Session& session;
318
 
  const TableIdentifier &identifier;
 
318
  const identifier::Table &identifier;
319
319
 
320
320
public:
321
 
  StorageEngineDoesTableExist(Session& session_arg, const TableIdentifier &identifier_arg) :
 
321
  StorageEngineDoesTableExist(Session& session_arg, const identifier::Table &identifier_arg) :
322
322
    session(session_arg), 
323
323
    identifier(identifier_arg) 
324
324
  { }
333
333
  Utility method which hides some of the details of getTableDefinition()
334
334
*/
335
335
bool plugin::StorageEngine::doesTableExist(Session &session,
336
 
                                           const TableIdentifier &identifier,
 
336
                                           const identifier::Table &identifier,
337
337
                                           bool include_temporary_tables)
338
338
{
339
339
  if (include_temporary_tables)
354
354
  return true;
355
355
}
356
356
 
357
 
bool plugin::StorageEngine::doDoesTableExist(Session&, const drizzled::TableIdentifier&)
 
357
bool plugin::StorageEngine::doDoesTableExist(Session&, const drizzled::identifier::Table&)
358
358
{
359
359
  std::cerr << " Engine was called for doDoesTableExist() and does not implement it: " << this->getName() << "\n";
360
360
  assert(0);
367
367
  or any dropped tables that need to be removed from disk
368
368
*/
369
369
int StorageEngine::getTableDefinition(Session& session,
370
 
                                      const TableIdentifier &identifier,
 
370
                                      const identifier::Table &identifier,
371
371
                                      message::table::shared_ptr &table_message,
372
372
                                      bool include_temporary_tables)
373
373
{
406
406
}
407
407
 
408
408
message::table::shared_ptr StorageEngine::getTableMessage(Session& session,
409
 
                                                          TableIdentifier::const_reference identifier,
 
409
                                                          identifier::Table::const_reference identifier,
410
410
                                                          drizzled::error_t &error,
411
411
                                                          bool include_temporary_tables)
412
412
{
478
478
class DropTableByIdentifier: public std::unary_function<EngineVector::value_type, bool>
479
479
{
480
480
  Session::reference session;
481
 
  TableIdentifier::const_reference identifier;
 
481
  identifier::Table::const_reference identifier;
482
482
  drizzled::error_t &error;
483
483
 
484
484
public:
485
485
 
486
486
  DropTableByIdentifier(Session::reference session_arg,
487
 
                        TableIdentifier::const_reference identifier_arg,
 
487
                        identifier::Table::const_reference identifier_arg,
488
488
                        drizzled::error_t &error_arg) :
489
489
    session(session_arg),
490
490
    identifier(identifier_arg),
518
518
 
519
519
 
520
520
bool StorageEngine::dropTable(Session::reference session,
521
 
                              TableIdentifier::const_reference identifier,
 
521
                              identifier::Table::const_reference identifier,
522
522
                              drizzled::error_t &error)
523
523
{
524
524
  error= EE_OK;
542
542
}
543
543
 
544
544
bool StorageEngine::dropTable(Session& session,
545
 
                              const TableIdentifier &identifier)
 
545
                              const identifier::Table &identifier)
546
546
{
547
547
  drizzled::error_t error;
548
548
 
556
556
 
557
557
bool StorageEngine::dropTable(Session::reference session,
558
558
                              StorageEngine &engine,
559
 
                              TableIdentifier::const_reference identifier,
 
559
                              identifier::Table::const_reference identifier,
560
560
                              drizzled::error_t &error)
561
561
{
562
562
  error= EE_OK;
598
598
   1  error
599
599
*/
600
600
bool StorageEngine::createTable(Session &session,
601
 
                                const TableIdentifier &identifier,
 
601
                                const identifier::Table &identifier,
602
602
                                message::Table& table_message)
603
603
{
604
604
  drizzled::error_t error= EE_OK;
665
665
  public std::unary_function<StorageEngine *, void>
666
666
{
667
667
  CachedDirectory &directory;
668
 
  const SchemaIdentifier &identifier;
669
 
  TableIdentifier::vector &set_of_identifiers;
 
668
  const identifier::Schema &identifier;
 
669
  identifier::Table::vector &set_of_identifiers;
670
670
 
671
671
public:
672
672
 
673
 
  AddTableIdentifier(CachedDirectory &directory_arg, const SchemaIdentifier &identifier_arg, TableIdentifier::vector &of_names) :
 
673
  AddTableIdentifier(CachedDirectory &directory_arg, const identifier::Schema &identifier_arg, identifier::Table::vector &of_names) :
674
674
    directory(directory_arg),
675
675
    identifier(identifier_arg),
676
676
    set_of_identifiers(of_names)
684
684
};
685
685
 
686
686
 
687
 
void StorageEngine::getIdentifiers(Session &session, const SchemaIdentifier &schema_identifier, TableIdentifier::vector &set_of_identifiers)
 
687
void StorageEngine::getIdentifiers(Session &session, const identifier::Schema &schema_identifier, identifier::Table::vector &set_of_identifiers)
688
688
{
689
 
  static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("information_schema");
690
 
  static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("data_dictionary");
 
689
  static identifier::Schema INFORMATION_SCHEMA_IDENTIFIER("information_schema");
 
690
  static identifier::Schema DATA_DICTIONARY_IDENTIFIER("data_dictionary");
691
691
 
692
692
  CachedDirectory directory(schema_identifier.getPath(), set_of_table_definition_ext);
693
693
 
721
721
  session.doGetTableIdentifiers(directory, schema_identifier, set_of_identifiers);
722
722
}
723
723
 
724
 
class DropTable: public std::unary_function<TableIdentifier&, bool>
 
724
class DropTable: public std::unary_function<identifier::Table&, bool>
725
725
{
726
726
  Session &session;
727
727
  StorageEngine *engine;
739
739
  } 
740
740
};
741
741
 
742
 
/* This will later be converted to TableIdentifiers */
 
742
/* This will later be converted to identifier::Tables */
743
743
class DropTables: public std::unary_function<StorageEngine *, void>
744
744
{
745
745
  Session &session;
746
 
  TableIdentifier::vector &table_identifiers;
 
746
  identifier::Table::vector &table_identifiers;
747
747
 
748
748
public:
749
749
 
750
 
  DropTables(Session &session_arg, TableIdentifier::vector &table_identifiers_arg) :
 
750
  DropTables(Session &session_arg, identifier::Table::vector &table_identifiers_arg) :
751
751
    session(session_arg),
752
752
    table_identifiers(table_identifiers_arg)
753
753
  { }
771
771
void StorageEngine::removeLostTemporaryTables(Session &session, const char *directory)
772
772
{
773
773
  CachedDirectory dir(directory, set_of_table_definition_ext);
774
 
  TableIdentifier::vector table_identifiers;
 
774
  identifier::Table::vector table_identifiers;
775
775
 
776
776
  if (dir.fail())
777
777
  {
800
800
    message::Table definition;
801
801
    if (StorageEngine::readTableFile(path, definition))
802
802
    {
803
 
      TableIdentifier identifier(definition.schema(), definition.name(), path);
 
803
      identifier::Table identifier(definition.schema(), definition.name(), path);
804
804
      table_identifiers.push_back(identifier);
805
805
    }
806
806
  }
1086
1086
}
1087
1087
 
1088
1088
 
1089
 
int StorageEngine::deleteDefinitionFromPath(const TableIdentifier &identifier)
 
1089
int StorageEngine::deleteDefinitionFromPath(const identifier::Table &identifier)
1090
1090
{
1091
1091
  std::string path(identifier.getPath());
1092
1092
 
1095
1095
  return internal::my_delete(path.c_str(), MYF(0));
1096
1096
}
1097
1097
 
1098
 
int StorageEngine::renameDefinitionFromPath(const TableIdentifier &dest, const TableIdentifier &src)
 
1098
int StorageEngine::renameDefinitionFromPath(const identifier::Table &dest, const identifier::Table &src)
1099
1099
{
1100
1100
  message::Table table_message;
1101
1101
  std::string src_path(src.getPath());
1124
1124
  return error;
1125
1125
}
1126
1126
 
1127
 
int StorageEngine::writeDefinitionFromPath(const TableIdentifier &identifier, message::Table &table_message)
 
1127
int StorageEngine::writeDefinitionFromPath(const identifier::Table &identifier, message::Table &table_message)
1128
1128
{
1129
1129
  char definition_file_tmp[FN_REFLEN];
1130
1130
  std::string file_name(identifier.getPath());
1203
1203
 
1204
1204
class CanCreateTable: public std::unary_function<StorageEngine *, bool>
1205
1205
{
1206
 
  const TableIdentifier &identifier;
 
1206
  const identifier::Table &identifier;
1207
1207
 
1208
1208
public:
1209
 
  CanCreateTable(const TableIdentifier &identifier_arg) :
 
1209
  CanCreateTable(const identifier::Table &identifier_arg) :
1210
1210
    identifier(identifier_arg)
1211
1211
  { }
1212
1212
 
1220
1220
/**
1221
1221
  @note on success table can be created.
1222
1222
*/
1223
 
bool StorageEngine::canCreateTable(const TableIdentifier &identifier)
 
1223
bool StorageEngine::canCreateTable(const identifier::Table &identifier)
1224
1224
{
1225
1225
  EngineVector::iterator iter=
1226
1226
    std::find_if(vector_of_engines.begin(), vector_of_engines.end(),