~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/db.cc

  • Committer: Brian Aker
  • Date: 2009-01-22 06:05:40 UTC
  • mto: This revision was merged to the branch mainline in revision 801.
  • Revision ID: brian@tangent.org-20090122060540-j9gqfa10gn8omgne
Converted db.cc away from using binlog

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <drizzled/server_includes.h>
26
26
#include <mysys/mysys_err.h>
27
27
#include <mysys/my_dir.h>
28
 
#include "log.h"
29
28
#include <drizzled/error.h>
30
29
#include <drizzled/gettext.h>
31
30
#include <mysys/hash.h>
34
33
#include <drizzled/sql_base.h>
35
34
#include <drizzled/lock.h>
36
35
#include <drizzled/errmsg_print.h>
 
36
#include <drizzled/replicator.h>
37
37
 
38
38
#define MAX_DROP_TABLE_Q_LEN      1024
39
39
 
139
139
  Helper function to write a query to binlog used by mysql_rm_db()
140
140
*/
141
141
 
142
 
static inline void write_to_binlog(Session *session, char *query, uint32_t q_len,
143
 
                                   char *db, uint32_t db_len)
 
142
static inline void write_to_binlog(Session *session, char *query, uint32_t query_length, char *, uint32_t)
144
143
{
145
 
  Query_log_event qinfo(session, query, q_len, 0, 0);
146
 
  qinfo.error_code= 0;
147
 
  qinfo.db= db;
148
 
  qinfo.db_len= db_len;
149
 
  drizzle_bin_log.write(&qinfo);
 
144
  (void)replicator_statement(session, query, query_length);
150
145
}
151
146
 
152
147
 
638
633
      query_length= session->query_length;
639
634
    }
640
635
 
641
 
    if (drizzle_bin_log.is_open())
642
 
    {
643
 
      Query_log_event qinfo(session, query, query_length, 0,
644
 
                            /* suppress_use */ true);
645
 
 
646
 
      /*
647
 
        Write should use the database being created as the "current
648
 
        database" and not the threads current database, which is the
649
 
        default. If we do not change the "current database" to the
650
 
        database being created, the CREATE statement will not be
651
 
        replicated when using --binlog-do-db to select databases to be
652
 
        replicated.
653
 
 
654
 
        An example (--binlog-do-db=sisyfos):
655
 
 
656
 
          CREATE DATABASE bob;        # Not replicated
657
 
          USE bob;                    # 'bob' is the current database
658
 
          CREATE DATABASE sisyfos;    # Not replicated since 'bob' is
659
 
                                      # current database.
660
 
          USE sisyfos;                # Will give error on slave since
661
 
                                      # database does not exist.
662
 
      */
663
 
      qinfo.db     = db;
664
 
      qinfo.db_len = strlen(db);
665
 
 
666
 
      /* These DDL methods and logging protected with LOCK_drizzle_create_db */
667
 
      drizzle_bin_log.write(&qinfo);
668
 
    }
 
636
    (void)replicator_statement(session, query, query_length);
669
637
    my_ok(session, result);
670
638
  }
671
639
 
721
689
    session->variables.collation_database= session->db_charset;
722
690
  }
723
691
 
724
 
  if (drizzle_bin_log.is_open())
725
 
  {
726
 
    Query_log_event qinfo(session, session->query, session->query_length, 0,
727
 
                          /* suppress_use */ true);
728
 
 
729
 
    /*
730
 
      Write should use the database being created as the "current
731
 
      database" and not the threads current database, which is the
732
 
      default.
733
 
    */
734
 
    qinfo.db     = db;
735
 
    qinfo.db_len = strlen(db);
736
 
 
737
 
    session->clear_error();
738
 
    /* These DDL methods and logging protected with LOCK_drizzle_create_db */
739
 
    drizzle_bin_log.write(&qinfo);
740
 
  }
 
692
  (void)replicator_statement(session, session->query, session->query_length);
741
693
  my_ok(session, result);
742
694
 
743
695
exit:
848
800
      query= session->query;
849
801
      query_length= session->query_length;
850
802
    }
851
 
    if (drizzle_bin_log.is_open())
852
 
    {
853
 
      Query_log_event qinfo(session, query, query_length, 0,
854
 
                            /* suppress_use */ true);
855
 
      /*
856
 
        Write should use the database being created as the "current
857
 
        database" and not the threads current database, which is the
858
 
        default.
859
 
      */
860
 
      qinfo.db     = db;
861
 
      qinfo.db_len = strlen(db);
862
 
 
863
 
      session->clear_error();
864
 
      /* These DDL methods and logging protected with LOCK_drizzle_create_db */
865
 
      drizzle_bin_log.write(&qinfo);
866
 
    }
 
803
    (void)replicator_statement(session, session->query, session->query_length);
867
804
    session->clear_error();
868
805
    session->server_status|= SERVER_STATUS_DB_DROPPED;
869
806
    my_ok(session, (uint32_t) deleted);
870
807
    session->server_status&= ~SERVER_STATUS_DB_DROPPED;
871
808
  }
872
 
  else if (drizzle_bin_log.is_open())
 
809
  else
873
810
  {
874
811
    char *query, *query_pos, *query_end, *query_data_start;
875
812
    TableList *tbl;