~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_clear.c

Merge/fix in FAQ.

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)
34
30
{
35
 
  hp_clear_dataspace(&info->recordspace);
 
31
  if (info->block.levels)
 
32
    VOID(hp_free_level(&info->block,info->block.levels,info->block.root,
 
33
                        (uchar*) 0));
 
34
  info->block.levels=0;
36
35
  hp_clear_keys(info);
37
 
  info->records= 0;
 
36
  info->records= info->deleted= 0;
 
37
  info->data_length= 0;
38
38
  info->blength=1;
39
39
  info->changed=0;
 
40
  info->del_link=0;
40
41
  return;
41
42
}
42
43
 
 
44
 
 
45
/*
 
46
  Clear all keys.
 
47
 
 
48
  SYNOPSIS
 
49
    heap_clear_keys()
 
50
    info      A pointer to the heap storage engine HP_INFO struct.
 
51
 
 
52
  DESCRIPTION
 
53
    Delete all trees of all indexes and leave them empty.
 
54
 
 
55
  RETURN
 
56
    void
 
57
*/
 
58
 
 
59
void heap_clear_keys(HP_INFO *info)
 
60
{
 
61
  hp_clear(info->s);
 
62
}
 
63
 
 
64
 
43
65
/*
44
66
  Clear all keys.
45
67
 
54
76
    void
55
77
*/
56
78
 
57
 
static void hp_clear_keys(HP_SHARE *info)
 
79
void hp_clear_keys(HP_SHARE *info)
58
80
{
59
 
  for (uint32_t key=0 ; key < info->keys ; key++)
 
81
  uint key;
 
82
 
 
83
  for (key=0 ; key < info->keys ; key++)
60
84
  {
61
85
    HP_KEYDEF *keyinfo = info->keydef + key;
 
86
    if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
 
87
    {
 
88
      delete_tree(&keyinfo->rb_tree);
 
89
    }
 
90
    else
62
91
    {
63
92
      HP_BLOCK *block= &keyinfo->block;
64
93
      if (block->levels)
65
 
        hp_free_level(block,block->levels,block->root,(unsigned char*) 0);
 
94
        VOID(hp_free_level(block,block->levels,block->root,(uchar*) 0));
66
95
      block->levels=0;
67
96
      block->last_allocated=0;
68
97
      keyinfo->hash_buckets= 0;
69
98
    }
70
99
  }
71
100
  info->index_length=0;
 
101
  return;
72
102
}
73
103
 
74
104
 
88
118
 
89
119
int heap_disable_indexes(HP_INFO *info)
90
120
{
91
 
  HP_SHARE *share= info->getShare();
 
121
  HP_SHARE *share= info->s;
92
122
 
93
123
  if (share->keys)
94
124
  {
122
152
int heap_enable_indexes(HP_INFO *info)
123
153
{
124
154
  int error= 0;
125
 
  HP_SHARE *share= info->getShare();
 
155
  HP_SHARE *share= info->s;
126
156
 
127
 
  if (share->recordspace.total_data_length || share->index_length)
 
157
  if (share->data_length || share->index_length)
128
158
    error= HA_ERR_CRASHED;
129
159
  else
130
160
    if (share->currently_disabled_keys)
154
184
 
155
185
int heap_indexes_are_disabled(HP_INFO *info)
156
186
{
157
 
  HP_SHARE *share= info->getShare();
 
187
  HP_SHARE *share= info->s;
158
188
 
159
189
  return (! share->keys && share->currently_disabled_keys);
160
190
}
 
191