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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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)
30
hp_clear(info->getShare());
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)
59
for (uint32_t key=0 ; key < info->keys ; key++)
61
HP_KEYDEF *keyinfo = info->keydef + key;
63
HP_BLOCK *block= &keyinfo->block;
65
hp_free_level(block,block->levels,block->root,(unsigned char*) 0);
67
block->last_allocated=0;
68
keyinfo->hash_buckets= 0;
79
heap_disable_indexes()
80
info A pointer to the heap storage engine HP_INFO struct.
83
Disable and clear (remove contents of) all indexes.
89
int heap_disable_indexes(HP_INFO *info)
91
HP_SHARE *share= info->getShare();
96
share->currently_disabled_keys= share->keys;
107
heap_enable_indexes()
108
info A pointer to the heap storage engine HP_INFO struct.
111
Enable all indexes. The indexes might have been disabled
112
by heap_disable_index() before.
113
The function works only if both data and indexes are empty,
114
since the heap storage engine cannot repair the indexes.
115
To be sure, call handler::delete_all_rows() before.
119
HA_ERR_CRASHED data or index is non-empty.
122
int heap_enable_indexes(HP_INFO *info)
125
HP_SHARE *share= info->getShare();
127
if (share->recordspace.total_data_length || share->index_length)
128
error= HA_ERR_CRASHED;
130
if (share->currently_disabled_keys)
132
share->keys= share->currently_disabled_keys;
133
share->currently_disabled_keys= 0;
140
Test if indexes are disabled.
143
heap_indexes_are_disabled()
144
info A pointer to the heap storage engine HP_INFO struct.
147
Test if indexes are disabled.
150
0 indexes are not disabled
151
1 all indexes are disabled
152
[2 non-unique indexes are disabled - NOT YET IMPLEMENTED]
155
int heap_indexes_are_disabled(HP_INFO *info)
157
HP_SHARE *share= info->getShare();
159
return (! share->keys && share->currently_disabled_keys);