~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2008-12-07 01:52:46 UTC
  • Revision ID: brian@tangent.org-20081207015246-debwl881w1y1s6zb
Updating new replication positions in code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2646
2646
  return(error);
2647
2647
}
2648
2648
 
2649
 
 
2650
 
/*
2651
 
  Member function that will log query, either row-based or
2652
 
  statement-based depending on the value of the 'current_stmt_binlog_row_based'
2653
 
  the value of the 'qtype' flag.
2654
 
 
2655
 
  This function should be called after the all calls to ha_*_row()
2656
 
  functions have been issued, but before tables are unlocked and
2657
 
  closed.
2658
 
 
2659
 
  OBSERVE
2660
 
    There shall be no writes to any system table after calling
2661
 
    binlog_query(), so these writes has to be moved to before the call
2662
 
    of binlog_query() for correct functioning.
2663
 
 
2664
 
    This is necessesary not only for RBR, but the master might crash
2665
 
    after binlogging the query but before changing the system tables.
2666
 
    This means that the slave and the master are not in the same state
2667
 
    (after the master has restarted), so therefore we have to
2668
 
    eliminate this problem.
2669
 
 
2670
 
  RETURN VALUE
2671
 
    Error code, or 0 if no error.
2672
 
*/
2673
 
int Session::binlog_query(Session::enum_binlog_query_type qtype, char const *query_arg,
2674
 
                      ulong query_len, bool is_trans, bool suppress_use,
2675
 
                      Session::killed_state killed_status_arg)
2676
 
{
2677
 
  assert(query_arg && drizzle_bin_log.is_open());
2678
 
 
2679
 
  if (int error= binlog_flush_pending_rows_event(true))
2680
 
    return(error);
2681
 
 
2682
 
  switch (qtype) {
2683
 
  case Session::ROW_QUERY_TYPE:
2684
 
    return(0);
2685
 
  case Session::DRIZZLE_QUERY_TYPE:
2686
 
    /*
2687
 
      Using this query type is a conveniece hack, since we have been
2688
 
      moving back and forth between using RBR for replication of
2689
 
      system tables and not using it.
2690
 
 
2691
 
      Make sure to change in check_table_binlog_row_based() according
2692
 
      to how you treat this.
2693
 
    */
2694
 
  case Session::STMT_QUERY_TYPE:
2695
 
    /*
2696
 
      The DRIZZLE_LOG::write() function will set the STMT_END_F flag and
2697
 
      flush the pending rows event if necessary.
2698
 
     */
2699
 
    {
2700
 
      Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use,
2701
 
                            killed_status_arg);
2702
 
      qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
2703
 
      /*
2704
 
        Binlog table maps will be irrelevant after a Query_log_event
2705
 
        (they are just removed on the slave side) so after the query
2706
 
        log event is written to the binary log, we pretend that no
2707
 
        table maps were written.
2708
 
       */
2709
 
      int error= drizzle_bin_log.write(&qinfo);
2710
 
      binlog_table_maps= 0;
2711
 
      return(error);
2712
 
    }
2713
 
    break;
2714
 
 
2715
 
  case Session::QUERY_TYPE_COUNT:
2716
 
  default:
2717
 
    assert(0 <= qtype && qtype < QUERY_TYPE_COUNT);
2718
 
  }
2719
 
  return(0);
2720
 
}
2721
 
 
2722
2649
bool Discrete_intervals_list::append(uint64_t start, uint64_t val,
2723
2650
                                 uint64_t incr)
2724
2651
{