~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/filesystem_engine/filesystem_engine.cc

  • Committer: Monty Taylor
  • Date: 2010-12-26 03:00:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101226030037-2qcfxg5ryamekd56
Cleaned through ha0ha.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 
87
87
  int doCreateTable(Session &,
88
88
                    Table &table_arg,
89
 
                    const drizzled::identifier::Table &identifier,
 
89
                    const drizzled::TableIdentifier &identifier,
90
90
                    drizzled::message::Table&);
91
91
 
92
92
  int doGetTableDefinition(Session& ,
93
 
                           const drizzled::identifier::Table &,
 
93
                           const drizzled::TableIdentifier &,
94
94
                           drizzled::message::Table &);
95
95
 
96
 
  int doDropTable(Session&, const identifier::Table &);
 
96
  int doDropTable(Session&, const TableIdentifier &);
97
97
 
98
98
  /* operations on FilesystemTableShare */
99
99
  FilesystemTableShare *findOpenTable(const string table_name);
103
103
  uint32_t max_keys()          const { return 0; }
104
104
  uint32_t max_key_parts()     const { return 0; }
105
105
  uint32_t max_key_length()    const { return 0; }
106
 
  bool doDoesTableExist(Session& , const identifier::Table &);
107
 
  int doRenameTable(Session&, const identifier::Table &, const identifier::Table &);
 
106
  bool doDoesTableExist(Session& , const TableIdentifier &);
 
107
  int doRenameTable(Session&, const TableIdentifier &, const TableIdentifier &);
108
108
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
109
 
                             const drizzled::identifier::Schema &schema_identifier,
110
 
                             drizzled::identifier::Table::vector &set_of_identifiers);
 
109
                             const drizzled::SchemaIdentifier &schema_identifier,
 
110
                             drizzled::TableIdentifier::vector &set_of_identifiers);
111
111
private:
112
112
  void getTableNamesFromFilesystem(drizzled::CachedDirectory &directory,
113
 
                                   const drizzled::identifier::Schema &schema_identifier,
 
113
                                   const drizzled::SchemaIdentifier &schema_identifier,
114
114
                                   drizzled::plugin::TableNameList *set_of_names,
115
 
                                   drizzled::identifier::Table::vector *set_of_identifiers);
 
115
                                   drizzled::TableIdentifier::vector *set_of_identifiers);
116
116
};
117
117
 
118
118
void FilesystemEngine::getTableNamesFromFilesystem(drizzled::CachedDirectory &directory,
119
 
                                                   const drizzled::identifier::Schema &schema_identifier,
 
119
                                                   const drizzled::SchemaIdentifier &schema_identifier,
120
120
                                                   drizzled::plugin::TableNameList *set_of_names,
121
 
                                                   drizzled::identifier::Table::vector *set_of_identifiers)
 
121
                                                   drizzled::TableIdentifier::vector *set_of_identifiers)
122
122
{
123
123
  drizzled::CachedDirectory::Entries entries= directory.getEntries();
124
124
 
140
140
      char uname[NAME_LEN + 1];
141
141
      uint32_t file_name_len;
142
142
 
143
 
      file_name_len= identifier::Table::filename_to_tablename(filename->c_str(), uname, sizeof(uname));
 
143
      file_name_len= TableIdentifier::filename_to_tablename(filename->c_str(), uname, sizeof(uname));
144
144
      uname[file_name_len - sizeof(FILESYSTEM_EXT) + 1]= '\0';
145
145
      if (set_of_names)
146
146
        set_of_names->insert(uname);
147
147
      if (set_of_identifiers)
148
 
        set_of_identifiers->push_back(identifier::Table(schema_identifier, uname));
 
148
        set_of_identifiers->push_back(TableIdentifier(schema_identifier, uname));
149
149
    }
150
150
  }
151
151
}
152
152
 
153
153
void FilesystemEngine::doGetTableIdentifiers(drizzled::CachedDirectory &directory,
154
 
                                             const drizzled::identifier::Schema &schema_identifier,
155
 
                                             drizzled::identifier::Table::vector &set_of_identifiers)
 
154
                                             const drizzled::SchemaIdentifier &schema_identifier,
 
155
                                             drizzled::TableIdentifier::vector &set_of_identifiers)
