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.
24
void heap_clear(HP_INFO *info)
29
void hp_clear(HP_SHARE *info)
31
DBUG_ENTER("hp_clear");
33
if (info->block.levels)
34
VOID(hp_free_level(&info->block,info->block.levels,info->block.root,
38
info->records= info->deleted= 0;
52
info A pointer to the heap storage engine HP_INFO struct.
55
Delete all trees of all indexes and leave them empty.
61
void heap_clear_keys(HP_INFO *info)
72
info A pointer to the heap storage engine HP_SHARE struct.
75
Delete all trees of all indexes and leave them empty.
81
void hp_clear_keys(HP_SHARE *info)
84
DBUG_ENTER("hp_clear_keys");
86
for (key=0 ; key < info->keys ; key++)
88
HP_KEYDEF *keyinfo = info->keydef + key;
89
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
91
delete_tree(&keyinfo->rb_tree);
95
HP_BLOCK *block= &keyinfo->block;
97
VOID(hp_free_level(block,block->levels,block->root,(uchar*) 0));
99
block->last_allocated=0;
100
keyinfo->hash_buckets= 0;
103
info->index_length=0;
112
heap_disable_indexes()
113
info A pointer to the heap storage engine HP_INFO struct.
116
Disable and clear (remove contents of) all indexes.
122
int heap_disable_indexes(HP_INFO *info)
124
HP_SHARE *share= info->s;
128
hp_clear_keys(share);
129
share->currently_disabled_keys= share->keys;
140
heap_enable_indexes()
141
info A pointer to the heap storage engine HP_INFO struct.
144
Enable all indexes. The indexes might have been disabled
145
by heap_disable_index() before.
146
The function works only if both data and indexes are empty,
147
since the heap storage engine cannot repair the indexes.
148
To be sure, call handler::delete_all_rows() before.
152
HA_ERR_CRASHED data or index is non-empty.
155
int heap_enable_indexes(HP_INFO *info)
158
HP_SHARE *share= info->s;
160
if (share->data_length || share->index_length)
161
error= HA_ERR_CRASHED;
163
if (share->currently_disabled_keys)
165
share->keys= share->currently_disabled_keys;
166
share->currently_disabled_keys= 0;
173
Test if indexes are disabled.
176
heap_indexes_are_disabled()
177
info A pointer to the heap storage engine HP_INFO struct.
180
Test if indexes are disabled.
183
0 indexes are not disabled
184
1 all indexes are disabled
185
[2 non-unique indexes are disabled - NOT YET IMPLEMENTED]
188
int heap_indexes_are_disabled(HP_INFO *info)
190
HP_SHARE *share= info->s;
192
return (! share->keys && share->currently_disabled_keys);