~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/blackhole/ha_blackhole.cc

  • Committer: Eric Day
  • Date: 2010-03-25 19:28:37 UTC
  • mfrom: (1405 staging)
  • mto: This revision was merged to the branch mainline in revision 1409.
  • Revision ID: eday@oddments.org-20100325192837-4exmacbrywjovsqp
Merged trunk, rsolved conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
#define BLACKHOLE_EXT ".blk"
40
40
 
 
41
static pthread_mutex_t blackhole_mutex;
 
42
 
 
43
 
41
44
static const char *ha_blackhole_exts[] = {
42
45
  NULL
43
46
};
60
63
    table_definition_ext= BLACKHOLE_EXT;
61
64
  }
62
65
 
 
66
  virtual ~BlackholeEngine()
 
67
  {
 
68
    pthread_mutex_destroy(&blackhole_mutex);
 
69
  }
 
70
 
63
71
  virtual Cursor *create(TableShare &table,
64
72
                         drizzled::memory::Root *mem_root)
65
73
  {
131
139
  }
132
140
 
133
141
  bool doDoesTableExist(Session& session, TableIdentifier &identifier);
 
142
  int doRenameTable(Session&, TableIdentifier &from, TableIdentifier &to);
134
143
};
135
144
 
136
145
 
 
146
int BlackholeEngine::doRenameTable(Session&, TableIdentifier &from, TableIdentifier &to)
 
147
{
 
148
  int error= 0;
 
149
 
 
150
  for (const char **ext= bas_ext(); *ext ; ext++)
 
151
  {
 
152
    if (rename_file_ext(from.getPath().c_str(), to.getPath().c_str(), *ext))
 
153
    {
 
154
      if ((error=errno) != ENOENT)
 
155
        break;
 
156
      error= 0;
 
157
    }
 
158
  }
 
159
  return error;
 
160
}
 
161
 
137
162
BlackholeShare *BlackholeEngine::findOpenTable(const string table_name)
138
163
{
139
164
  BlackholeMap::iterator find_iter=
156
181
}
157
182
 
158
183
 
159
 
/* Static declarations for shared structures */
160
 
 
161
 
static pthread_mutex_t blackhole_mutex;
162
 
 
163
184
 
164
185
/*****************************************************************************
165
186
** BLACKHOLE tables
425
446
 
426
447
static drizzled::plugin::StorageEngine *blackhole_engine= NULL;
427
448
 
428
 
static int blackhole_init(drizzled::plugin::Registry &registry)
 
449
static int blackhole_init(drizzled::plugin::Context &context)
429
450
{
430
451
 
431
452
  blackhole_engine= new BlackholeEngine("BLACKHOLE");
432
 
  registry.add(blackhole_engine);
 
453
  context.add(blackhole_engine);
433
454
  
434
455
  pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST);
435
456
 
436
457
  return 0;
437
458
}
438
459
 
439
 
static int blackhole_fini(drizzled::plugin::Registry &registry)
440
 
{
441
 
  registry.remove(blackhole_engine);
442
 
  delete blackhole_engine;
443
 
 
444
 
  pthread_mutex_destroy(&blackhole_mutex);
445
 
 
446
 
  return 0;
447
 
}
448
460
 
449
461
DRIZZLE_DECLARE_PLUGIN
450
462
{
455
467
  "/dev/null storage engine (anything you write to it disappears)",
456
468
  PLUGIN_LICENSE_GPL,
457
469
  blackhole_init,     /* Plugin Init */
458
 
  blackhole_fini,     /* Plugin Deinit */
459
470
  NULL,               /* system variables */
460
471
  NULL                /* config options   */
461
472
}