Commit 5f915465 authored by Nirbhay Choubey's avatar Nirbhay Choubey

Bug#13639125 DELIMITER STRIPS THE NEXT NEW LINE

             IN A SQL STATEMENT

While processing each lines entered at the prompt,
mysql client appends a '\n' to all the lines except
for delimiter commands. However the same logic must
not apply if 'delimiter' is part of a string or a
comment, for which a '\n' should be added.

Fixed by adding appropriate checks.

Added a test case.
parent 0095bd00
...@@ -2283,17 +2283,19 @@ static bool add_line(String &buffer,char *line,char *in_string, ...@@ -2283,17 +2283,19 @@ static bool add_line(String &buffer,char *line,char *in_string,
{ {
uint length=(uint) (out-line); uint length=(uint) (out-line);
if (!truncated && if (!truncated && (length < 9 ||
(length < 9 || my_strnncoll (charset_info, (uchar *)line, 9,
my_strnncoll (charset_info, (const uchar *) "delimiter", 9) ||
(uchar *)line, 9, (const uchar *) "delimiter", 9))) (*in_string || *ml_comment)))
{ {
/* /*
Don't add a new line in case there's a DELIMITER command to be Don't add a new line in case there's a DELIMITER command to be
added to the glob buffer (e.g. on processing a line like added to the glob buffer (e.g. on processing a line like
"<command>;DELIMITER <non-eof>") : similar to how a new line is "<command>;DELIMITER <non-eof>") : similar to how a new line is
not added in the case when the DELIMITER is the first command not added in the case when the DELIMITER is the first command
entered with an empty glob buffer. entered with an empty glob buffer. However, if the delimiter is
part of a string or a comment, the new line should be added. (e.g.
SELECT '\ndelimiter\n';\n)
*/ */
*out++='\n'; *out++='\n';
length++; length++;
......
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