1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2002, 2004, 2006 MySQL AB
|
2 |
||
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.
|
|
6 |
||
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.
|
|
11 |
||
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
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
16 |
/*
|
|
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.
|
|
20 |
*/
|
|
21 |
||
1130.3.28
by Monty Taylor
Moved heapdef.h and myisamdef.h to *_priv.h for easier filtering for include guard check. |
22 |
#include "heap_priv.h" |
1
by brian
clean slate |
23 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
24 |
using namespace drizzled; |
25 |
||
1165.1.159
by Stewart Smith
make hp_clear_keys() static to hp_clear.cc |
26 |
static void hp_clear_keys(HP_SHARE *info); |
27 |
||
1
by brian
clean slate |
28 |
void heap_clear(HP_INFO *info) |
29 |
{
|
|
1697.2.1
by Brian Aker
Encapsulate the internal share for HEAP. |
30 |
hp_clear(info->getShare()); |
1
by brian
clean slate |
31 |
}
|
32 |
||
33 |
void hp_clear(HP_SHARE *info) |
|
34 |
{
|
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
35 |
hp_clear_dataspace(&info->recordspace); |
1
by brian
clean slate |
36 |
hp_clear_keys(info); |
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
37 |
info->records= 0; |
1
by brian
clean slate |
38 |
info->blength=1; |
39 |
info->changed=0; |
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
40 |
return; |
1
by brian
clean slate |
41 |
}
|
42 |
||
43 |
/*
|
|
44 |
Clear all keys.
|
|
45 |
||
46 |
SYNOPSIS
|
|
47 |
hp_clear_keys()
|
|
48 |
info A pointer to the heap storage engine HP_SHARE struct.
|
|
49 |
||
50 |
DESCRIPTION
|
|
51 |
Delete all trees of all indexes and leave them empty.
|
|
52 |
||
53 |
RETURN
|
|
54 |
void
|
|
55 |
*/
|
|
56 |
||
1165.1.159
by Stewart Smith
make hp_clear_keys() static to hp_clear.cc |
57 |
static void hp_clear_keys(HP_SHARE *info) |
1
by brian
clean slate |
58 |
{
|
1707.1.7
by Brian Aker
Style updates. |
59 |
for (uint32_t key=0 ; key < info->keys ; key++) |
1
by brian
clean slate |
60 |
{
|
61 |
HP_KEYDEF *keyinfo = info->keydef + key; |
|
62 |
{
|
|
63 |
HP_BLOCK *block= &keyinfo->block; |
|
64 |
if (block->levels) |
|
481
by Brian Aker
Remove all of uchar. |
65 |
hp_free_level(block,block->levels,block->root,(unsigned char*) 0); |
1
by brian
clean slate |
66 |
block->levels=0; |
67 |
block->last_allocated=0; |
|
68 |
keyinfo->hash_buckets= 0; |
|
69 |
}
|
|
70 |
}
|
|
71 |
info->index_length=0; |
|
72 |
}
|
|
73 |
||
74 |
||
75 |
/*
|
|
76 |
Disable all indexes.
|
|
77 |
||
78 |
SYNOPSIS
|
|
79 |
heap_disable_indexes()
|
|
80 |
info A pointer to the heap storage engine HP_INFO struct.
|
|
81 |
||
82 |
DESCRIPTION
|
|
83 |
Disable and clear (remove contents of) all indexes.
|
|
84 |
||
85 |
RETURN
|
|
86 |
0 ok
|
|
87 |
*/
|
|
88 |
||
89 |
int heap_disable_indexes(HP_INFO *info) |
|
90 |
{
|
|
1697.2.1
by Brian Aker
Encapsulate the internal share for HEAP. |
91 |
HP_SHARE *share= info->getShare(); |
1
by brian
clean slate |
92 |
|
93 |
if (share->keys) |
|
94 |
{
|
|
95 |
hp_clear_keys(share); |
|
96 |
share->currently_disabled_keys= share->keys; |
|
97 |
share->keys= 0; |
|
98 |
}
|
|
99 |
return 0; |
|
100 |
}
|
|
101 |
||
102 |
||
103 |
/*
|
|
104 |
Enable all indexes
|
|
105 |
||
106 |
SYNOPSIS
|
|
107 |
heap_enable_indexes()
|
|
108 |
info A pointer to the heap storage engine HP_INFO struct.
|
|
109 |
||
110 |
DESCRIPTION
|
|
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.
|
|
116 |
||
117 |
RETURN
|
|
118 |
0 ok
|
|
119 |
HA_ERR_CRASHED data or index is non-empty.
|
|
120 |
*/
|
|
121 |
||
122 |
int heap_enable_indexes(HP_INFO *info) |
|
123 |
{
|
|
124 |
int error= 0; |
|
1697.2.1
by Brian Aker
Encapsulate the internal share for HEAP. |
125 |
HP_SHARE *share= info->getShare(); |
1
by brian
clean slate |
126 |
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
127 |
if (share->recordspace.total_data_length || share->index_length) |
1
by brian
clean slate |
128 |
error= HA_ERR_CRASHED; |
129 |
else
|
|
130 |
if (share->currently_disabled_keys) |
|
131 |
{
|
|
132 |
share->keys= share->currently_disabled_keys; |
|
133 |
share->currently_disabled_keys= 0; |
|
134 |
}
|
|
135 |
return error; |
|
136 |
}
|
|
137 |
||
138 |
||
139 |
/*
|
|
140 |
Test if indexes are disabled.
|
|
141 |
||
142 |
SYNOPSIS
|
|
143 |
heap_indexes_are_disabled()
|
|
144 |
info A pointer to the heap storage engine HP_INFO struct.
|
|
145 |
||
146 |
DESCRIPTION
|
|
147 |
Test if indexes are disabled.
|
|
148 |
||
149 |
RETURN
|
|
150 |
0 indexes are not disabled
|
|
151 |
1 all indexes are disabled
|
|
152 |
[2 non-unique indexes are disabled - NOT YET IMPLEMENTED]
|
|
153 |
*/
|
|
154 |
||
155 |
int heap_indexes_are_disabled(HP_INFO *info) |
|
156 |
{
|
|
1697.2.1
by Brian Aker
Encapsulate the internal share for HEAP. |
157 |
HP_SHARE *share= info->getShare(); |
1
by brian
clean slate |
158 |
|
159 |
return (! share->keys && share->currently_disabled_keys); |
|
160 |
}
|