~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log.cc

  • Committer: Monty Taylor
  • Date: 2008-12-08 10:42:44 UTC
  • mfrom: (667 drizzle)
  • mto: This revision was merged to the branch mainline in revision 670.
  • Revision ID: monty@inaugust.com-20081208104244-fan1pe90li9df3ym
MergedĀ inĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
 
233
233
 
234
234
/*
235
 
  Truncate the binary log transaction cache.
236
 
 
237
 
  SYNPOSIS
238
 
    binlog_trans_log_truncate()
239
 
 
240
 
    session      The thread to take the binlog data from
241
 
    pos      Position to truncate to
242
 
 
243
 
  DESCRIPTION
244
 
 
245
 
    Truncate the binary log to the given position. Will not change
246
 
    anything else.
247
 
 
248
 
 */
249
 
static void
250
 
binlog_trans_log_truncate(Session *session, my_off_t pos)
251
 
{
252
 
  assert(session_get_ha_data(session, binlog_hton) != NULL);
253
 
  /* Only true if binlog_trans_log_savepos() wasn't called before */
254
 
  assert(pos != ~(my_off_t) 0);
255
 
 
256
 
  binlog_trx_data *const trx_data=
257
 
    (binlog_trx_data*) session_get_ha_data(session, binlog_hton);
258
 
  trx_data->truncate(pos);
259
 
  return;
260
 
}
261
 
 
262
 
 
263
 
/*
264
235
  this function is mostly a placeholder.
265
236
  conceptually, binlog initialization (now mostly done in DRIZZLE_BIN_LOG::open)
266
237
  should be moved here.
485
456
 
486
457
    Otherwise, we accumulate the statement
487
458
  */
 
459
 
488
460
  uint64_t const in_transaction=
489
461
    session->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN);
 
462
 
 
463
 
490
464
  if ((in_transaction && (all || (!trx_data->at_least_one_stmt && session->transaction.stmt.modified_non_trans_table))) || (!in_transaction && !all))
491
465
  {
492
466
    Query_log_event qev(session, STRING_WITH_LEN("COMMIT"), true, false);
493
467
    qev.error_code= 0; // see comment in DRIZZLE_LOG::write(Session, IO_CACHE)
494
468
    /* TODO: Fix return type */
 
469
    int error= binlog_end_trans(session, trx_data, &qev, all);
495
470
    (void)replicator_end_transaction(session, all, true);
496
 
    int error= binlog_end_trans(session, trx_data, &qev, all);
497
471
    return(error);
498
472
  }
499
473
  return(0);
520
494
  binlog_trx_data *const trx_data=
521
495
    (binlog_trx_data*) session_get_ha_data(session, binlog_hton);
522
496
 
523
 
  if (trx_data->empty()) {
 
497
  /* TODO: Fix return type */
 
498
  (void)replicator_end_transaction(session, all, false);
 
499
 
 
500
  if (trx_data->empty()) 
 
501
  {
524
502
    trx_data->reset();
 
503
 
525
504
    return(0);
526
505
  }
527
506
 
552
531
    error= binlog_end_trans(session, trx_data, 0, all);
553
532
  }
554
533
 
555
 
  /* TODO: Fix return type */
556
 
  (void)replicator_end_transaction(session, all, false);
557
 
 
558
534
  return(error);
559
535
}
560
536
 
584
560
 
585
561
static int binlog_savepoint_set(handlerton *, Session *session, void *sv)
586
562
{
587
 
  (void)replicator_savepoint_set(session, sv);
 
563
  bool error;
588
564
  binlog_trans_log_savepos(session, (my_off_t*) sv);
589
565
  /* Write it to the binary log */
590
566
 
591
 
  int const error=
592
 
    session->binlog_query(Session::STMT_QUERY_TYPE,
593
 
                      session->query, session->query_length, true, false);
 
567
  error= replicator_statement(session, session->query, session->query_length);
 
568
 
594
569
  return(error);
595
570
}
596
571
 
597
 
static int binlog_savepoint_rollback(handlerton *, Session *session, void *sv)
 
572
static int binlog_savepoint_rollback(handlerton *, Session *session, void *)
598
573
{
599
574
  bool error;
600
 
  /*
601
 
    Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some
602
 
    non-transactional table. Otherwise, truncate the binlog cache starting
603
 
    from the SAVEPOINT command.
604
 
  */
605
 
  if (unlikely(session->transaction.all.modified_non_trans_table ||
606
 
               (session->options & OPTION_KEEP_LOG)))
607
 
  {
608
 
    int error=
609
 
      session->binlog_query(Session::STMT_QUERY_TYPE,
610
 
                            session->query, session->query_length, true, false);
611
 
    return(error);
612
 
  }
613
 
  binlog_trans_log_truncate(session, *(my_off_t*)sv);
614
 
 
615
 
 
616
 
  error= replicator_rollback_to_savepoint(session, sv);
617
 
 
618
 
  return(0);
 
575
 
 
576
  error= replicator_statement(session, session->query, session->query_length);
 
577
 
 
578
  return error;
619
579
}
620
580
 
621
581