~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_clear.c

Merged vcol stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
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 */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/*
17
17
  remove all records from database
19
19
  database remains open.
20
20
*/
21
21
 
22
 
#include "heap_priv.h"
23
 
 
24
 
using namespace drizzled;
25
 
 
26
 
static void hp_clear_keys(HP_SHARE *info);
 
22
#include "heapdef.h"
27
23
 
28
24
void heap_clear(HP_INFO *info)
29
25
{
30
 
  hp_clear(info->getShare());
 
26
  hp_clear(info->s);
31
27
}
32
28
 
33
29
void hp_clear(HP_SHARE *info)
40
36
  return;
41
37
}
42
38
 
 
39
 
 
40
/*
 
41
  Clear all keys.
 
42
 
 
43
  SYNOPSIS
 
44
    heap_clear_keys()
 
45
    info      A pointer to the heap storage engine HP_INFO struct.
 
46
 
 
47
  DESCRIPTION
 
48
    Delete all trees of all indexes and leave them empty.
 
49
 
 
50
  RETURN
 
51
    void
 
52
*/
 
53
 
 
54
void heap_clear_keys(HP_INFO *info)
 
55
{
 
56
  hp_clear(info->s);
 
57
}
 
58
 
 
59
 
43
60
/*
44
61
  Clear all keys.
45
62
 
54
71
    void
55
72
*/
56
73
 
57
 
static void hp_clear_keys(HP_SHARE *info)
 
74
void hp_clear_keys(HP_SHARE *info)
58
75
{
59
 
  for (uint32_t key=0 ; key < info->keys ; key++)
 
76
  uint32_t key;
 
77
 
 
78
  for (key=0 ; key < info->keys ; key++)
60
79
  {
61
80
    HP_KEYDEF *keyinfo = info->keydef + key;
 
81
    if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
 
82
    {
 
83
      delete_tree(&keyinfo->rb_tree);
 
84
    }
 
85
    else
62
86
    {
63
87
      HP_BLOCK *block= &keyinfo->block;
64
88
      if (block->levels)
69
93
    }
70
94
  }
71
95
  info->index_length=0;
 
96
  return;
72
97
}
73
98
 
74
99
 
88
113
 
89
114
int heap_disable_indexes(HP_INFO *info)
90
115
{
91
 
  HP_SHARE *share= info->getShare();
 
116
  HP_SHARE *share= info->s;
92
117
 
93
118
  if (share->keys)
94
119
  {
122
147
int heap_enable_indexes(HP_INFO *info)
123
148
{
124
149
  int error= 0;
125
 
  HP_SHARE *share= info->getShare();
 
150
  HP_SHARE *share= info->s;
126
151
 
127
152
  if (share->recordspace.total_data_length || share->index_length)
128
153
    error= HA_ERR_CRASHED;
154
179
 
155
180
int heap_indexes_are_disabled(HP_INFO *info)
156
181
{
157
 
  HP_SHARE *share= info->getShare();
 
182
  HP_SHARE *share= info->s;
158
183
 
159
184
  return (! share->keys && share->currently_disabled_keys);
160
185
}