Repository navigation
End use and source at the newline in batch input - #2433
Conversation
| MAX_MULTILINE_BATCH_STATEMENT = 5000 | ||
|
|
||
| DELIMITER_RE = re.compile(r'^\s*delimiter\s+(\S+)\s*$', re.IGNORECASE) | ||
| # Client commands the mysql client ends at the newline, without a delimiter |
There was a problem hiding this comment.
Let's call it "the vendor client" for clarity.
There was a problem hiding this comment.
Done, the comment now says "the vendor client".
|
|
||
| DELIMITER_RE = re.compile(r'^\s*delimiter\s+(\S+)\s*$', re.IGNORECASE) | ||
| # Client commands the mysql client ends at the newline, without a delimiter | ||
| LINE_COMMAND_RE = re.compile(r'^\s*(use|source|\\u|\\\.)\s+\S', re.IGNORECASE) |
There was a problem hiding this comment.
The regex needs to support forward slashes for mycli syntax:
re.compile(r'^\s*(/?use|/?source|[/\\]u|[/\\]\.)\s+\S', re.IGNORECASE)
and, more importantly, can't the filename or database name contain spaces? Edit: Oh I see, there isn't a trailing anchor. Good.
There was a problem hiding this comment.
Done, using your regex, and added a test for /use at the newline. Right, no trailing anchor, so names with spaces still match.
| -------- | ||
| * Open the audit log and the `\T`/`\o` output files as UTF-8, so non-ASCII output no longer fails under non-UTF-8 locales. | ||
| * Support `DELIMITER` in batch input (`mycli < file.sql`, `--batch`), so dumps with triggers or routines restore. | ||
| * End `use`, `source`, `\u` and `\.` at the newline in batch input, as the mysql client does, so a `use db` line without `;` no longer swallows the next statement. |
There was a problem hiding this comment.
Suggestion (making it shorter among other things):
Terminate `use`, `source`, `\u` and `\.` at newline in batch input, as the vendor client does.
There was a problem hiding this comment.
Done, changelog uses your wording. Also rebased on main to clear the conflict.
The mysql client ends use, source, \u and \. at the newline, so scripts often have `use db` without a semicolon. Batch input kept reading until the next ';', so the following statement was sent as part of the database name and the run stopped with "Unknown database".
846eb1d to
d4492e0
Compare
|
Lovely. |
|
Released in https://github.com/dbcli/mycli/releases/tag/v2.31.0 ! |
Description
The mysql client ends
use,source,\uand\.at the newline, so scripts often haveuse dbwithout;. Piped into mycli, that line swallows the next statement and the run stops:select database()andselect 5never run. The same input throughmysqlprintsa 1,database() mysql,later 5. Same with--batch file.sqlandsource file.sql.statements_from_filehandlenow yields ause,source,\uor\.line on its own when it starts a statement and doesn't end with the delimiter, the same wayDELIMITERlines are handled.use db;still goes through the normal path.Tested: a new
test_batch_utils.pycase fails without the change.pytest mycli_test/pytests: 3356 passed with the change and 3355 on main, with the same 62 failures on both (tests that need a live server here). Against MySQL 8.0 the input above now prints the same as themysqlclient and exits 0.ruff checkandruff formatclean.Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).