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