Commit 0a95bda2 authored by unknown's avatar unknown

Always use libtool with "--preserve-dup-deps"

Always use all LOAD DATA options in replication.
Fixed problem in mysqlbinlog where LOAD DATA options could be overwritten.


client/mysqlbinlog.cc:
  Ensure that we don't call init_dynamic_array() before my_init() has been done
configure.in:
  Always use libtool with "--preserve-dup-deps" to prevent link problems with g++
mysql-test/r/mysqlbinlog.result:
  new results
mysql-test/r/range.result:
  new results
mysql-test/t/range.test:
  add missing DROP TABLE
sql/log_event.cc:
  Always use all LOAD DATA options. This is needed to handle commands of type "FIELDS TERMINATED BY ''"
  Allocate memory for Create_file_log_event options as these may be overwritten in mysqlbinlog
sql/log_event.h:
  Free buffer
parent 82e82a88
...@@ -103,17 +103,18 @@ class Load_log_processor ...@@ -103,17 +103,18 @@ class Load_log_processor
} }
public: public:
Load_log_processor() Load_log_processor() {}
{
init_dynamic_array(&file_names,sizeof(Create_file_log_event*),
100,100 CALLER_INFO);
}
~Load_log_processor() ~Load_log_processor()
{ {
destroy(); destroy();
delete_dynamic(&file_names); delete_dynamic(&file_names);
} }
int init()
{
return init_dynamic_array(&file_names,sizeof(Create_file_log_event*),
100,100 CALLER_INFO);
}
void init_by_dir_name(const char *dir) void init_by_dir_name(const char *dir)
{ {
...@@ -350,7 +351,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, ...@@ -350,7 +351,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev,
filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT'
below. below.
*/ */
ce->print(result_file, short_form, last_db, true); ce->print(result_file, short_form, last_db, TRUE);
if (!old_format) if (!old_format)
{ {
if (load_processor.process(ce)) if (load_processor.process(ce))
...@@ -376,7 +377,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, ...@@ -376,7 +377,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev,
*/ */
if (ce) if (ce)
{ {
ce->print(result_file, short_form, last_db,true); ce->print(result_file, short_form, last_db, TRUE);
my_free((char*)ce->fname,MYF(MY_WME)); my_free((char*)ce->fname,MYF(MY_WME));
delete ce; delete ce;
} }
...@@ -458,6 +459,10 @@ void sql_print_error(const char *format,...) ...@@ -458,6 +459,10 @@ void sql_print_error(const char *format,...)
static void cleanup() static void cleanup()
{ {
my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) database, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) host, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) user, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) dirname_for_local_load, MYF(MY_ALLOW_ZERO_PTR));
} }
static void die(const char* fmt, ...) static void die(const char* fmt, ...)
...@@ -469,12 +474,13 @@ static void die(const char* fmt, ...) ...@@ -469,12 +474,13 @@ static void die(const char* fmt, ...)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
va_end(args); va_end(args);
cleanup(); cleanup();
my_end(0);
exit(1); exit(1);
} }
static void print_version() static void print_version()
{ {
printf("%s Ver 2.4 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
} }
...@@ -935,6 +941,8 @@ int main(int argc, char** argv) ...@@ -935,6 +941,8 @@ int main(int argc, char** argv)
dirname_for_local_load= my_tmpdir(&tmpdir); dirname_for_local_load= my_tmpdir(&tmpdir);
} }
if (load_processor.init())
exit(1);
if (dirname_for_local_load) if (dirname_for_local_load)
load_processor.init_by_dir_name(dirname_for_local_load); load_processor.init_by_dir_name(dirname_for_local_load);
else else
......
...@@ -194,6 +194,11 @@ AC_PROG_RANLIB ...@@ -194,6 +194,11 @@ AC_PROG_RANLIB
#AC_LIBTOOL_WIN32_DLL #AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
# Ensure that we have --preserve-dup-deps defines, otherwise we get link
# problems of 'mysql' with CXX=g++
LIBTOOL="$LIBTOOL --preserve-dup-deps"
AC_SUBST(LIBTOOL)dnl
#AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC #AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC
# AC_PROG_INSTALL # AC_PROG_INSTALL
......
...@@ -24,11 +24,11 @@ insert into t1 values ("abirvalg"); ...@@ -24,11 +24,11 @@ insert into t1 values ("abirvalg");
SET INSERT_ID=1; SET INSERT_ID=1;
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
insert into t2 values (); insert into t2 values ();
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
--- Broken LOAD DATA -- --- Broken LOAD DATA --
use test; use test;
...@@ -54,12 +54,12 @@ insert into t1 values ("abirvalg"); ...@@ -54,12 +54,12 @@ insert into t1 values ("abirvalg");
SET INSERT_ID=1; SET INSERT_ID=1;
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
insert into t2 values (); insert into t2 values ();
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-6-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-6-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
insert into t1 values ("Alas"); insert into t1 values ("Alas");
......
...@@ -313,3 +313,4 @@ WHERE ...@@ -313,3 +313,4 @@ WHERE
a b a b
15 1 15 1
47 1 47 1
DROP TABLE t1;
...@@ -263,3 +263,4 @@ WHERE ...@@ -263,3 +263,4 @@ WHERE
( b =3 AND a BETWEEN 15 AND 19 ) OR ( b =3 AND a BETWEEN 15 AND 19 ) OR
(a BETWEEN 19 AND 47) (a BETWEEN 19 AND 47)
); );
DROP TABLE t1;
...@@ -293,40 +293,21 @@ void Load_log_event::pack_info(String* packet) ...@@ -293,40 +293,21 @@ void Load_log_event::pack_info(String* packet)
else if (sql_ex.opt_flags & IGNORE_FLAG) else if (sql_ex.opt_flags & IGNORE_FLAG)
tmp.append(" IGNORE "); tmp.append(" IGNORE ");
tmp.append("INTO TABLE "); tmp.append("INTO TABLE `");
tmp.append(table_name); tmp.append(table_name);
if (sql_ex.field_term_len) tmp.append("` FIELDS TERMINATED BY ");
{ pretty_print_str(&tmp, sql_ex.field_term, sql_ex.field_term_len);
tmp.append(" FIELDS TERMINATED BY "); if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG )
pretty_print_str(&tmp, sql_ex.field_term, sql_ex.field_term_len); tmp.append(" OPTIONALLY ");
} tmp.append( " ENCLOSED BY ");
pretty_print_str(&tmp, sql_ex.enclosed, sql_ex.enclosed_len);
if (sql_ex.enclosed_len) tmp.append( " ESCAPED BY ");
{ pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_len);
if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG )
tmp.append(" OPTIONALLY ");
tmp.append( " ENCLOSED BY ");
pretty_print_str(&tmp, sql_ex.enclosed, sql_ex.enclosed_len);
}
if (sql_ex.escaped_len)
{
tmp.append( " ESCAPED BY ");
pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_len);
}
bool line_lexem_added= false; tmp.append(" LINES TERMINATED BY ");
if (sql_ex.line_term_len) pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len);
{
tmp.append(" LINES TERMINATED BY ");
pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len);
line_lexem_added= true;
}
if (sql_ex.line_start_len) if (sql_ex.line_start_len)
{ {
if (!line_lexem_added)
tmp.append(" LINES");
tmp.append(" STARTING BY "); tmp.append(" STARTING BY ");
pretty_print_str(&tmp, sql_ex.line_start, sql_ex.line_start_len); pretty_print_str(&tmp, sql_ex.line_start, sql_ex.line_start_len);
} }
...@@ -1323,7 +1304,8 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) ...@@ -1323,7 +1304,8 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db)
print(file, short_form, last_db, 0); print(file, short_form, last_db, 0);
} }
void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool commented) void Load_log_event::print(FILE* file, bool short_form, char* last_db,
bool commented)
{ {
if (!short_form) if (!short_form)
{ {
...@@ -1354,40 +1336,22 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool comm ...@@ -1354,40 +1336,22 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool comm
fprintf(file," REPLACE "); fprintf(file," REPLACE ");
else if (sql_ex.opt_flags & IGNORE_FLAG ) else if (sql_ex.opt_flags & IGNORE_FLAG )
fprintf(file," IGNORE "); fprintf(file," IGNORE ");
fprintf(file, "INTO TABLE %s ", table_name);
if (sql_ex.field_term)
{
fprintf(file, " FIELDS TERMINATED BY ");
pretty_print_str(file, sql_ex.field_term, sql_ex.field_term_len);
}
if (sql_ex.enclosed) fprintf(file, "INTO TABLE `%s`", table_name);
{ fprintf(file, " FIELDS TERMINATED BY ");
if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) pretty_print_str(file, sql_ex.field_term, sql_ex.field_term_len);
fprintf(file," OPTIONALLY ");
fprintf(file, " ENCLOSED BY "); if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG )
pretty_print_str(file, sql_ex.enclosed, sql_ex.enclosed_len); fprintf(file," OPTIONALLY ");
} fprintf(file, " ENCLOSED BY ");
pretty_print_str(file, sql_ex.enclosed, sql_ex.enclosed_len);
if (sql_ex.escaped) fprintf(file, " ESCAPED BY ");
{ pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len);
fprintf(file, " ESCAPED BY "); fprintf(file," LINES TERMINATED BY ");
pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len); pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len);
}
bool line_lexem_added= false;
if (sql_ex.line_term)
{
fprintf(file," LINES TERMINATED BY ");
pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len);
line_lexem_added= true;
}
if (sql_ex.line_start) if (sql_ex.line_start)
{ {
if (!line_lexem_added)
fprintf(file," LINES");
fprintf(file," STARTING BY "); fprintf(file," STARTING BY ");
pretty_print_str(file, sql_ex.line_start, sql_ex.line_start_len); pretty_print_str(file, sql_ex.line_start, sql_ex.line_start_len);
} }
...@@ -1546,7 +1510,7 @@ Create_file_log_event(THD* thd_arg, sql_exchange* ex, ...@@ -1546,7 +1510,7 @@ Create_file_log_event(THD* thd_arg, sql_exchange* ex,
char* block_arg, uint block_len_arg, bool using_trans) char* block_arg, uint block_len_arg, bool using_trans)
:Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup, :Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup,
using_trans), using_trans),
fake_base(0),block(block_arg),block_len(block_len_arg), fake_base(0),block(block_arg), event_buf(0), block_len(block_len_arg),
file_id(thd_arg->file_id = mysql_bin_log.next_file_id()) file_id(thd_arg->file_id = mysql_bin_log.next_file_id())
{ {
sql_ex.force_new_format(); sql_ex.force_new_format();
...@@ -1586,8 +1550,16 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len, ...@@ -1586,8 +1550,16 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len,
:Load_log_event(buf,0,old_format),fake_base(0),block(0),inited_from_old(0) :Load_log_event(buf,0,old_format),fake_base(0),block(0),inited_from_old(0)
{ {
int block_offset; int block_offset;
if (copy_log_event(buf,len,old_format)) DBUG_ENTER("Create_file_log_event");
return;
/*
We must make copy of 'buf' as this event may have to live over a
rotate log entry when used in mysqlbinlog
*/
if (!(event_buf= my_memdup(buf, len, MYF(MY_WME))) ||
(copy_log_event(event_buf, len, old_format)))
DBUG_VOID_RETURN;
if (!old_format) if (!old_format)
{ {
file_id = uint4korr(buf + LOG_EVENT_HEADER_LEN + file_id = uint4korr(buf + LOG_EVENT_HEADER_LEN +
...@@ -1605,6 +1577,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len, ...@@ -1605,6 +1577,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len,
sql_ex.force_new_format(); sql_ex.force_new_format();
inited_from_old = 1; inited_from_old = 1;
} }
DBUG_VOID_RETURN;
} }
......
...@@ -644,6 +644,7 @@ class Create_file_log_event: public Load_log_event ...@@ -644,6 +644,7 @@ class Create_file_log_event: public Load_log_event
bool fake_base; bool fake_base;
public: public:
char* block; char* block;
const char *event_buf;
uint block_len; uint block_len;
uint file_id; uint file_id;
bool inited_from_old; bool inited_from_old;
...@@ -663,7 +664,10 @@ class Create_file_log_event: public Load_log_event ...@@ -663,7 +664,10 @@ class Create_file_log_event: public Load_log_event
#endif #endif
Create_file_log_event(const char* buf, int event_len, bool old_format); Create_file_log_event(const char* buf, int event_len, bool old_format);
~Create_file_log_event() {} ~Create_file_log_event()
{
my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR));
}
Log_event_type get_type_code() Log_event_type get_type_code()
{ {
......
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