[MDEV-15260] Changing delimiter after commented line in mysql client Created: 2018-02-09 Updated: 2023-04-27 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Scripts & Clients |
| Affects Version/s: | 5.5.59, 10.2.12 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Juha Pyy | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian / Ubuntu |
||
| Attachments: |
|
| Description |
|
Encountered an odd "You have an error in your SQL syntax" error while running a script into mysql client. After making sure there were no obvious errors or typos in our script, I finally found the culprits causing the error. Seems like commented lines with white space before the comment mark "--" (or actually also "#") makes the command processing continue until a delimiter is encountered. But if trying to change the delimiter right after such commented line, the delimiter change is not executed and results in syntax error message when ("old") delimiter is finally encountered later. Expected result: DELIMITER command should be executed whether the previous line/command is commented out (with or without white space) or multi-line comment. See attached files for a script with working and non-working cases, including workarounds at the end, and results when each segment of commands was executed in mysql client. Also tested in Oracle mysql, which seems to behave differently with multi-line comments in that it doesn't require a delimiter after the end of the comment block in order for the delimiter change to work correctly. The white space problem is there as well, although it is not immediately visible if executing the commands just one line at a time. Edit: The errors happen when --comments option is given to mysql client (either from command line or having "comments=1" in config file). |
| Comments |
| Comment by Alice Sherepa [ 2018-02-09 ] | ||||||||||||||||||||||||||||||
|
Hi Juha, I guess you have some symbols, that are not visible there, in word DELIMITER (letter D)
please check again. | ||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2018-02-09 ] | ||||||||||||||||||||||||||||||
|
In the fragment above, the invisible symbol is before the first `DELIMITER`. Hexdump or alike will help to see it. | ||||||||||||||||||||||||||||||
| Comment by Juha Pyy [ 2018-02-09 ] | ||||||||||||||||||||||||||||||
|
Hi Alice, thanks for your reply. It didn't matter whether I copy-pasted or wrote by hand, I still got the same result each time. Now I'm also able to replicate these cases in Oracle mysql as well, e.g.
This is how it now looks like for me:
Alice (or someone else), could you please try if you can replicate the issue now with the comments option? | ||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-02-12 ] | ||||||||||||||||||||||||||||||
|
I get syntax errors with Mysql client option --comments (preserve comments in statements sent to the server). 1)line starts with "-- " - does not need delimiter in the end
If this comment is followed by DELIMITER:
3) In the case of /* ..........*/ it has to have delimiter in the end (for those cases, when it will be an executable comment )
4)comments after DELIMITER - treated as a delimiter, not as a comment: | ||||||||||||||||||||||||||||||
| Comment by Juha Pyy [ 2018-02-13 ] | ||||||||||||||||||||||||||||||
|
Thanks Alice for the confirmation and clarifications. | ||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2018-10-05 ] | ||||||||||||||||||||||||||||||
|
alice, do you consider any of the described cases to be wrong? If so, could you please indicate which are (and why) and move the bug report forward? Otherwise, you can close it. | ||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-10-05 ] | ||||||||||||||||||||||||||||||
|
I switched to the another laptop and can not reproduce the same behavior. (it is also Ubuntu 16.04, but maybe some settings are different).
The case 4, when comment starts right after "DELIMITER" clause - the warning should be returned (or it should be mentioned in the documentation) (the same applies to all reserved words,.. KB says, that delimiter should be distinct, but it is not checked, it expects the user to be reasonable.)
|