~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.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:
2673
2673
  return(error);
2674
2674
}
2675
2675
 
2676
 
 
2677
 
/*
2678
 
  Member function that will log query, either row-based or
2679
 
  statement-based depending on the value of the 'current_stmt_binlog_row_based'
2680
 
  the value of the 'qtype' flag.
2681
 
 
2682
 
  This function should be called after the all calls to ha_*_row()
2683
 
  functions have been issued, but before tables are unlocked and
2684
 
  closed.
2685
 
 
2686
 
  OBSERVE
2687
 
    There shall be no writes to any system table after calling
2688
 
    binlog_query(), so these writes has to be moved to before the call
2689
 
    of binlog_query() for correct functioning.
2690
 
 
2691
 
    This is necessesary not only for RBR, but the master might crash
2692
 
    after binlogging the query but before changing the system tables.
2693
 
    This means that the slave and the master are not in the same state
2694
 
    (after the master has restarted), so therefore we have to
2695
 
    eliminate this problem.
2696
 
 
2697
 
  RETURN VALUE
2698
 
    Error code, or 0 if no error.
2699
 
*/
2700
 
int Session::binlog_query(Session::enum_binlog_query_type qtype, char const *query_arg,
2701
 
                      ulong query_len, bool is_trans, bool suppress_use,
2702
 
                      Session::killed_state killed_status_arg)
2703
 
{
2704
 
  assert(query_arg && drizzle_bin_log.is_open());
2705
 
 
2706
 
  if (int error= binlog_flush_pending_rows_event(true))
2707
 
    return(error);
2708
 
 
2709
 
  switch (qtype) {
2710
 
  case Session::ROW_QUERY_TYPE:
2711
 
    return(0);
2712
 
  case Session::DRIZZLE_QUERY_TYPE:
2713
 
    /*
2714
 
      Using this query type is a conveniece hack, since we have been
2715
 
      moving back and forth between using RBR for replication of
2716
 
      system tables and not using it.
2717
 
 
2718
 
      Make sure to change in check_table_binlog_row_based() according
2719
 
      to how you treat this.
2720
 
    */
2721
 
  case Session::STMT_QUERY_TYPE:
2722
 
    /*
2723
 
      The DRIZZLE_LOG::write() function will set the STMT_END_F flag and
2724
 
      flush the pending rows event if necessary.
2725
 
     */
2726
 
    {
2727
 
      Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use,
2728
 
                            killed_status_arg);
2729
 
      qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
2730
 
      /*
2731
 
        Binlog table maps will be irrelevant after a Query_log_event
2732
 
        (they are just removed on the slave side) so after the query
2733
 
        log event is written to the binary log, we pretend that no
2734
 
        table maps were written.
2735
 
       */
2736
 
      int error= drizzle_bin_log.write(&qinfo);
2737
 
      binlog_table_maps= 0;
2738
 
      return(error);
2739
 
    }
2740
 
    break;
2741
 
 
2742
 
  case Session::QUERY_TYPE_COUNT:
2743
 
  default:
2744
 
    assert(0 <= qtype && qtype < QUERY_TYPE_COUNT);
2745
 
  }
2746
 
  return(0);
2747
 
}
2748
 
 
2749
2676
bool Discrete_intervals_list::append(uint64_t start, uint64_t val,
2750
2677
                                 uint64_t incr)
2751
2678
{