diff options
author | Nirbhay Choubey <nirbhay.choubey@oracle.com> | 2012-12-12 22:31:03 +0530 |
---|---|---|
committer | Nirbhay Choubey <nirbhay.choubey@oracle.com> | 2012-12-12 22:31:03 +0530 |
commit | fc2ad0afc3070ffa48c56cb3087d25284d53bc7a (patch) | |
tree | b5549842385c9e5dfa3f92393bea5a63933b923a /client | |
parent | ccee2f501178e18c8069ef4d9a521a31b1c3621f (diff) | |
download | mariadb-git-fc2ad0afc3070ffa48c56cb3087d25284d53bc7a.tar.gz |
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.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index b772fe67cc4..edbfd532de3 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2283,17 +2283,19 @@ static bool add_line(String &buffer,char *line,char *in_string, { uint length=(uint) (out-line); - if (!truncated && - (length < 9 || - my_strnncoll (charset_info, - (uchar *)line, 9, (const uchar *) "delimiter", 9))) + if (!truncated && (length < 9 || + my_strnncoll (charset_info, (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 added to the glob buffer (e.g. on processing a line like "<command>;DELIMITER <non-eof>") : similar to how a new line is 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'; length++; |