~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/slave/queue_producer.cc

  • Committer: Mark Atwood
  • Date: 2011-07-06 23:13:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2361.
  • Revision ID: me@mark.atwood.name-20110706231300-y49o7wu01avy1jh5
restore multi master replication

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
22
21
#include <plugin/slave/queue_producer.h>
23
22
#include <drizzled/errmsg_print.h>
24
23
#include <drizzled/sql/result_set.h>
27
26
#include <drizzled/message/transaction.pb.h>
28
27
#include <boost/lexical_cast.hpp>
29
28
#include <google/protobuf/text_format.h>
 
29
#include <string>
 
30
#include <vector>
30
31
 
31
32
using namespace std;
32
33
using namespace drizzled;
199
200
   */
200
201
  string sql("SELECT MAX(x.cid) FROM"
201
202
             " (SELECT MAX(`commit_order`) AS cid FROM `sys_replication`.`queue`"
202
 
             "  UNION ALL SELECT `last_applied_commit_id` AS cid"
203
 
             "  FROM `sys_replication`.`applier_state`) AS x");
 
203
             "  WHERE `master_id` = "
 
204
             + boost::lexical_cast<string>(masterId())
 
205
             + "  UNION ALL SELECT `last_applied_commit_id` AS cid"
 
206
             + "  FROM `sys_replication`.`applier_state` WHERE `master_id` = "
 
207
             + boost::lexical_cast<string>(masterId())
 
208
             + ") AS x");
204
209
 
205
210
  sql::ResultSet result_set(1);
206
211
  Execute execute(*(_session.get()), true);
304
309
   * The SQL to insert our results into the local queue.
305
310
   */
306
311
  string sql= "INSERT INTO `sys_replication`.`queue`"
307
 
              " (`trx_id`, `seg_id`, `commit_order`,"
 
312
              " (`master_id`, `trx_id`, `seg_id`, `commit_order`,"
308
313
              "  `originating_server_uuid`, `originating_commit_id`, `msg`) VALUES (";
 
314
  sql.append(boost::lexical_cast<string>(masterId()));
 
315
  sql.append(", ", 2);
309
316
  sql.append(trx_id);
310
317
  sql.append(", ", 2);
311
318
  sql.append(seg_id);
490
497
  }
491
498
  
492
499
  sql.append(msg);
493
 
  sql.append("'", 1);
 
500
  sql.append("' WHERE `master_id` = ");
 
501
  sql.append(boost::lexical_cast<string>(masterId()));
494
502
 
495
503
  statements.push_back(sql);
496
504
  executeSQL(statements);