~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memory/ha_heap.cc

mergeĀ lp:~hingo/drizzle/drizzle-auth_ldap-fix-and-docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <drizzled/error.h>
18
18
#include <drizzled/table.h>
19
19
#include <drizzled/session.h>
20
 
#include <drizzled/field/timestamp.h>
21
20
#include <drizzled/field/varstring.h>
22
 
#include "drizzled/plugin/daemon.h"
 
21
#include <drizzled/plugin/daemon.h>
 
22
#include <drizzled/plugin/storage_engine.h>
 
23
#include <drizzled/util/test.h>
 
24
#include <drizzled/session/table_messages.h>
 
25
#include <drizzled/statistics_variables.h>
 
26
#include <drizzled/system_variables.h>
23
27
 
24
28
#include <boost/thread/mutex.hpp>
25
29
 
28
32
 
29
33
#include <string>
30
34
 
31
 
 
32
35
using namespace drizzled;
33
36
using namespace std;
34
37
 
65
68
    return new ha_heap(*this, table);
66
69
  }
67
70
 
68
 
  const char **bas_ext() const {
 
71
  const char **bas_ext() const 
 
72
  {
69
73
    return ha_heap_exts;
70
74
  }
71
75
 
 
76
  drizzled::message::Table::Index::IndexType default_index_type() const
 
77
  {
 
78
    return drizzled::message::Table::Index::HASH;
 
79
  }
 
80
 
72
81
  int doCreateTable(Session &session,
73
82
                    Table &table_arg,
74
 
                    const TableIdentifier &identifier,
75
 
                    message::Table &create_proto);
 
83
                    const identifier::Table &identifier,
 
84
                    const message::Table &create_proto);
76
85
 
77
86
  /* For whatever reason, internal tables can be created by Cursor::open()
78
87
     for MEMORY.
82
91
  int heap_create_table(Session *session, const char *table_name,
83
92
                        Table *table_arg,
84
93
                        bool internal_table,
85
 
                        message::Table &create_proto,
 
94
                        const message::Table &create_proto,
86
95
                        HP_SHARE **internal_share);
87
96
 
88
 
  int doRenameTable(Session&, const TableIdentifier &from, const TableIdentifier &to);
 
97
  int doRenameTable(Session&, const identifier::Table &from, const identifier::Table &to);
89
98
 
90
 
  int doDropTable(Session&, const TableIdentifier &identifier);
 
99
  int doDropTable(Session&, const identifier::Table &identifier);
91
100
 
92
101
  int doGetTableDefinition(Session& session,
93
 
                           const TableIdentifier &identifier,
 
102
                           const identifier::Table &identifier,
94
103
                           message::Table &table_message);
95
104
 
96
105
  uint32_t max_supported_keys()          const { return MAX_KEY; }
101
110
    return ( HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR);
102
111
  }
103
112
 
104
 
  bool doDoesTableExist(Session& session, const TableIdentifier &identifier);
 
113
  bool doDoesTableExist(Session& session, const identifier::Table &identifier);
105
114
  void doGetTableIdentifiers(CachedDirectory &directory,
106
 
                             const SchemaIdentifier &schema_identifier,
107
 
                             TableIdentifier::vector &set_of_identifiers);
 
115
                             const identifier::Schema &schema_identifier,
 
116
                             identifier::table::vector &set_of_identifiers);
108
117
};
109
118
 
110
119
void HeapEngine::doGetTableIdentifiers(CachedDirectory&,
111
 
                                       const SchemaIdentifier&,
112
 
                                       TableIdentifier::vector&)
 
120
                                       const identifier::Schema&,
 
121
                                       identifier::table::vector&)
113
122
{
114
123
}
115
124
 
116
 
bool HeapEngine::doDoesTableExist(Session& session, const TableIdentifier &identifier)
 
125
bool HeapEngine::doDoesTableExist(Session& session, const identifier::Table &identifier)
117
126
{
118
127
  return session.getMessageCache().doesTableMessageExist(identifier);
119
128
}
120
129
 
121
130
int HeapEngine::doGetTableDefinition(Session &session,
122
 
                                     const TableIdentifier &identifier,
 
131
                                     const identifier::Table &identifier,
123
132
                                     message::Table &table_proto)
124
133
{
125
134
  if (session.getMessageCache().getTableMessage(identifier, table_proto))
131
140
  We have to ignore ENOENT entries as the MEMORY table is created on open and
132
141
  not when doing a CREATE on the table.
133
142
*/
134
 
