summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-02-13 16:05:09 +0200
committerunknown <monty@mysql.com>2004-02-13 16:05:09 +0200
commit0a95bda23a349639bd51c4b2c71da56ebd13d31f (patch)
tree0fed6c37f6c17ba97ac09f0dbecdf6846b11a97b /sql
parent82e82a88e7704330ea1ac5c7d885c1cee56c6618 (diff)
downloadmariadb-git-0a95bda23a349639bd51c4b2c71da56ebd13d31f.tar.gz
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
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc101
-rw-r--r--sql/log_event.h6
2 files changed, 42 insertions, 65 deletions
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);
- }
-
- if (sql_ex.escaped_len)
- {
- tmp.append( " ESCAPED BY ");
- pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_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);
- 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()
{