~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/hp_open.cc

  • Committer: Brian Aker
  • Date: 2010-05-26 00:24:31 UTC
  • Revision ID: brian@gaz-20100526002431-33l06jm4z369luxy
Remove restriction on schemas named temporary.

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
/* open a heap-database */
17
17
 
31
31
 
32
32
HP_INFO *heap_open_from_share(HP_SHARE *share, int mode)
33
33
{
34
 
  HP_INFO *info= new HP_INFO;
 
34
  HP_INFO *info;
35
35
 
 
36
  if (!(info= (HP_INFO*) malloc(sizeof(HP_INFO) + 2 * share->max_key_length)))
 
37
  {
 
38
    return(0);
 
39
  }
 
40
  memset(info, 0, sizeof(HP_INFO) + 2 * share->max_key_length);
36
41
  share->open_count++;
37
 
  info->setShare(share);
38
 
  info->lastkey.resize(share->max_key_length);
 
42
  thr_lock_data_init(&share->lock,&info->lock,NULL);
 
43
  info->s= share;
 
44
  info->lastkey= (unsigned char*) (info + 1);
 
45
  info->recbuf= (unsigned char*) (info->lastkey + share->max_key_length);
39
46
  info->mode= mode;
40
47
  info->current_record= UINT32_MAX;             /* No current record */
41
48
  info->lastinx= info->errkey= -1;
42
 
  return info;
 
49
  return(info);
43
50
}
44
51
 
45
52
 
51
58
{
52
59
  HP_INFO *info;
53
60
 
54
 
  THR_LOCK_heap.lock();
 
61
  pthread_mutex_lock(&THR_LOCK_heap);
55
62
  if ((info= heap_open_from_share(share, mode)))
56
63
  {
57
64
    heap_open_list.push_front(info);
58
65
  }
59
 
  THR_LOCK_heap.unlock();
 
66
  pthread_mutex_unlock(&THR_LOCK_heap);
60
67
  return(info);
61
68
}
62
69
 
74
81
  HP_INFO *info;
75
82
  HP_SHARE *share;
76
83
 
77
 
  THR_LOCK_heap.lock();
 
84
  pthread_mutex_lock(&THR_LOCK_heap);
78
85
  if (!(share= hp_find_named_heap(name)))
79
86
  {
80
87
    errno= ENOENT;
81
 
    THR_LOCK_heap.unlock();
 
88
    pthread_mutex_unlock(&THR_LOCK_heap);
82
89
    return(0);
83
90
  }
84
91
  if ((info= heap_open_from_share(share, mode)))
85
92
  {
86
93
    heap_open_list.push_front(info);
87
94
  }
88
 
  THR_LOCK_heap.unlock();
 
95
  pthread_mutex_unlock(&THR_LOCK_heap);
89
96
  return(info);
90
97
}
91
98
 
97
104
  list<HP_SHARE *>::iterator it= heap_share_list.begin();
98
105
  while (it != heap_share_list.end())
99
106
  {
100
 
    if (not (*it)->name.compare(name))
 
107
    if (!strcmp(name, (*it)->name))
101
108
    {
102
109
      return (*it);
103
110
    }