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 */
16
16
/* open a heap-database */
18
#include "heap_priv.h"
20
#include "hp_static.c" /* Stupid vms-linker */
23
#include <mysys/my_sys.h>
26
26
Open heap table based on HP_SHARE structure
29
29
This doesn't register the table in the open table list.
32
32
HP_INFO *heap_open_from_share(HP_SHARE *share, int mode)
34
HP_INFO *info= new HP_INFO;
37
info->setShare(share);
38
info->lastkey.resize(share->max_key_length);
36
if (!(info= (HP_INFO*) my_malloc((uint) sizeof(HP_INFO) +
37
2 * share->max_key_length,
43
thr_lock_data_init(&share->lock,&info->lock,NULL);
45
info->lastkey= (uchar*) (info + 1);
46
info->recbuf= (uchar*) (info->lastkey + share->max_key_length);
40
info->current_record= UINT32_MAX; /* No current record */
48
info->current_record= (ulong) ~0L; /* No current record */
41
49
info->lastinx= info->errkey= -1;
62
pthread_mutex_lock(&THR_LOCK_heap);
55
63
if ((info= heap_open_from_share(share, mode)))
57
heap_open_list.push_front(info);
65
info->open_list.data= (void*) info;
66
heap_open_list= list_add(heap_open_list,&info->open_list);
59
THR_LOCK_heap.unlock();
68
pthread_mutex_unlock(&THR_LOCK_heap);
86
pthread_mutex_lock(&THR_LOCK_heap);
78
87
if (!(share= hp_find_named_heap(name)))
81
THR_LOCK_heap.unlock();
90
pthread_mutex_unlock(&THR_LOCK_heap);
84
93
if ((info= heap_open_from_share(share, mode)))
86
heap_open_list.push_front(info);
95
info->open_list.data= (void*) info;
96
heap_open_list= list_add(heap_open_list,&info->open_list);
88
THR_LOCK_heap.unlock();
98
pthread_mutex_unlock(&THR_LOCK_heap);
95
105
HP_SHARE *hp_find_named_heap(const char *name)
97
list<HP_SHARE *>::iterator it= heap_share_list.begin();
98
while (it != heap_share_list.end())
110
for (pos= heap_share_list; pos; pos= pos->next)
100
if (not (*it)->name.compare(name))
112
info= (HP_SHARE*) pos->data;
113
if (!strcmp(name, info->name))
106
118
return((HP_SHARE *) 0);