~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/transaction_log/utilities/transaction_log_connection.cc

  • Committer: Brian Aker
  • Date: 2011-11-26 23:14:59 UTC
  • mto: This revision was merged to the branch mainline in revision 2465.
  • Revision ID: brian@tangent.org-20111126231459-pa9i3arizevf0vlr
Remove con from being passed object.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
TransactionLogConnection::TransactionLogConnection(string &host, uint16_t port,
27
27
                                                   string &username, string &password,
28
 
                                                   bool drizzle_protocol)
29
 
  :
30
 
    hostName(host),
31
 
    drizzleProtocol(drizzle_protocol)
 
28
                                                   bool drizzle_protocol) :
 
29
  hostName(host),
 
30
  drizzleProtocol(drizzle_protocol)
32
31
{
33
32
  if (host.empty())
34
33
  {
40
39
  if (drizzle == NULL)
41
40
  {
42
41
    errorHandler(NULL, DRIZZLE_RETURN_MEMORY, "drizzle_create() failed");
43
 
    throw 1;
44
 
  }
45
 
  drizzle_con_create(drizzle, &connection);
46
 
  drizzle_con_set_tcp(&connection, (char *)host.c_str(), port);
47
 
  drizzle_con_set_auth(&connection, (char *)username.c_str(), (char *)password.c_str());
48
 
 
49
 
  drizzle_con_add_options(&connection,
50
 
    drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
51
 
 
52
 
  drizzle_return_t ret= drizzle_con_connect(&connection);
 
42
    throw "drizzle_create() failed";
 
43
  }
 
44
 
 
45
  connection= drizzle_con_create(drizzle);
 
46
  if (connection == NULL)
 
47
  {
 
48
    errorHandler(NULL, DRIZZLE_RETURN_MEMORY, "drizzle_create() failed");
 
49
    throw "drizzle_con_create() failed";
 
50
  }
 
51
  drizzle_con_set_tcp(connection, (char *)host.c_str(), port);
 
52
  drizzle_con_set_auth(connection, (char *)username.c_str(), (char *)password.c_str());
 
53
 
 
54
  drizzle_con_add_options(connection,
 
55
                          drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
 
56
 
 
57
  drizzle_return_t ret= drizzle_con_connect(connection);
53
58
 
54
59
  if (ret != DRIZZLE_RETURN_OK)
55
60
  {
63
68
{
64
69
  drizzle_return_t ret;
65
70
 
66
 
  if (drizzle_query_str(&connection, result, str_query.c_str(), &ret) == NULL ||
 
71
  if (drizzle_query_str(connection, result, str_query.c_str(), &ret) == NULL ||
67
72
      ret != DRIZZLE_RETURN_OK)
68
73
  {
69
74
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
75
80
    else
76
81
    {
77
82
      cerr << "Error executing query: " <<
78
 
        drizzle_con_error(&connection) << endl;
 
83
        drizzle_con_error(connection) << endl;
79
84
      drizzle_result_free(result);
80
85
    }
81
86
    return;
84
89
  if (drizzle_result_buffer(result) != DRIZZLE_RETURN_OK)
85
90
  {
86
91
    cerr << "Could not buffer result: " <<
87
 
        drizzle_con_error(&connection) << endl;
 
92
        drizzle_con_error(connection) << endl;
88
93
    drizzle_result_free(result);
89
94
    return;
90
95
  }
91
96
}
92
97
 
93
98
void TransactionLogConnection::errorHandler(drizzle_result_st *res,
94
 
  drizzle_return_t ret, const char *when)
 
99
                                            drizzle_return_t ret, const char *when)
95
100
{
96
101
  if (res == NULL)
97
102
  {
98
 
    cerr << "Got error: " << drizzle_con_error(&connection) << " " << when << endl;
 
103
    cerr << "Got error: " << drizzle_con_error(connection) << " " << when << endl;
99
104
  }
100
105
  else if (ret == DRIZZLE_RETURN_ERROR_CODE)
101
106
  {