dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.42k stars 661 forks source link

Unable to reset delimiter in scripts #986

Closed mannerydhe closed 3 years ago

mannerydhe commented 3 years ago

Version: 1.24.1

Running the following from a file using source <filename>results in an error:

delimiter //

SELECT * FROM TEST//

delimiter ;

SELECT * FROM TEST;

The second delimiter command sets the delimiter to 'SELECT'. This causes of course a syntax error on the second select (* FROM TEST).

It is as though any delimiter set in the script is 'consumed' and can't be used again. There is no problem switching delimiters if a new one is used every time.

amjith commented 3 years ago

I'm able to reproduce it. I'll look into this. Thanks!

amjith commented 3 years ago

Found the issue. The source file has to have a delimiter at the end of every query.

delimiter //

SELECT * FROM TEST //

delimiter ;//

SELECT * FROM TEST;

The reason being when we source sql from a file there is no way for us to tell when a query ends and the next one starts so we rely on the delimiter to split the commands and run them one at a time.

Let us know if that works for you.