~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replication_services.cc

  • Committer: Jay Pipes
  • Date: 2010-03-15 23:02:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1351.
  • Revision ID: jpipes@serialcoder-20100315230206-kgjcldoq453205so
Move transactionContainsBulkSegment() to statement transform library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
  in_session->setTransactionMessage(NULL);
206
206
}
207
207
 
208
 
bool ReplicationServices::transactionContainsBulkSegment(const message::Transaction &transaction) const
209
 
{
210
 
  size_t num_statements= transaction.statement_size();
211
 
  if (num_statements == 0)
212
 
    return false;
213
 
 
214
 
  /*
215
 
   * Only INSERT, UPDATE, and DELETE statements can possibly
216
 
   * have bulk segments.  So, we loop through the statements
217
 
   * checking for segment_id > 1 in those specific submessages.
218
 
   */
219
 
  size_t x;
220
 
  for (x= 0; x < num_statements; ++x)
221
 
  {
222
 
    const message::Statement &statement= transaction.statement(x);
223
 
    message::Statement::Type type= statement.type();
224
 
 
225
 
    switch (type)
226
 
    {
227
 
      case message::Statement::INSERT:
228
 
        if (statement.insert_data().segment_id() > 1)
229
 
          return true;
230
 
        break;
231
 
      case message::Statement::UPDATE:
232
 
        if (statement.update_data().segment_id() > 1)
233
 
          return true;
234
 
        break;
235
 
      case message::Statement::DELETE:
236
 
        if (statement.delete_data().segment_id() > 1)
237
 
          return true;
238
 
        break;
239
 
      default:
240
 
        break;
241
 
    }
242
 
  }
243
 
  return false;
244
 
}
245
208
void ReplicationServices::commitTransaction(Session *in_session)
246
209
{
247
210
  if (! is_active)
306
269
   *    ROLLBACK to indicate to replicators that previously-transmitted
307
270
   *    messages must be un-applied.
308
271
   */
309
 
  if (unlikely(transactionContainsBulkSegment(*transaction)))
 
272
  if (unlikely(message::transactionContainsBulkSegment(*transaction)))
310
273
  {
311
274
    /*
312
275
     * Clear the transaction, create a Rollback statement message,