~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_open.c

  • Committer: Brian Aker
  • Date: 2008-07-14 22:40:46 UTC
  • Revision ID: brian@tangent.org-20080714224046-x183907w9wp1txwv
Removed sql_manager. Ever heard of just setting up the OS to sync when you
want it to?

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "hp_static.c"                  /* Stupid vms-linker */
21
21
#endif
22
22
 
23
 
#include <mysys/my_sys.h>
 
23
#include "my_sys.h"
24
24
 
25
25
/*
26
26
  Open heap table based on HP_SHARE structure
32
32
HP_INFO *heap_open_from_share(HP_SHARE *share, int mode)
33
33
{
34
34
  HP_INFO *info;
 
35
  DBUG_ENTER("heap_open_from_share");
35
36
 
36
37
  if (!(info= (HP_INFO*) my_malloc((uint) sizeof(HP_INFO) +
37
38
                                  2 * share->max_key_length,
38
39
                                  MYF(MY_ZEROFILL))))
39
40
  {
40
 
    return(0);
 
41
    DBUG_RETURN(0);
41
42
  }
42
43
  share->open_count++; 
43
44
  thr_lock_data_init(&share->lock,&info->lock,NULL);
44
45
  info->s= share;
45
 
  info->lastkey= (unsigned char*) (info + 1);
46
 
  info->recbuf= (unsigned char*) (info->lastkey + share->max_key_length);
 
46
  info->lastkey= (uchar*) (info + 1);
 
47
  info->recbuf= (uchar*) (info->lastkey + share->max_key_length);
47
48
  info->mode= mode;
48
 
  info->current_record= UINT32_MAX;             /* No current record */
 
49
  info->current_record= (ulong) ~0L;            /* No current record */
49
50
  info->lastinx= info->errkey= -1;
50
 
  return(info);
 
51
#ifndef DBUG_OFF
 
52
  info->opt_flag= READ_CHECK_USED;              /* Check when changing */
 
53
#endif
 
54
  DBUG_PRINT("exit",("heap: 0x%lx  reclength: %d  records_in_block: %d",
 
55
                     (long) info, share->reclength,
 
56
                     share->block.records_in_block));
 
57
  DBUG_RETURN(info);
51
58
}
52
59
 
53
60
 
58
65
HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode)
59
66
{
60
67
  HP_INFO *info;
 
68
  DBUG_ENTER("heap_open_from_share_and_register");
61
69
 
62
70
  pthread_mutex_lock(&THR_LOCK_heap);
63
71
  if ((info= heap_open_from_share(share, mode)))
66
74
    heap_open_list= list_add(heap_open_list,&info->open_list);
67
75
  }
68
76
  pthread_mutex_unlock(&THR_LOCK_heap);
69
 
  return(info);
 
77
  DBUG_RETURN(info);
70
78
}
71
79
 
72
80
 
82
90
{
83
91
  HP_INFO *info;
84
92
  HP_SHARE *share;
 
93
  DBUG_ENTER("heap_open");
85
94
 
86
95
  pthread_mutex_lock(&THR_LOCK_heap);
87
96
  if (!(share= hp_find_named_heap(name)))
88
97
  {
89
98
    my_errno= ENOENT;
90
99
    pthread_mutex_unlock(&THR_LOCK_heap);
91
 
    return(0);
 
100
    DBUG_RETURN(0);
92
101
  }
93
102
  if ((info= heap_open_from_share(share, mode)))
94
103
  {
96
105
    heap_open_list= list_add(heap_open_list,&info->open_list);
97
106
  }
98
107
  pthread_mutex_unlock(&THR_LOCK_heap);
99
 
  return(info);
 
108
  DBUG_RETURN(info);
100
109
}
101
110
 
102
111
 
106
115
{
107
116
  LIST *pos;
108
117
  HP_SHARE *info;
 
118
  DBUG_ENTER("heap_find");
 
119
  DBUG_PRINT("enter",("name: %s",name));
109
120
 
110
121
  for (pos= heap_share_list; pos; pos= pos->next)
111
122
  {
112
123
    info= (HP_SHARE*) pos->data;
113
124
    if (!strcmp(name, info->name))
114
125
    {
115
 
      return(info);
 
126
      DBUG_PRINT("exit", ("Old heap_database: 0x%lx", (long) info));
 
127
      DBUG_RETURN(info);
116
128
    }
117
129
  }
118
 
  return((HP_SHARE *) 0);
 
130
  DBUG_RETURN((HP_SHARE *) 0);
119
131
}
120
132
 
121
133