~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/ha_heap.cc

  • Committer: Brian Aker
  • Date: 2009-03-25 22:03:13 UTC
  • mfrom: (960.2.47 mordred)
  • Revision ID: brian@tangent.org-20090325220313-fffae098oufxiaqg
Merge of Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <drizzled/field/timestamp.h>
26
26
#include <drizzled/field/varstring.h>
27
27
 
 
28
#include <string>
 
29
 
 
30
using namespace std;
 
31
 
 
32
static const string engine_name("MEMORY");
28
33
 
29
34
pthread_mutex_t THR_LOCK_heap= PTHREAD_MUTEX_INITIALIZER;
30
35
 
31
 
static handler *heap_create_handler(handlerton *hton,
32
 
                                    TABLE_SHARE *table,
33
 
                                    MEM_ROOT *mem_root);
34
 
 
35
 
int heap_deinit(void *)
36
 
{
 
36
 
 
37
class HeapEngine : public StorageEngine
 
38
{
 
39
public:
 
40
  HeapEngine(string name_arg) : StorageEngine(name_arg) {}
 
41
  virtual handler *create(TABLE_SHARE *table,
 
42
                          MEM_ROOT *mem_root)
 
43
  {
 
44
    return new (mem_root) ha_heap(this, table);
 
45
  }
 
46
};
 
47
 
 
48
int heap_init(void *p)
 
49
{
 
50
  StorageEngine **engine= static_cast<StorageEngine **>(p);
 
51
  *engine= new HeapEngine(engine_name);
 
52
 
 
53
  (*engine)->state=      SHOW_OPTION_YES;
 
54
  (*engine)->flags=      HTON_CAN_RECREATE;
 
55
 
 
56
  return 0;
 
57
}
 
58
 
 
59
int heap_deinit(void *p)
 
60
{
 
61
  HeapEngine *engine= static_cast<HeapEngine *>(p);
 
62
  delete engine;
 
63
 
37
64
  pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST);
38
65
 
39
66
  return hp_panic(HA_PANIC_CLOSE);
40
67
}
41
68
 
42
69
 
43
 
int heap_init(void *p)
44
 
{
45
 
  heap_hton= (handlerton *)p;
46
 
  heap_hton->state=      SHOW_OPTION_YES;
47
 
  heap_hton->create=     heap_create_handler;
48
 
  heap_hton->flags=      HTON_CAN_RECREATE;
49
 
 
50
 
  return 0;
51
 
}
52
 
 
53
 
static handler *heap_create_handler(handlerton *hton,
54
 
                                    TABLE_SHARE *table,
55
 
                                    MEM_ROOT *mem_root)
56
 
{
57
 
  return new (mem_root) ha_heap(hton, table);
58
 
}
59
 
 
60
70
 
61
71
/*****************************************************************************
62
72
** HEAP tables
63
73
*****************************************************************************/
64
74
 
65
 
ha_heap::ha_heap(handlerton *hton, TABLE_SHARE *table_arg)
66
 
  :handler(hton, table_arg), file(0), records_changed(0), key_stat_version(0),
 
75
ha_heap::ha_heap(StorageEngine *engine_arg, TABLE_SHARE *table_arg)
 
76
  :handler(engine_arg, table_arg), file(0), records_changed(0), key_stat_version(0),
67
77
  internal_table(0)
68
78
{}
69
79