00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <drizzled/error_t.h>
00023 #include "heap_priv.h"
00024
00025 using namespace drizzled;
00026
00027 static void hp_clear_keys(HP_SHARE *info);
00028
00029 void heap_clear(HP_INFO *info)
00030 {
00031 hp_clear(info->getShare());
00032 }
00033
00034 void hp_clear(HP_SHARE *info)
00035 {
00036 hp_clear_dataspace(&info->recordspace);
00037 hp_clear_keys(info);
00038 info->records= 0;
00039 info->blength=1;
00040 info->changed=0;
00041 return;
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 static void hp_clear_keys(HP_SHARE *info)
00059 {
00060 for (uint32_t key=0 ; key < info->keys ; key++)
00061 {
00062 HP_KEYDEF *keyinfo = info->keydef + key;
00063 {
00064 HP_BLOCK *block= &keyinfo->block;
00065 if (block->levels)
00066 hp_free_level(block,block->levels,block->root,(unsigned char*) 0);
00067 block->levels=0;
00068 block->last_allocated=0;
00069 keyinfo->hash_buckets= 0;
00070 }
00071 }
00072 info->index_length=0;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 int heap_disable_indexes(HP_INFO *info)
00091 {
00092 HP_SHARE *share= info->getShare();
00093
00094 if (share->keys)
00095 {
00096 hp_clear_keys(share);
00097 share->currently_disabled_keys= share->keys;
00098 share->keys= 0;
00099 }
00100 return 0;
00101 }
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 int heap_enable_indexes(HP_INFO *info)
00124 {
00125 int error= 0;
00126 HP_SHARE *share= info->getShare();
00127
00128 if (share->recordspace.total_data_length || share->index_length)
00129 error= HA_ERR_CRASHED;
00130 else
00131 if (share->currently_disabled_keys)
00132 {
00133 share->keys= share->currently_disabled_keys;
00134 share->currently_disabled_keys= 0;
00135 }
00136 return error;
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 int heap_indexes_are_disabled(HP_INFO *info)
00157 {
00158 HP_SHARE *share= info->getShare();
00159
00160 return (! share->keys && share->currently_disabled_keys);
00161 }