1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2004, 2006 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
16 |
/* open a heap-database */
|
|
17 |
||
1130.3.28
by Monty Taylor
Moved heapdef.h and myisamdef.h to *_priv.h for easier filtering for include guard check. |
18 |
#include "heap_priv.h" |
1
by brian
clean slate |
19 |
|
612.2.13
by Monty Taylor
Work on removing global.h from headers that should be installed. |
20 |
#include <string.h> |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
21 |
#include <cstdlib> |
1
by brian
clean slate |
22 |
|
916.1.26
by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine. |
23 |
using namespace std; |
24 |
||
1
by brian
clean slate |
25 |
/*
|
26 |
Open heap table based on HP_SHARE structure
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
27 |
|
1
by brian
clean slate |
28 |
NOTE
|
29 |
This doesn't register the table in the open table list.
|
|
30 |
*/
|
|
31 |
||
32 |
HP_INFO *heap_open_from_share(HP_SHARE *share, int mode) |
|
33 |
{
|
|
1697.2.2
by Brian Aker
Encapsulate some of heap. |
34 |
HP_INFO *info= new HP_INFO; |
1
by brian
clean slate |
35 |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
36 |
share->open_count++; |
1697.2.1
by Brian Aker
Encapsulate the internal share for HEAP. |
37 |
info->setShare(share); |
1707.1.3
by Brian Aker
Switch to using vector. |
38 |
info->lastkey.resize(share->max_key_length); |
1
by brian
clean slate |
39 |
info->mode= mode; |
365.2.8
by Monty Taylor
More MAX macros. |
40 |
info->current_record= UINT32_MAX; /* No current record */ |
1
by brian
clean slate |
41 |
info->lastinx= info->errkey= -1; |
1697.2.2
by Brian Aker
Encapsulate some of heap. |
42 |
return info; |
1
by brian
clean slate |
43 |
}
|
44 |
||
45 |
||
46 |
/*
|
|
47 |
Open heap table based on HP_SHARE structure and register it
|
|
48 |
*/
|
|
49 |
||
50 |
HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode) |
|
51 |
{
|
|
52 |
HP_INFO *info; |
|
53 |
||
1689.3.6
by Brian Aker
Update for HEAP to convert its lock to boost. |
54 |
THR_LOCK_heap.lock(); |
1
by brian
clean slate |
55 |
if ((info= heap_open_from_share(share, mode))) |
56 |
{
|
|
916.1.26
by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine. |
57 |
heap_open_list.push_front(info); |
1
by brian
clean slate |
58 |
}
|
1689.3.6
by Brian Aker
Update for HEAP to convert its lock to boost. |
59 |
THR_LOCK_heap.unlock(); |
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
60 |
return(info); |
1
by brian
clean slate |
61 |
}
|
62 |
||
63 |
||
64 |
/*
|
|
65 |
Open heap table based on name
|
|
66 |
||
67 |
NOTE
|
|
68 |
This register the table in the open table list. so that it can be
|
|
69 |
found by future heap_open() calls.
|
|
70 |
*/
|
|
71 |
||
72 |
HP_INFO *heap_open(const char *name, int mode) |
|
73 |
{
|
|
74 |
HP_INFO *info; |
|
75 |
HP_SHARE *share; |
|
76 |
||
1689.3.6
by Brian Aker
Update for HEAP to convert its lock to boost. |
77 |
THR_LOCK_heap.lock(); |
1
by brian
clean slate |
78 |
if (!(share= hp_find_named_heap(name))) |
79 |
{
|
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
80 |
errno= ENOENT; |
1689.3.6
by Brian Aker
Update for HEAP to convert its lock to boost. |
81 |
THR_LOCK_heap.unlock(); |
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
82 |
return(0); |
1
by brian
clean slate |
83 |
}
|
84 |
if ((info= heap_open_from_share(share, mode))) |
|
85 |
{
|
|
916.1.26
by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine. |
86 |
heap_open_list.push_front(info); |
1
by brian
clean slate |
87 |
}
|
1689.3.6
by Brian Aker
Update for HEAP to convert its lock to boost. |
88 |
THR_LOCK_heap.unlock(); |
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
89 |
return(info); |
1
by brian
clean slate |
90 |
}
|
91 |
||
92 |
||
93 |
/* map name to a heap-nr. If name isn't found return 0 */
|
|
94 |
||
95 |
HP_SHARE *hp_find_named_heap(const char *name) |
|
96 |
{
|
|
916.1.26
by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine. |
97 |
list<HP_SHARE *>::iterator it= heap_share_list.begin(); |
98 |
while (it != heap_share_list.end()) |
|
1
by brian
clean slate |
99 |
{
|
1707.1.2
by Brian Aker
std::string usage for name, remove strdup. |
100 |
if (not (*it)->name.compare(name)) |
1
by brian
clean slate |
101 |
{
|
916.1.26
by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine. |
102 |
return (*it); |
1
by brian
clean slate |
103 |
}
|
916.1.26
by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine. |
104 |
++it; |
1
by brian
clean slate |
105 |
}
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
106 |
return((HP_SHARE *) 0); |
1
by brian
clean slate |
107 |
}
|
108 |
||
109 |