~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_clear.c

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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