13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <drizzled/server_includes.h>
16
#include "heap_priv.h"
17
17
#include <drizzled/error.h>
18
18
#include <drizzled/table.h>
19
19
#include <drizzled/session.h>
57
56
return ha_heap_exts;
60
int createTableImplementation(Session *session, const char *table_name,
61
Table *table_arg, HA_CREATE_INFO *create_info,
62
drizzled::message::Table*);
59
int doCreateTable(Session *session,
60
const char *table_name,
62
HA_CREATE_INFO& create_info,
63
drizzled::message::Table&);
64
/* For whatever reason, internal tables can be created by handler::open()
65
/* For whatever reason, internal tables can be created by Cursor::open()
66
67
Instead of diving down a rat hole, let's just cry ourselves to sleep
67
68
at night with this odd hackish workaround.
69
70
int heap_create_table(Session *session, const char *table_name,
70
Table *table_arg, HA_CREATE_INFO *create_info,
71
Table *table_arg, HA_CREATE_INFO& create_info,
71
72
bool internal_table,
72
73
HP_SHARE **internal_share);
74
int renameTableImplementation(Session*, const char * from, const char * to);
76
int deleteTableImplementation(Session *, const string table_path);
75
int doRenameTable(Session*, const char * from, const char * to);
77
int doDropTable(Session&, const string table_path);
79
int doGetTableDefinition(Session& session,
82
const char *table_name,
84
drizzled::message::Table *table_proto);
86
/* Temp only engine, so do not return values. */
87
void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
91
int HeapEngine::doGetTableDefinition(Session&,
96
drizzled::message::Table *table_proto)
99
ProtoCache::iterator iter;
101
pthread_mutex_lock(&proto_cache_mutex);
102
iter= proto_cache.find(path);
104
if (iter!= proto_cache.end())
107
table_proto->CopyFrom(((*iter).second));
110
pthread_mutex_unlock(&proto_cache_mutex);
80
115
We have to ignore ENOENT entries as the HEAP table is created on open and
81
116
not when doing a CREATE on the table.
83
int HeapEngine::deleteTableImplementation(Session*, const string table_path)
118
int HeapEngine::doDropTable(Session&, const string table_path)
120
ProtoCache::iterator iter;
122
pthread_mutex_lock(&proto_cache_mutex);
123
iter= proto_cache.find(table_path.c_str());
125
if (iter!= proto_cache.end())
126
proto_cache.erase(iter);
127
pthread_mutex_unlock(&proto_cache_mutex);
85
129
return heap_delete_table(table_path.c_str());
116
160
ha_heap::ha_heap(drizzled::plugin::StorageEngine *engine_arg,
117
161
TableShare *table_arg)
118
:handler(engine_arg, table_arg), file(0), records_changed(0), key_stat_version(0),
162
:Cursor(engine_arg, table_arg), file(0), records_changed(0), key_stat_version(0),
119
163
internal_table(0)
192
236
with '\'-delimited path.
195
handler *ha_heap::clone(MEM_ROOT *mem_root)
239
Cursor *ha_heap::clone(MEM_ROOT *mem_root)
197
handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type());
241
Cursor *new_handler= table->s->db_type()->getCursor(table->s, mem_root);
198
243
if (new_handler && !new_handler->ha_open(table, file->s->name, table->db_stat,
199
244
HA_OPEN_IGNORE_IF_LOCKED))
200
245
return new_handler;
550
589
The indexes might have been disabled by disable_index() before.
551
590
The function works only if both data and indexes are empty,
552
591
since the heap storage engine cannot repair the indexes.
553
To be sure, call handler::delete_all_rows() before.
592
To be sure, call Cursor::delete_all_rows() before.
556
595
HA_KEY_SWITCH_NONUNIQ is not implemented.
645
684
return key->rec_per_key[key->key_parts-1];
648
int HeapEngine::createTableImplementation(Session *session,
649
const char *table_name,
651
HA_CREATE_INFO *create_info,
652
drizzled::message::Table*)
687
int HeapEngine::doCreateTable(Session *session,
688
const char *table_name,
690
HA_CREATE_INFO& create_info,
691
drizzled::message::Table& create_proto)
654
694
HP_SHARE *internal_share;
655
return heap_create_table(session, table_name, table_arg, create_info,
696
error= heap_create_table(session, table_name, &table_arg, create_info,
656
697
false, &internal_share);
701
pthread_mutex_lock(&proto_cache_mutex);
702
proto_cache.insert(make_pair(table_name, create_proto));
703
pthread_mutex_unlock(&proto_cache_mutex);
660
710
int HeapEngine::heap_create_table(Session *session, const char *table_name,
661
Table *table_arg, HA_CREATE_INFO *create_info,
711
Table *table_arg, HA_CREATE_INFO& create_info,
662
712
bool internal_table, HP_SHARE **internal_share)
664
714
uint32_t key, parts, mem_per_row_keys= 0, keys= table_arg->s->keys;
828
878
HP_CREATE_INFO hp_create_info;
829
879
hp_create_info.auto_key= auto_key;
830
880
hp_create_info.auto_key_type= auto_key_type;
831
hp_create_info.auto_increment= (create_info->auto_increment_value ?
832
create_info->auto_increment_value - 1 : 0);
881
hp_create_info.auto_increment= (create_info.auto_increment_value ?
882
create_info.auto_increment_value - 1 : 0);
833
883
hp_create_info.max_table_size=session->variables.max_heap_table_size;
834
884
hp_create_info.with_auto_increment= found_real_auto_increment;
835
885
hp_create_info.internal_table= internal_table;