~skinny.moey/drizzle/bug755201

« back to all changes in this revision

Viewing changes to plugin/slave/queue_producer.cc

  • Committer: Lee Bieber
  • Date: 2011-03-28 18:11:45 UTC
  • mfrom: (2254.1.2 build)
  • Revision ID: kalebral@gmail.com-20110328181145-tfsb6s5ozhuvhfoq
Merge Patrick - Tweaked dbqp so that the existing slave tests work.
Merge Stewart - remove over 1000 lines of mysys

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);
302
307
   * The SQL to insert our results into the local queue.
303
308
   */
304
309
  string sql= "INSERT INTO `sys_replication`.`queue`"
305
 
              " (`trx_id`, `seg_id`, `commit_order`, `msg`) VALUES (";
 
310
              " (`master_id`, `trx_id`, `seg_id`, `commit_order`, `msg`) VALUES (";
 
311
  sql.append(boost::lexical_cast<string>(masterId()));
 
312
  sql.append(", ", 2);
306
313
  sql.append(trx_id);
307
314
  sql.append(", ", 2);
308
315
  sql.append(seg_id);
481
488
  }
482
489
  
483
490
  sql.append(msg);
484
 
  sql.append("'", 1);
 
491
  sql.append("' WHERE `master_id` = ");
 
492
  sql.append(boost::lexical_cast<string>(masterId()));
485
493
 
486
494
  statements.push_back(sql);
487
495
  executeSQL(statements);