~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/csv/ha_tina.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:
121
121
{
122
122
public:
123
123
  Tina(const string& name_arg)
124
 
   : drizzled::plugin::StorageEngine(name_arg, HTON_CAN_RECREATE | HTON_TEMPORARY_ONLY | HTON_FILE_BASED) {}
 
124
   : drizzled::plugin::StorageEngine(name_arg, HTON_CAN_RECREATE | HTON_TEMPORARY_ONLY | 
 
125
                                     HTON_HAS_DATA_DICTIONARY | HTON_FILE_BASED) {}
125
126
  virtual Cursor *create(TableShare *table,
126
127
                          MEM_ROOT *mem_root)
127
128
  {
132
133
    return ha_tina_exts;
133
134
  }
134
135
 
135
 
  int createTableImplementation(Session *, const char *table_name,
136
 
                                Table *table_arg,
137
 
                                HA_CREATE_INFO *, drizzled::message::Table*);
138
 
 
 
136
  int doCreateTable(Session *, const char *table_name,
 
137
                    Table& table_arg,
 
138
                    HA_CREATE_INFO&, drizzled::message::Table&);
 
139
 
 
140
  int doGetTableDefinition(Session& session,
 
141
                           const char* path,
 
142
                           const char *db,
 
143
                           const char *table_name,
 
144
                           const bool is_tmp,
 
145
                           drizzled::message::Table *table_proto);
 
146
 
 
147
  /* Temp only engine, so do not return values. */
 
148
  void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
 
149
 
 
150
  int doDropTable(Session&, const string table_path);
139
151
};
140
152
 
 
153
int Tina::doDropTable(Session&,
 
154
                        const string table_path)
 
155
{
 
156
  int error= 0;
 
157
  int enoent_or_zero= ENOENT;                   // Error if no file was deleted
 
158
  char buff[FN_REFLEN];
 
159
  ProtoCache::iterator iter;
 
160
 
 
161
  for (const char **ext= bas_ext(); *ext ; ext++)
 
162
  {
 
163
    fn_format(buff, table_path.c_str(), "", *ext,
 
164
              MY_UNPACK_FILENAME|MY_APPEND_EXT);
 
165
    if (my_delete_with_symlink(buff, MYF(0)))
 
166
    {
 
167
      if ((error= my_errno) != ENOENT)
 
168
        break;
 
169
    }
 
170
    else
 
171
      enoent_or_zero= 0;                        // No error for ENOENT
 
172
    error= enoent_or_zero;
 
173
  }
 
174
 
 
175
  pthread_mutex_lock(&proto_cache_mutex);
 
176
  iter= proto_cache.find(table_path.c_str());
 
177
 
 
178
  if (iter!= proto_cache.end())
 
179
    proto_cache.erase(iter);
 
180
  pthread_mutex_unlock(&proto_cache_mutex);
 
181
 
 
182
  return error;
 
183
}
 
184
 
 
185
int Tina::doGetTableDefinition(Session&,
 
186
                               const char* path,
 
187
                               const char *,
 
188
                               const char *,
 
189
                               const bool,
 
190
                               drizzled::message::Table *table_proto)
 
191
{
 
192
  int error= 1;
 
193
  ProtoCache::iterator iter;
 
194
 
 
195
  pthread_mutex_lock(&proto_cache_mutex);
 
196
  iter= proto_cache.find(path);
 
197
 
 
198
  if (iter!= proto_cache.end())
 
199
  {
 
200
    if (table_proto)
 
201
      table_proto->CopyFrom(((*iter).second));
 
202
    error= EEXIST;
 
203
  }
 
204
  pthread_mutex_unlock(&proto_cache_mutex);
 
205
 
 
206
  return error;
 
207
}
 
208
 
 
209
 
141
210
static Tina *tina_engine= NULL;
142
211
 
143
212
static int tina_init_func(drizzled::plugin::Registry &registry)
1455
1524
  this (the database will call ::open() if it needs to).
1456
1525
*/
1457
1526
 
1458
 
int Tina::createTableImplementation(Session *, const char *table_name,
1459
 
                                    Table *table_arg,
1460
 
                                    HA_CREATE_INFO *, drizzled::message::Table*)
 
1527
int Tina::doCreateTable(Session *, const char *table_name,
 
1528
                        Table& table_arg,
 
1529
                        HA_CREATE_INFO&, 
 
1530
                        drizzled::message::Table& create_proto)
1461
1531
{
1462
1532
  char name_buff[FN_REFLEN];
1463
1533
  File create_file;
1465
1535
  /*
1466
1536
    check columns
1467
1537
  */
1468
 
  for (Field **field= table_arg->s->field; *field; field++)
 
1538
  for (Field **field= table_arg.s->field; *field; field++)
1469
1539
  {
1470
1540
    if ((*field)->real_maybe_null())
1471
1541
    {
1490
1560
 
1491
1561
  my_close(create_file, MYF(0));
1492
1562
 
1493
 
  return(0);
 
1563
  pthread_mutex_lock(&proto_cache_mutex);
 
1564
  proto_cache.insert(make_pair(table_name, create_proto));
 
1565
  pthread_mutex_unlock(&proto_cache_mutex);
 
1566
 
 
1567
  return 0;
1494
1568
}
1495
1569
 
1496
1570
int ha_tina::check(Session* session, HA_CHECK_OPT *)
1543
1617
}
1544
1618
 
1545
1619
 
1546
 
drizzle_declare_plugin(csv)
 
1620
drizzle_declare_plugin
1547
1621
{
1548
1622
  "CSV",
1549
1623
  "1.0",