Commit bdb62daa authored by Sujatha Sivakumar's avatar Sujatha Sivakumar

Bug#17429677:LAST ARGUMENT OF LOAD DATA ...SET ...STATEMENT

REPEATED TWICE IN BINLOG

Problem:
=======
If LOAD DATA ... SET ... is used the last argument of SET is
repeated twice in replication binlog.

Analysis:
========
LOAD DATA statements are reconstructed once again before
they are written to the binary log. When SET clauses are
specified as part of LOAD DATA statement, these SET clause
user command strings need to be stored in order to rebuild
the original user command. During parsing each column and
the value in the SET command are stored in two differenet
lists. All the values are stored in a string list.

When SET expression has more than one value as shown in the
following example:
SET a = @A, b = CONCAT(@b, '| 123456789');

Parser extracts values in the following manner i.e Item name
, value string, actual length of the value of the item with
in the string.

Item a:
Value for a:"= @A, b = CONCAT(@b, '| 123456789')
str_length = 4
Item b:
Value for b:"= CONCAT(@b, '| 123456789')
str_length = 27

During reconstructing the LOAD DATA command the above
strings are retrived as it is and appended to the LOAD DATA
statement. Hence it becomes as shown below.

SET `a`= @A, b = CONCAT(@b, '| 123456789'),
`b`= CONCAT(@b, '| 123456789')

Fix:
===
During reconstruction of SET command, retrieve exact item
value string rather than reading the entire string.
parent e360311e
......@@ -738,8 +738,16 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
if (n++)
pfields.append(", ");
append_identifier(thd, &pfields, item->name, strlen(item->name));
// Extract exact Item value
str->copy();
pfields.append((char *)str->ptr());
str->free();
}
/*
Clear the SET string list once the SET command is reconstructed
as we donot require the list anymore.
*/
thd->lex->load_set_str_list.empty();
}
p= pfields.c_ptr_safe();
......
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