~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/hp_open.cc

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

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
    }