1
/* Copyright (C) 2000-2002, 2004, 2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
remove all records from database
18
Identical as hp_create() and hp_open() but used HP_SHARE* instead of name and
19
database remains open.
22
#include "heap_priv.h"
24
using namespace drizzled;
26
static void hp_clear_keys(HP_SHARE *info);
28
void heap_clear(HP_INFO *info)
33
void hp_clear(HP_SHARE *info)
35
hp_clear_dataspace(&info->recordspace);
48
info A pointer to the heap storage engine HP_SHARE struct.
51
Delete all trees of all indexes and leave them empty.
57
static void hp_clear_keys(HP_SHARE *info)
61
for (key=0 ; key < info->keys ; key++)
63
HP_KEYDEF *keyinfo = info->keydef + key;
64
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
66
delete_tree(&keyinfo->rb_tree);
70
HP_BLOCK *block= &keyinfo->block;
72
hp_free_level(block,block->levels,block->root,(unsigned char*) 0);
74
block->last_allocated=0;
75
keyinfo->hash_buckets= 0;
87
heap_disable_indexes()
88
info A pointer to the heap storage engine HP_INFO struct.
91
Disable and clear (remove contents of) all indexes.
97
int heap_disable_indexes(HP_INFO *info)
99
HP_SHARE *share= info->s;
103
hp_clear_keys(share);
104
share->currently_disabled_keys= share->keys;
115
heap_enable_indexes()
116
info A pointer to the heap storage engine HP_INFO struct.
119
Enable all indexes. The indexes might have been disabled
120
by heap_disable_index() before.
121
The function works only if both data and indexes are empty,
122
since the heap storage engine cannot repair the indexes.
123
To be sure, call handler::delete_all_rows() before.
127
HA_ERR_CRASHED data or index is non-empty.
130
int heap_enable_indexes(HP_INFO *info)
133
HP_SHARE *share= info->s;
135
if (share->recordspace.total_data_length || share->index_length)
136
error= HA_ERR_CRASHED;
138
if (share->currently_disabled_keys)
140
share->keys= share->currently_disabled_keys;
141
share->currently_disabled_keys= 0;
148
Test if indexes are disabled.
151
heap_indexes_are_disabled()
152
info A pointer to the heap storage engine HP_INFO struct.
155
Test if indexes are disabled.
158
0 indexes are not disabled
159
1 all indexes are disabled
160
[2 non-unique indexes are disabled - NOT YET IMPLEMENTED]
163
int heap_indexes_are_disabled(HP_INFO *info)
165
HP_SHARE *share= info->s;
167
return (! share->keys && share->currently_disabled_keys);