156
156
{
157
157
  getTableNamesFromFilesystem(directory, schema_identifier, NULL, &set_of_identifiers);
158
158
}
159
159
 
160
 
int FilesystemEngine::doDropTable(Session &, const identifier::Table &identifier)
 
160
int FilesystemEngine::doDropTable(Session &, const TableIdentifier &identifier)
161
161
{
162
162
  string new_path(identifier.getPath());
163
163
  new_path+= FILESYSTEM_EXT;
169
169
  return err;
170
170
}
171
171
 
172
 
bool FilesystemEngine::doDoesTableExist(Session &, const identifier::Table &identifier)
 
172
bool FilesystemEngine::doDoesTableExist(Session &, const TableIdentifier &identifier)
173
173
{
174
174
  string proto_path(identifier.getPath());
175
175
  proto_path.append(FILESYSTEM_EXT);
281
281
}
282
282
 
283
283
int FilesystemEngine::doGetTableDefinition(Session &,
284
 
                                           const drizzled::identifier::Table &identifier,
 
284
                                           const drizzled::TableIdentifier &identifier,
285
285
                                           drizzled::message::Table &table_proto)
286
286
{
287
287
  string new_path(identifier.getPath());
304
304
    if (not table_proto.IsInitialized())
305
305
    {
306
306
      my_error(ER_CORRUPT_TABLE_DEFINITION, MYF(0),
307
 
               table_proto.name().empty() ? " " : table_proto.name().c_str(),
308
307
               table_proto.InitializationErrorString().c_str());
309
 
 
310
308
      return ER_CORRUPT_TABLE_DEFINITION;
311
309
    }
312
310
 
463
461
{
464
462
}
465
463
 
466
 
int FilesystemCursor::doOpen(const drizzled::identifier::Table &identifier, int, uint32_t)
 
464
int FilesystemCursor::doOpen(const drizzled::TableIdentifier &identifier, int, uint32_t)
467
465
{
468
466
  if (!(share= get_share(identifier.getPath().c_str())))
469
467
    return ENOENT;
490
488
 
491
489
int FilesystemCursor::doStartTableScan(bool)
492
490
{
493
 
  sql_command_type = getTable()->getSession()->getSqlCommand();
 
491
  sql_command_type = session_sql_command(getTable()->getSession());
494
492
 
495
493
  if (thread_locked)
496
494
    critical_section_exit();
701
699
 
702
700
int FilesystemCursor::doEndTableScan()
703
701
{
704
 
  sql_command_type = getTable->getSession()->getSqlCommand();
 
702
  sql_command_type = session_sql_command(getTable()->getSession());
705
703
 
706
704
  if (share->format.isTagFormat())
707
705
  {
822
820
  if (share->format.isTagFormat())
823
821
    return 0;
824
822
 
825
 
  sql_command_type = getTable()->getSession()->getSqlCommand();
 
823
  sql_command_type = session_sql_command(getTable()->getSession());
826
824
 
827
825
  critical_section_enter();
828
826
 
893
891
  return 0;
894
892
}
895
893
 
896
 
int FilesystemEngine::doRenameTable(Session&, const identifier::Table &from, const identifier::Table &to)
 
894
int FilesystemEngine::doRenameTable(Session&, const TableIdentifier &from, const TableIdentifier &to)
897
895
{
898
896
  if (rename_file_ext(from.getPath().c_str(), to.getPath().c_str(), FILESYSTEM_EXT))
899
897
    return errno;
907
905
}
908
906
 
909
907
int FilesystemEngine::doCreateTable(Session &,
910
 
                                    Table&,
911
 
                                    const drizzled::identifier::Table &identifier,
912
 
                                    drizzled::message::Table &proto)
 
908
                        Table&,
 
909
                        const drizzled::TableIdentifier &identifier,
 
910
                        drizzled::message::Table &proto)
913
911
{
914
912
  FormatInfo format;
915
913
  format.parseFromTable(&proto);
956
954
  "Filesystem Engine",
957
955
  PLUGIN_LICENSE_GPL,
958
956
  filesystem_init_func, /* Plugin Init */
959
 
  NULL,                       /* depends */
 
957
  NULL,                       /* system variables                */
960
958
  NULL                        /* config options                  */
961
959
}
962
960
DRIZZLE_DECLARE_PLUGIN_END;