~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Lee Bieber
  • Date: 2011-01-20 18:34:37 UTC
  • mfrom: (2098.1.2 build)
  • Revision ID: kalebral@gmail.com-20110120183437-n1fk7epcx48dzoqd
add BSD copyright to win32/config.h
Merge Monty - add missing windows files
Merge Shrews - The transaction_reader utility will use "SET AUTOCOMMIT=0" instead of "START TRANSACTION" for DDL, this allows us to now merge Stewart's branch 

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
  return true;
141
141
}
142
142
 
 
143
static bool isDDLStatement(const message::Statement &statement)
 
144
{
 
145
  bool isDDL;
 
146
 
 
147
  switch (statement.type())
 
148
  {
 
149
    case (message::Statement::TRUNCATE_TABLE):
 
150
    case (message::Statement::CREATE_SCHEMA):
 
151
    case (message::Statement::ALTER_SCHEMA):
 
152
    case (message::Statement::DROP_SCHEMA):
 
153
    case (message::Statement::CREATE_TABLE):
 
154
    case (message::Statement::ALTER_TABLE):
 
155
    case (message::Statement::DROP_TABLE):
 
156
    case (message::Statement::RAW_SQL):
 
157
    {
 
158
      isDDL= true;
 
159
      break;
 
160
    }
 
161
    default:
 
162
    {
 
163
      isDDL= false;
 
164
      break;
 
165
    }
 
166
  }
 
167
  
 
168
  return isDDL;
 
169
}
 
170
 
143
171
static bool isEndStatement(const message::Statement &statement)
144
172
{
145
173
  switch (statement.type())
370
398
  }
371
399
 
372
400
  size_t num_statements= transaction.statement_size();
373
 
  size_t x;
374
 
 
375
 
  /*
376
 
   * One way to determine when a new transaction begins is when the
377
 
   * transaction id changes (if all transactions have their GPB messages
378
 
   * grouped together, which this program will). We check that here.
379
 
   */
380
 
  if (trx.transaction_id() != last_trx_id)
381
 
    cout << "START TRANSACTION;" << endl;
382
 
 
383
 
  last_trx_id= trx.transaction_id();
384
 
 
385
401
  vector<string> cached_statement_sql;
386
402
 
387
 
  for (x= 0; x < num_statements; ++x)
 
403
  for (size_t x= 0; x < num_statements; ++x)
388
404
  {
389
405
    const message::Statement &statement= transaction.statement(x);
390
406
 
 
407
    /* Transactional DDL not supported yet. Use AUTOCOMMIT for DDL. */
 
408
    if (x == 0)
 
409
    {
 
410
      /* Transaction ID change means new transaction to start */
 
411
      if (trx.transaction_id() != last_trx_id)
 
412
      {
 
413
        if (isDDLStatement(statement))
 
414
        {
 
415
          cout << "SET AUTOCOMMIT=0;" << endl;
 
416
        }
 
417
        else
 
418
        {
 
419
          cout << "START TRANSACTION;" << endl;
 
420
        }
 
421
      }
 
422
  
 
423
      last_trx_id= trx.transaction_id();
 
424
    }
 
425
 
391
426
    if (should_commit)
392
427
      should_commit= isEndStatement(statement);
393
428