make LOAD DATA INFILE replication work with multi-character

delimiters/starters/terminators

started work on server management daemon
parent 440bff25
...@@ -6,8 +6,8 @@ master-bin.001 200 Query 1 4 use test; insert into t1 values (NULL) ...@@ -6,8 +6,8 @@ master-bin.001 200 Query 1 4 use test; insert into t1 values (NULL)
master-bin.001 263 Query 1 5 use test; drop table t1 master-bin.001 263 Query 1 5 use test; drop table t1
master-bin.001 311 Query 1 6 use test; create table t1 (word char(20) not null) master-bin.001 311 Query 1 6 use test; create table t1 (word char(20) not null)
master-bin.001 386 Create_file 1 7 db=test;table=t1;file_id=1;block_len=81 master-bin.001 386 Create_file 1 7 db=test;table=t1;file_id=1;block_len=81
master-bin.001 554 Exec_load 1 8 ;file_id=1 master-bin.001 556 Exec_load 1 8 ;file_id=1
master-bin.001 577 Query 1 9 use test; drop table t1 master-bin.001 579 Query 1 9 use test; drop table t1
Log_name Pos Event_type Server_id Log_seq Info Log_name Pos Event_type Server_id Log_seq Info
master-bin.001 79 Query 1 2 use test; create table t1(n int not null auto_increment primary key) master-bin.001 79 Query 1 2 use test; create table t1(n int not null auto_increment primary key)
Log_name Pos Event_type Server_id Log_seq Info Log_name Pos Event_type Server_id Log_seq Info
...@@ -23,10 +23,10 @@ master-bin.001 200 Query 1 4 use test; insert into t1 values (NULL) ...@@ -23,10 +23,10 @@ master-bin.001 200 Query 1 4 use test; insert into t1 values (NULL)
master-bin.001 263 Query 1 5 use test; drop table t1 master-bin.001 263 Query 1 5 use test; drop table t1
master-bin.001 311 Query 1 6 use test; create table t1 (word char(20) not null) master-bin.001 311 Query 1 6 use test; create table t1 (word char(20) not null)
master-bin.001 386 Create_file 1 7 db=test;table=t1;file_id=1;block_len=81 master-bin.001 386 Create_file 1 7 db=test;table=t1;file_id=1;block_len=81
master-bin.001 554 Exec_load 1 8 ;file_id=1 master-bin.001 556 Exec_load 1 8 ;file_id=1
master-bin.001 577 Query 1 9 use test; drop table t1 master-bin.001 579 Query 1 9 use test; drop table t1
master-bin.001 625 Rotate 1 10 master-bin.002;pos=4 master-bin.001 627 Rotate 1 10 master-bin.002;pos=4
master-bin.001 666 Stop 1 11 master-bin.001 668 Stop 1 11
Log_name Pos Event_type Server_id Log_seq Info Log_name Pos Event_type Server_id Log_seq Info
master-bin.002 4 Start 1 1 Server ver: $VERSION, Binlog ver: 2 master-bin.002 4 Start 1 1 Server ver: $VERSION, Binlog ver: 2
master-bin.002 79 Query 1 2 use test; create table t1 (n int) master-bin.002 79 Query 1 2 use test; create table t1 (n int)
...@@ -47,10 +47,10 @@ slave-bin.001 253 Query 1 4 use test; insert into t1 values (NULL) ...@@ -47,10 +47,10 @@ slave-bin.001 253 Query 1 4 use test; insert into t1 values (NULL)
slave-bin.001 316 Query 1 5 use test; drop table t1 slave-bin.001 316 Query 1 5 use test; drop table t1
slave-bin.001 364 Query 1 6 use test; create table t1 (word char(20) not null) slave-bin.001 364 Query 1 6 use test; create table t1 (word char(20) not null)
slave-bin.001 439 Create_file 1 7 db=test;table=t1;file_id=1;block_len=81 slave-bin.001 439 Create_file 1 7 db=test;table=t1;file_id=1;block_len=81
slave-bin.001 616 Exec_load 1 8 ;file_id=1 slave-bin.001 618 Exec_load 1 8 ;file_id=1
slave-bin.001 639 Query 1 9 use test; drop table t1 slave-bin.001 641 Query 1 9 use test; drop table t1
slave-bin.001 687 Rotate 1 4 slave-bin.002;pos=4; forced by master slave-bin.001 689 Rotate 1 4 slave-bin.002;pos=4; forced by master
slave-bin.001 727 Stop 2 5 slave-bin.001 729 Stop 2 5
Log_name Pos Event_type Server_id Log_seq Info Log_name Pos Event_type Server_id Log_seq Info
slave-bin.002 4 Start 2 1 Server ver: $VERSION, Binlog ver: 2 slave-bin.002 4 Start 2 1 Server ver: $VERSION, Binlog ver: 2
slave-bin.002 79 Slave 2 10 host=127.0.0.1,port=$MASTER_MYPORT,log=master-bin.002,pos=4 slave-bin.002 79 Slave 2 10 host=127.0.0.1,port=$MASTER_MYPORT,log=master-bin.002,pos=4
......
This diff is collapsed.
...@@ -53,16 +53,46 @@ ...@@ -53,16 +53,46 @@
#define LINE_START_EMPTY 0x8 #define LINE_START_EMPTY 0x8
#define ESCAPED_EMPTY 0x10 #define ESCAPED_EMPTY 0x10
struct old_sql_ex
struct sql_ex_info
{ {
char field_term; char field_term;
char enclosed; char enclosed;
char line_term; char line_term;
char line_start; char line_start;
char escaped; char escaped;
char opt_flags; // flags for the options char opt_flags;
char empty_flags; // flags to indicate which of the terminating charact char empty_flags;
};
struct sql_ex_info
{
char* field_term;
char* enclosed;
char* line_term;
char* line_start;
char* escaped;
uchar field_term_len,enclosed_len,line_term_len,line_start_len,
escaped_len;
char opt_flags;
char empty_flags;
int cached_new_format;
// store in new format even if old is possible
void force_new_format() { cached_new_format = 1;}
int data_size() { return new_format() ?
field_term_len + enclosed_len + line_term_len +
line_start_len + escaped_len + 6 : 7;}
int write_data(IO_CACHE* file);
char* init(char* buf,char* buf_end,bool use_new_format);
bool new_format()
{
return (cached_new_format != -1) ? cached_new_format :
(cached_new_format=(field_term_len > 1 ||
enclosed_len > 1 ||
line_term_len > 1 || line_start_len > 1 ||
escaped_len > 1));
}
} ; } ;
/* Binary log consists of events. Each event has a fixed length header, /* Binary log consists of events. Each event has a fixed length header,
...@@ -76,7 +106,7 @@ struct sql_ex_info ...@@ -76,7 +106,7 @@ struct sql_ex_info
/* event-specific post-header sizes */ /* event-specific post-header sizes */
#define LOG_EVENT_HEADER_LEN 19 #define LOG_EVENT_HEADER_LEN 19
#define QUERY_HEADER_LEN (4 + 4 + 1 + 2) #define QUERY_HEADER_LEN (4 + 4 + 1 + 2)
#define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4+sizeof(struct sql_ex_info)) #define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4)
#define START_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4) #define START_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4)
#define ROTATE_HEADER_LEN 8 #define ROTATE_HEADER_LEN 8
#define CREATE_FILE_HEADER_LEN 4 #define CREATE_FILE_HEADER_LEN 4
...@@ -162,7 +192,8 @@ struct sql_ex_info ...@@ -162,7 +192,8 @@ struct sql_ex_info
enum Log_event_type { START_EVENT = 1, QUERY_EVENT =2, enum Log_event_type { START_EVENT = 1, QUERY_EVENT =2,
STOP_EVENT=3, ROTATE_EVENT = 4, INTVAR_EVENT=5, STOP_EVENT=3, ROTATE_EVENT = 4, INTVAR_EVENT=5,
LOAD_EVENT=6, SLAVE_EVENT=7, CREATE_FILE_EVENT=8, LOAD_EVENT=6, SLAVE_EVENT=7, CREATE_FILE_EVENT=8,
APPEND_BLOCK_EVENT=9, EXEC_LOAD_EVENT=10, DELETE_FILE_EVENT=11}; APPEND_BLOCK_EVENT=9, EXEC_LOAD_EVENT=10, DELETE_FILE_EVENT=11,
NEW_LOAD_EVENT=12};
enum Int_event_type { INVALID_INT_EVENT = 0, LAST_INSERT_ID_EVENT = 1, INSERT_ID_EVENT = 2 enum Int_event_type { INVALID_INT_EVENT = 0, LAST_INSERT_ID_EVENT = 1, INSERT_ID_EVENT = 2
}; };
...@@ -359,7 +390,6 @@ public: ...@@ -359,7 +390,6 @@ public:
const char* table_name; const char* table_name;
const char* db; const char* db;
const char* fname; const char* fname;
bool fname_null_term;
uint32 skip_lines; uint32 skip_lines;
sql_ex_info sql_ex; sql_ex_info sql_ex;
...@@ -384,7 +414,8 @@ public: ...@@ -384,7 +414,8 @@ public:
~Load_log_event() ~Load_log_event()
{ {
} }
Log_event_type get_type_code() { return LOAD_EVENT; } Log_event_type get_type_code() { return sql_ex.new_format() ?
NEW_LOAD_EVENT: LOAD_EVENT; }
int write_data_header(IO_CACHE* file); int write_data_header(IO_CACHE* file);
int write_data_body(IO_CACHE* file); int write_data_body(IO_CACHE* file);
bool is_valid() { return table_name != 0; } bool is_valid() { return table_name != 0; }
...@@ -395,7 +426,7 @@ public: ...@@ -395,7 +426,7 @@ public:
+ 4 // exec_time + 4 // exec_time
+ 4 // skip_lines + 4 // skip_lines
+ 4 // field block len + 4 // field block len
+ sizeof(sql_ex) + field_block_len + num_fields; + sql_ex.data_size() + field_block_len + num_fields;
; ;
} }
int get_data_body_offset() { return LOAD_EVENT_OVERHEAD; } int get_data_body_offset() { return LOAD_EVENT_OVERHEAD; }
...@@ -545,8 +576,10 @@ public: ...@@ -545,8 +576,10 @@ public:
~Create_file_log_event() ~Create_file_log_event()
{ {
} }
Log_event_type get_type_code() { return fake_base ? LOAD_EVENT : Log_event_type get_type_code()
CREATE_FILE_EVENT;} {
return fake_base ? Load_log_event::get_type_code() : CREATE_FILE_EVENT;
}
int get_data_size() { return fake_base ? Load_log_event::get_data_size() : int get_data_size() { return fake_base ? Load_log_event::get_data_size() :
Load_log_event::get_data_size() + Load_log_event::get_data_size() +
4 + 1 + block_len;} 4 + 1 + block_len;}
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* MySQL server management daemon
*
* Written by:
* Sasha Pachev <sasha@mysql.com>
**/
#define VERSION "1.0"
#include <global.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql.h>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment