~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/xa_resource_manager.cc

  • Committer: Brian Aker
  • Date: 2010-10-21 05:03:11 UTC
  • mto: (1866.1.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1867.
  • Revision ID: brian@tangent.org-20101021050311-gmobtsn3cgp8tz0b
Add a catalog() command.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <algorithm>
36
36
#include <functional>
37
37
 
 
38
using namespace std;
 
39
 
38
40
namespace drizzled
39
41
{
40
42
 
41
43
namespace plugin
42
44
{
43
45
 
44
 
static std::vector<XaResourceManager *> xa_resource_managers;
 
46
static vector<XaResourceManager *> xa_resource_managers;
45
47
 
46
48
int XaResourceManager::commitOrRollbackXID(XID *xid, bool commit)
47
49
{
48
 
  std::vector<int> results;
 
50
  vector<int> results;
49
51
  
50
52
  if (commit)
51
53
    transform(xa_resource_managers.begin(), xa_resource_managers.end(), results.begin(),
52
 
              std::bind2nd(std::mem_fun(&XaResourceManager::xaCommitXid), xid));
 
54
              bind2nd(mem_fun(&XaResourceManager::xaCommitXid), xid));
53
55
  else
54
56
    transform(xa_resource_managers.begin(), xa_resource_managers.end(), results.begin(),
55
 
              std::bind2nd(std::mem_fun(&XaResourceManager::xaRollbackXid), xid));
 
57
              bind2nd(mem_fun(&XaResourceManager::xaRollbackXid), xid));
56
58
 
57
 
  if (std::find_if(results.begin(), results.end(), std::bind2nd(std::equal_to<int>(),0)) == results.end())
 
59
  if (find_if(results.begin(), results.end(), bind2nd(equal_to<int>(),0))
 
60
         == results.end())
58
61
    return 1;
59
 
 
60
62
  return 0;
61
63
}
62
64
 
76
78
    in this case commit_list.size()==0, tc_heuristic_recover == 0
77
79
    there should be no prepared transactions in this case.
78
80
*/
79
 
class XaRecover : std::unary_function<XaResourceManager *, void>
 
81
class XaRecover : unary_function<XaResourceManager *, void>
80
82
{
81
83
private:
82
84
  int trans_len, found_foreign_xids, found_my_xids;
182
184
    errmsg_printf(ERRMSG_LVL_INFO, _("Starting crash recovery..."));
183
185
 
184
186
  XaRecover recover_func(trans_list, trans_len, commit_list, dry_run);
185
 
  std::for_each(xa_resource_managers.begin(),
186
 
                xa_resource_managers.end(),
187
 
                recover_func);
 
187
  for_each(xa_resource_managers.begin(),
 
188
           xa_resource_managers.end(),
 
189
           recover_func);
188
190
  free(trans_list);
189
191
 
190
192
  if (recover_func.getForeignXIDs())