int HeapEngine::doDropTable(Session &session, const TableIdentifier &identifier)
 
143
int HeapEngine::doDropTable(Session &session, const identifier::Table &identifier)
135
144
{
136
145
  session.getMessageCache().removeTableMessage(identifier);
137
146
 
176
185
*/
177
186
#define MEMORY_STATS_UPDATE_THRESHOLD 10
178
187
 
179
 
int ha_heap::doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked)
 
188
int ha_heap::doOpen(const drizzled::identifier::Table &identifier, int mode, uint32_t test_if_locked)
180
189
{
181
190
  if ((test_if_locked & HA_OPEN_INTERNAL_TABLE) || (!(file= heap_open(identifier.getPath().c_str(), mode)) && errno == ENOENT))
182
191
  {
219
228
    */
220
229
    key_stat_version= file->getShare()->key_stat_version - 1;
221
230
  }
222
 
  return (file ? 0 : 1);
 
231
  return file ? 0 : 1;
223
232
}
224
233
 
225
234
int ha_heap::close(void)
241
250
Cursor *ha_heap::clone(memory::Root *)
242
251
{
243
252
  Cursor *new_handler= getTable()->getMutableShare()->db_type()->getCursor(*getTable());
244
 
  TableIdentifier identifier(getTable()->getShare()->getSchemaName(),
 
253
  identifier::Table identifier(getTable()->getShare()->getSchemaName(),
245
254
                             getTable()->getShare()->getTableName(),
246
255
                             getTable()->getShare()->getPath());
247
256
 
612
621
   [2  non-unique indexes are disabled - NOT YET IMPLEMENTED]
613
622
*/
614
623
 
615
 
int ha_heap::indexes_are_disabled(void)
 
624
int ha_heap::indexes_are_disabled()
616
625
{
617
626
  return heap_indexes_are_disabled(file);
618
627
}
619
628
 
620
 
void ha_heap::drop_table(const char *)
 
629
void ha_heap::drop_table()
621
630
{
622
631
  file->getShare()->delete_on_close= 1;
623
632
  close();
624
633
}
625
634
 
626
635
 
627
 
int HeapEngine::doRenameTable(Session &session, const TableIdentifier &from, const TableIdentifier &to)
 
636
int HeapEngine::doRenameTable(Session &session, const identifier::Table &from, const identifier::Table &to)
628
637
{
629
638
  session.getMessageCache().renameTableMessage(from, to);
630
639
  return heap_rename(from.getPath().c_str(), to.getPath().c_str());
653
662
 
654
663
int HeapEngine::doCreateTable(Session &session,
655
664
                              Table &table_arg,
656
 
                              const TableIdentifier &identifier,
657
 
                              message::Table& create_proto)
 
665
                              const identifier::Table &identifier,
 
666
                              const message::Table& create_proto)
658
667
{
659
668
  int error;
660
669
  HP_SHARE *internal_share;
677
686
int HeapEngine::heap_create_table(Session *session, const char *table_name,
678
687
                                  Table *table_arg,
679
688
                                  bool internal_table, 
680
 
                                  message::Table &create_proto,
 
689
                                  const message::Table &create_proto,
681
690
                                  HP_SHARE **internal_share)
682
691
{
683
692
  uint32_t key, parts, mem_per_row_keys= 0;
840
849
  "Hash based, stored in memory, useful for temporary tables",
841
850
  PLUGIN_LICENSE_GPL,
842
851
  heap_init,
843
 
  NULL,                       /* system variables                */
 
852
  NULL,                       /* depends */
844
853
  NULL                        /* config options                  */
845
854
}
846
855
DRIZZLE_DECLARE_PLUGIN_END;