~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/slave/replication_schema.cc

  • Committer: Olaf van der Spek
  • Date: 2011-08-04 08:13:04 UTC
  • mfrom: (2384 drizzle)
  • mto: This revision was merged to the branch mainline in revision 2385.
  • Revision ID: olafvdspek@gmail.com-20110804081304-rlejjpvoos17bjdf
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
  if (not executeSQL(sql))
66
66
    return false;
67
67
 
68
 
#if 0
69
 
  sql.clear();
70
 
  sql.push_back("SELECT COUNT(*) FROM `sys_replication`.`io_state`");
71
 
 
72
 
  {
73
 
    sql::ResultSet result_set(1);
74
 
    Execute execute(*(_session.get()), true);
75
 
    execute.run(sql[0], result_set);
76
 
    result_set.next();
77
 
    string count= result_set.getString(0);
78
 
 
79
 
    /* Must always be at least one row in the table */
80
 
    if (count == "0")
81
 
    {
82
 
      sql.clear();
83
 
      sql.push_back("INSERT INTO `sys_replication`.`io_state` (`status`)"
84
 
                    " VALUES ('STOPPED')");
85
 
      if (not executeSQL(sql))
86
 
        return false;
87
 
    }
88
 
  }
89
 
#endif
90
 
 
91
68
  /*
92
69
   * Create our applier thread state information table if we need to.
93
70
   */
102
79
  sql.clear();
103
80
  sql.push_back("COMMIT");
104
81
  sql.push_back("CREATE TABLE IF NOT EXISTS `sys_replication`.`applier_state`"
105
 
                " (`last_applied_commit_id` BIGINT NOT NULL PRIMARY KEY,"
106
 
                " `master_id` BIGINT NOT NULL,"
 
82
                " (`master_id` BIGINT NOT NULL,"      
 
83
                " `last_applied_commit_id` BIGINT NOT NULL,"
107
84
                " `originating_server_uuid` VARCHAR(36) NOT NULL,"
108
85
                " `originating_commit_id` BIGINT NOT NULL,"
109
86
                " `status` VARCHAR(20) NOT NULL,"
113
90
  if (not executeSQL(sql))
114
91
    return false;
115
92
 
116
 
#if 0
117
 
  sql.clear();
118
 
  sql.push_back("SELECT COUNT(*) FROM `sys_replication`.`applier_state`");
119
 
 
120
 
  {
121
 
    sql::ResultSet result_set(1);
122
 
    Execute execute(*(_session.get()), true);
123
 
    execute.run(sql[0], result_set);
124
 
    result_set.next();
125
 
    string count= result_set.getString(0);
126
 
 
127
 
    /* Must always be at least one row in the table */
128
 
    if (count == "0")
129
 
    {
130
 
      sql.clear();
131
 
      sql.push_back("INSERT INTO `sys_replication`.`applier_state`"
132
 
                    " (`last_applied_commit_id`, `originating_server_uuid`,"
133
 
                    "  `originating_commit_id`, `status`)"
134
 
                    " VALUES (0, '', 0, 'STOPPED')");
135
 
      if (not executeSQL(sql))
136
 
        return false;
137
 
    }
138
 
  }
139
 
#endif
140
 
 
141
93
  /*
142
94
   * Create our message queue table if we need to.
143
95
   * Version 1.0: Initial definition
203
155
  {
204
156
    sql.clear();
205
157
    sql.push_back("INSERT INTO `sys_replication`.`applier_state`"
206
 
                  " (`master_id`, `last_applied_commit_id`, `status`) VALUES ("
 
158
                  " (`master_id`, `last_applied_commit_id`,"
 
159
                  " `originating_server_uuid`, `originating_commit_id`," 
 
160
                  " `status`) VALUES ("
207
161
                  + boost::lexical_cast<string>(master_id)
208
 
                  + ",0 , 'STOPPED')");
 
162
                  + ",0,"
 
163
                  + "'" + _session.get()->getServerUUID() + "'"
 
164
                  + ",0,'STOPPED')");
 
165
     
209
166
    if (not executeSQL(sql))
210
167
      return false;
211
168
  }