From f54789bdfe74216eebf758e891c1bc699792cc47 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Thu, 5 Feb 2004 16:04:43 +0200 Subject: [PATCH 1/8] sql_load.cc: Added a comment for already pushed bug fix --- sql/sql_load.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 93dfcd84caf..3b8672188d4 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -93,6 +93,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, char *db = table_list->db; // This is never null /* If no current database, use database where table is located */ char *tdb= thd->db ? thd->db : db; + /* + 'tdb' can be NULL only if both table_list->db and thd->db are NULL + 'db' itself can be NULL. but in that case it will generate + an error earlier open_ltable()). + */ bool transactional_table, log_delayed; ulong skip_lines= ex->skip_lines; DBUG_ENTER("mysql_load"); From b8866d929d9e6f89f5d2da8dccb5e7d12cfa41c9 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 12 Feb 2004 15:53:47 +0100 Subject: [PATCH 2/8] - always use CXX=gcc (not only when using gcc 3) to avoid a dependency on libstdc++ and exceptions --- support-files/mysql.spec.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 3ee602e7504..b69d6961f37 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -258,10 +258,11 @@ export PATH # Build the 4.0 Max binary (includes BDB and UDFs and therefore # cannot be linked statically against the patched glibc) -# If we want to compile with RAID using gcc 3, we need to use -# gcc instead of g++ to avoid linking problems (RAID code is written in C++) -test -z $CXX && test -z $CC && if gcc -v 2>&1 | grep 'gcc version 3' > /dev/null 2>&1 +# Use gcc for C and C++ code (to avoid a dependency on libstdc++ and +# including exceptions into the code +test -z $CXX && test -z $CC then + export CC="gcc" export CXX="gcc" fi @@ -573,6 +574,10 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Thu Feb 12 2004 Lenz Grimmer + +- when using gcc, _always_ use CXX=gcc + * Tue Feb 03 2004 Lenz Grimmer - added myisam_ftdump to the Server package From 4e42ac4f9ec9fc4bf945ffd8f69110bec69f64a9 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 12 Feb 2004 16:51:52 +0100 Subject: [PATCH 3/8] - fixed broken shellcode --- support-files/mysql.spec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b69d6961f37..18f41ed5326 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -260,7 +260,7 @@ export PATH # Use gcc for C and C++ code (to avoid a dependency on libstdc++ and # including exceptions into the code -test -z $CXX && test -z $CC +if [ -z "$CXX" -a -z "$CC" ] then export CC="gcc" export CXX="gcc" From 0588ac7736b73fca5531fd0cc1949840ce724870 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 12 Feb 2004 17:12:08 +0100 Subject: [PATCH 4/8] - Replaced obsolete "Copyright" field with "License" in the RPM spec file --- support-files/mysql.spec.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 18f41ed5326..cea9c112b8b 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -16,7 +16,7 @@ Summary(pt_BR): MySQL: Um servidor SQL r Group(pt_BR): Aplicações/Banco_de_Dados Version: @MYSQL_NO_DASH_VERSION@ Release: %{release} -Copyright: GPL +License: GPL Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz URL: http://www.mysql.com/ Packager: Lenz Grimmer @@ -577,6 +577,7 @@ fi * Thu Feb 12 2004 Lenz Grimmer - when using gcc, _always_ use CXX=gcc +- replaced Copyright with License field (Copyright is obsolete) * Tue Feb 03 2004 Lenz Grimmer From 09b90901add0f125e7f6128c74fa963eabca43ba Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 12 Feb 2004 19:33:06 +0100 Subject: [PATCH 5/8] - bumped up version number in configure.in from 4.0.18 -> 4.0.19 - Tagged ChangeSet@1.1733 as mysql-4.0.18 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 5ed2105be89..1fa9e1c5a38 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.18) +AM_INIT_AUTOMAKE(mysql, 4.0.19) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 5b369431f1a458f960155d71be457474f6f05eea Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Thu, 12 Feb 2004 23:45:39 +0400 Subject: [PATCH 6/8] fixed copying of color in SEL_ARG::clone (fixed bug #2968) --- mysql-test/r/select_found.result | 18 ++++++++++++++++++ mysql-test/t/select_found.test | 28 ++++++++++++++++++++++++++++ sql/opt_range.cc | 1 + 3 files changed, 47 insertions(+) diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result index 419ffb73d59..367bdd798b4 100644 --- a/mysql-test/r/select_found.result +++ b/mysql-test/r/select_found.result @@ -188,3 +188,21 @@ select FOUND_ROWS(); FOUND_ROWS() 0 drop table t1; +CREATE TABLE t1 ( a int not null, b int not null, KEY ab(a,b) ); +INSERT INTO t1 VALUES ( 47, 1 ); +INSERT INTO t1 VALUES ( 70, 1 ); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) +); +a b +DROP TABLE t1; +CREATE TABLE t1 ( a integer, u varchar(15), r integer, key uao_idx( r, a, u)); +DELETE FROM t1 +WHERE ( r = 1 AND a IN ( 1, 2 ) AND ( u = 'w' OR u LIKE 'w/%' ) ) +OR ( r = 1 AND a IN ( 3 ) AND ( u = 'w/U' OR u LIKE 'w/U/%' ) ) +OR ( r = 1 AND a IN ( 1, 2, 3 ) AND ( u = 'w' ) ); +drop table t1; diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index f5ee4d5c010..e584fca206f 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -99,3 +99,31 @@ select FOUND_ROWS(); select SQL_CALC_FOUND_ROWS * from t1 where id > 6 limit 0, 1; select FOUND_ROWS(); drop table t1; + +# +# Other bugs with range optimization +# + +# bug #2448 + +CREATE TABLE t1 ( a int not null, b int not null, KEY ab(a,b) ); +INSERT INTO t1 VALUES ( 47, 1 ); +INSERT INTO t1 VALUES ( 70, 1 ); +SELECT * FROM t1 +WHERE +( + ( b =1 AND a BETWEEN 14 AND 21 ) OR + ( b =2 AND a BETWEEN 16 AND 18 ) OR + ( b =3 AND a BETWEEN 15 AND 19 ) +); +DROP TABLE t1; + +# bug #2698 + +CREATE TABLE t1 ( a integer, u varchar(15), r integer, key uao_idx( r, a, u)); +DELETE FROM t1 +WHERE ( r = 1 AND a IN ( 1, 2 ) AND ( u = 'w' OR u LIKE 'w/%' ) ) + OR ( r = 1 AND a IN ( 3 ) AND ( u = 'w/U' OR u LIKE 'w/U/%' ) ) + OR ( r = 1 AND a IN ( 1, 2, 3 ) AND ( u = 'w' ) ); +drop table t1; + diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 188d503b767..0ed5c447486 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -488,6 +488,7 @@ SEL_ARG *SEL_ARG::clone(SEL_ARG *new_parent,SEL_ARG **next_arg) return 0; // OOM } increment_use_count(1); + tmp->color= color; return tmp; } From fb8f27f0172d12507f24551624f0f77315ea2763 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 13 Feb 2004 16:05:09 +0200 Subject: [PATCH 7/8] 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 | 34 +++++++---- configure.in | 5 ++ mysql-test/r/mysqlbinlog.result | 22 +++---- mysql-test/r/range.result | 1 + mysql-test/t/range.test | 1 + sql/log_event.cc | 101 ++++++++++++-------------------- sql/log_event.h | 6 +- 7 files changed, 81 insertions(+), 89 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 90c3cfc98f6..71819070a85 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -103,17 +103,18 @@ class Load_log_processor } public: - Load_log_processor() - { - init_dynamic_array(&file_names,sizeof(Create_file_log_event*), - 100,100 CALLER_INFO); - } - + Load_log_processor() {} ~Load_log_processor() - { - destroy(); - delete_dynamic(&file_names); - } + { + destroy(); + 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) { @@ -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' below. */ - ce->print(result_file, short_form, last_db, true); + ce->print(result_file, short_form, last_db, TRUE); if (!old_format) { if (load_processor.process(ce)) @@ -376,7 +377,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, */ 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)); delete ce; } @@ -458,6 +459,10 @@ void sql_print_error(const char *format,...) static void cleanup() { 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, ...) @@ -469,12 +474,13 @@ static void die(const char* fmt, ...) fprintf(stderr, "\n"); va_end(args); cleanup(); + my_end(0); exit(1); } 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) dirname_for_local_load= my_tmpdir(&tmpdir); } + if (load_processor.init()) + exit(1); if (dirname_for_local_load) load_processor.init_by_dir_name(dirname_for_local_load); else diff --git a/configure.in b/configure.in index 5ed2105be89..ad1feefdd98 100644 --- a/configure.in +++ b/configure.in @@ -194,6 +194,11 @@ AC_PROG_RANLIB #AC_LIBTOOL_WIN32_DLL 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_PROG_INSTALL diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index f604aa0589e..df472eb9c80 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -24,11 +24,11 @@ insert into t1 values ("abirvalg"); SET INSERT_ID=1; SET TIMESTAMP=1000000000; 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-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-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-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-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-5-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); --- Broken LOAD DATA -- use test; @@ -54,12 +54,12 @@ insert into t1 values ("abirvalg"); SET INSERT_ID=1; SET TIMESTAMP=1000000000; 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-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-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-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-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-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-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); SET TIMESTAMP=1000000000; insert into t1 values ("Alas"); diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index ccfdbd62a42..b826dd1b677 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -313,3 +313,4 @@ WHERE a b 15 1 47 1 +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 2899c7c99a4..40fb402a457 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -263,3 +263,4 @@ WHERE ( b =3 AND a BETWEEN 15 AND 19 ) OR (a BETWEEN 19 AND 47) ); +DROP TABLE t1; diff --git a/sql/log_event.cc b/sql/log_event.cc index b5d7b1df038..1c10a9a798c 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -293,40 +293,21 @@ void Load_log_event::pack_info(String* packet) else if (sql_ex.opt_flags & IGNORE_FLAG) tmp.append(" IGNORE "); - tmp.append("INTO TABLE "); + tmp.append("INTO TABLE `"); 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); - } - - if (sql_ex.enclosed_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); - } + tmp.append("` FIELDS TERMINATED BY "); + pretty_print_str(&tmp, sql_ex.field_term, sql_ex.field_term_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); + tmp.append( " ESCAPED BY "); + pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_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; - if (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; - } - + tmp.append(" LINES TERMINATED BY "); + pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len); if (sql_ex.line_start_len) { - if (!line_lexem_added) - tmp.append(" LINES"); tmp.append(" STARTING BY "); 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) 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) { @@ -1354,40 +1336,22 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool comm fprintf(file," REPLACE "); else if (sql_ex.opt_flags & IGNORE_FLAG ) 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) - { - if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) - 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); - } - - 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; - } + fprintf(file, "INTO TABLE `%s`", table_name); + fprintf(file, " FIELDS TERMINATED BY "); + pretty_print_str(file, sql_ex.field_term, sql_ex.field_term_len); + + if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) + fprintf(file," OPTIONALLY "); + fprintf(file, " ENCLOSED BY "); + pretty_print_str(file, sql_ex.enclosed, sql_ex.enclosed_len); + fprintf(file, " ESCAPED BY "); + pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len); + fprintf(file," LINES TERMINATED BY "); + pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len); if (sql_ex.line_start) { - if (!line_lexem_added) - fprintf(file," LINES"); fprintf(file," STARTING BY "); 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, 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, 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()) { sql_ex.force_new_format(); @@ -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) { int block_offset; - if (copy_log_event(buf,len,old_format)) - return; + DBUG_ENTER("Create_file_log_event"); + + /* + 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) { 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, sql_ex.force_new_format(); inited_from_old = 1; } + DBUG_VOID_RETURN; } diff --git a/sql/log_event.h b/sql/log_event.h index b610263a462..2eaaab260fc 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -644,6 +644,7 @@ protected: bool fake_base; public: char* block; + const char *event_buf; uint block_len; uint file_id; bool inited_from_old; @@ -663,7 +664,10 @@ public: #endif 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() { From 4aafb1ef3d9387c1ec10efdf69e47bdceb6f083c Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 16 Feb 2004 09:41:13 +0200 Subject: [PATCH 8/8] Cleanup + safety comment --- sql/share/english/errmsg.txt | 4 +++- sql/sql_load.cc | 7 +------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 7104eb64d56..dca9311b277 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -238,5 +238,7 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", -"Slave SQL thread ignored the query because of replicate-*-table rules" +"Slave SQL thread ignored the query because of replicate-*-table rules", "Variable '%-.64s' is a %s variable" +] # End of error messages +# Do NOT add new error messages here as this makes merges to 4.1 too hard! diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 3b8672188d4..1603a7eb26a 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -92,12 +92,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, LOAD_FILE_INFO lf_info; char *db = table_list->db; // This is never null /* If no current database, use database where table is located */ - char *tdb= thd->db ? thd->db : db; - /* - 'tdb' can be NULL only if both table_list->db and thd->db are NULL - 'db' itself can be NULL. but in that case it will generate - an error earlier open_ltable()). - */ + char *tdb= thd->db ? thd->db : db; // Result is never null bool transactional_table, log_delayed; ulong skip_lines= ex->skip_lines; DBUG_ENTER("mysql_load");