~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memory/ha_heap.cc

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

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
 
71
74
 
72
75
  int doCreateTable(Session &session,
73
76
                    Table &table_arg,
74
 
                    const TableIdentifier &identifier,
75
 
                    message::Table &create_proto);
 
77
                    const identifier::Table &identifier,
 
78
                    const message::Table &create_proto);
76
79
 
77
80
  /* For whatever reason, internal tables can be created by Cursor::open()
78
81
     for MEMORY.
82
85
  int heap_create_table(Session *session, const char *table_name,
83
86
                        Table *table_arg,
84
87
                        bool internal_table,
85
 
                        message::Table &create_proto,
 
88
                        const message::Table &create_proto,
86
89
                        HP_SHARE **internal_share);
87
90
 
88
 
  int doRenameTable(Session&, const TableIdentifier &from, const TableIdentifier &to);
 
91
  int doRenameTable(Session&, const identifier::Table &from, const identifier::Table &to);
89
92
 
90
 
  int doDropTable(Session&, const TableIdentifier &identifier);
 
93
  int doDropTable(Session&, const identifier::Table &identifier);
91
94
 
92
95
  int doGetTableDefinition(Session& session,
93
 
                           const TableIdentifier &identifier,
 
96
                           const identifier::Table &identifier,
94
97
                           message::Table &table_message);
95
98
 
96
99
  uint32_t max_supported_keys()          const { return MAX_KEY; }
101
104
    return ( HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR);
102
105
  }
103
106
 
104
 
  bool doDoesTableExist(Session& session, const TableIdentifier &identifier);
 
107
  bool doDoesTableExist(Session& session, const identifier::Table &identifier);
105
108
  void doGetTableIdentifiers(CachedDirectory &directory,
106
 
                             const SchemaIdentifier &schema_identifier,
107
 
                             TableIdentifier::vector &set_of_identifiers);
 
109
                             const identifier::Schema &schema_identifier,
 
110
                             identifier::table::vector &set_of_identifiers);
108
111
};
109
112
 
110
113
void HeapEngine::doGetTableIdentifiers(CachedDirectory&,
111
 
                                       const SchemaIdentifier&,
112
 
                                       TableIdentifier::vector&)
 
114
                                       const identifier::Schema&,
 
115
                                       identifier::table::vector&)
113
116
{
114
117
}
115
118
 
116
 
bool HeapEngine::doDoesTableExist(Session& session, const TableIdentifier &identifier)
 
119
bool HeapEngine::doDoesTableExist(Session& session, const identifier::Table &identifier)
117
120
{
118
121
  return session.getMessageCache().doesTableMessageExist(identifier);
119
122
}
120
123
 
121
124
int HeapEngine::doGetTableDefinition(Session &session,
122
 
                                     const TableIdentifier &identifier,
 
125
                                     const identifier::Table &identifier,
123
126
                                     message::Table &table_proto)
124
127
{
125
128
  if (session.getMessageCache().getTableMessage(identifier, table_proto))
131
134
  We have to ignore ENOENT entries as the MEMORY table is created on open and
132
135
  not when doing a CREATE on the table.
133
136
*/
134
 
int HeapEngine::doDropTable(Session &session, const TableIdentifier &identifier)
 
137
int HeapEngine::doDropTable(Session &session, const identifier::Table &identifier)
135
138
{
136
139
  session.getMessageCache().removeTableMessage(identifier);
137
140
 
176
179
*/
177
180
#define MEMORY_STATS_UPDATE_THRESHOLD 10
178
181
 
179
 
int ha_heap::doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked)
 
182
int ha_heap::doOpen(const drizzled::identifier::Table &identifier, int mode, uint32_t test_if_locked)
180
183
{
181
184
  if ((test_if_locked & HA_OPEN_INTERNAL_TABLE) || (!(file= heap_open(identifier.getPath().c_str(), mode)) && errno == ENOENT))
182
185
  {
241
244
Cursor *ha_heap::clone(memory::Root *)
242
245
{
243
246
  Cursor *new_handler= getTable()->getMutableShare()->db_type()->getCursor(*getTable());
244
 
  TableIdentifier identifier(getTable()->getShare()->getSchemaName(),
 
247
  identifier::Table identifier(getTable()->getShare()->getSchemaName(),
245
248
                             getTable()->getShare()->getTableName(),
246
249
                             getTable()->getShare()->getPath());
247
250
 
624
627
}
625
628
 
626
629
 
627
 
int HeapEngine::doRenameTable(Session &session, const TableIdentifier &from, const TableIdentifier &to)
 
630
int HeapEngine::doRenameTable(Session &session, const identifier::Table &from, const identifier::Table &to)
628
631
{
629
632
  session.getMessageCache().renameTableMessage(from, to);
630
633
  return heap_rename(from.getPath().c_str(), to.getPath().c_str());
653
656
 
654
657
int HeapEngine::doCreateTable(Session &session,
655
658
                              Table &table_arg,
656
 
                              const TableIdentifier &identifier,
657
 
                              message::Table& create_proto)
 
659
                              const identifier::Table &identifier,
 
660
                              const message::Table& create_proto)
658
661
{
659
662
  int error;
660
663
  HP_SHARE *internal_share;
677
680
int HeapEngine::heap_create_table(Session *session, const char *table_name,
678
681
                                  Table *table_arg,
679
682
                                  bool internal_table, 
680
 
                                  message::Table &create_proto,
 
683
                                  const message::Table &create_proto,
681
684
                                  HP_SHARE **internal_share)
682
685
{
683
686
  uint32_t key, parts, mem_per_row_keys= 0;
840
843
  "Hash based, stored in memory, useful for temporary tables",
841
844
  PLUGIN_LICENSE_GPL,
842
845
  heap_init,
843
 
  NULL,                       /* system variables                */
 
846
  NULL,                       /* depends */
844
847
  NULL                        /* config options                  */
845
848
}
846
849
DRIZZLE_DECLARE_PLUGIN_END;