Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Not a Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Only tested on Windows XP

      Description

      mysql client: when the statement delimiter is in the same line of the new DELIMITER command, the delimiter is lost.
      Example:

      MariaDB [(none)]> delimiter ||
      MariaDB [(none)]> select 1;
          -> || delimiter ;
      +---+
      | 1 |
      +---+
      | 1 |
      +---+
      1 row in set (0.00 sec)
          ->
      

      At this point... no delimiter seems to be recognized:

          -> select 1 ||
      MariaDB [(none)]> select 1 ;
          -> select 1 ;
          -> select 1 ||
          -> || ;
          ->
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Hi Federico,

            Apparently, there is a reason why MySQL client says in its help: "Note that all text commands must be first on line and end with ';'"

            This statement is not quite accurate, obviously it should be not ';' but a delimiter, and besides if the command is first on line, the delimiter is optional.
            But in your example, you break both requirements at once: your "delimiter ;" command is neither first on line, nor ends with the current delimiter. So, it starts working in a non-obvious way.

            The behavior you observe is more or less generic for MySQL client commands, it's just the specifics of delimiter that makes it so confusing.

            Please consider the following simpler example first:

            MariaDB [(none)]> select 1; help contents
            ---

            1

            ---

            1

            ---
            1 row in set (0.00 sec)

            -> ;
            You asked for help about help category: "Contents"
            For more information, type 'help <item>', where <item> is one of the following
            categories:
            Account Management
            ...
            Utility

            MariaDB [(none)]>

            As you can see, the 'help' command, when it's not first on the line, is not executed until you enter the delimiter. Same thing would have happened with your example, if you had entered the old delimiter after the 'delimiter ;' command:

            MariaDB [(none)]> delimiter ||

            1. Here you have set delimiter to '||'

            MariaDB [(none)]> select 1;

            1. Here you entered 'select 1;' statement which is considered incomplete because there is no delimiter

            -> || delimiter ;

            1. Here you entered the delimiter, so select is now complete and is sent to server;
            2. and you also started a 'delimiter' command which is now waiting for the old delimiter to be finalized

            ---

            1

            ---

            1

            ---
            1 row in set (0.00 sec)

            -> ||
            MariaDB [(none)]>

            But instead of the old delimiter, you entered "select 1 ||". That's where the whole thing went pear-shaped. According to the documentation, a delimiter, when provided unquoted, should be read up to the first space or the end of line. But then again, it relates to the normal case, when the command is first in line, right? Here, instead, the end of line is ignored on whatever reason, and your delimiter is read further, till the first space. So, you end up with delimiter = ';select'. If you had tried to use it further, it would have worked:

            MariaDB [(none)]> delimiter ||
            MariaDB [(none)]> select 1;
            -> || delimiter ;
            ---

            1

            ---

            1

            ---
            1 row in set (0.01 sec)

            -> select 1 ||
            MariaDB [(none)]> select 2 ;select
            ---

            2

            ---

            2

            ---
            1 row in set (0.00 sec)

            And of course, after that you could have changed the delimiter in the usual way.

            While the situation you ended up in is confusing (since you don't know what your delimiter is), it's not nearly as hopeless as it seems. You could always end the vicious cycle using \c or \g command, it would have return you to the pristine prompt:

            MariaDB [(none)]> delimiter ||
            MariaDB [(none)]> select 1;
            -> || delimiter ;
            ---

            1

            ---

            1

            ---
            1 row in set (0.00 sec)

            -> select 1 ||
            MariaDB [(none)]> select 1 ;
            -> select 1 ;
            -> select 1 ||
            -> || ;
            -> \c
            MariaDB [(none)]>

            And here you could have changed the delimiter in the usual fashion.

            Hope it helps.

            Show
            elenst Elena Stepanova added a comment - Hi Federico, Apparently, there is a reason why MySQL client says in its help: "Note that all text commands must be first on line and end with ';'" This statement is not quite accurate, obviously it should be not ';' but a delimiter, and besides if the command is first on line, the delimiter is optional. But in your example, you break both requirements at once: your "delimiter ;" command is neither first on line, nor ends with the current delimiter. So, it starts working in a non-obvious way. The behavior you observe is more or less generic for MySQL client commands, it's just the specifics of delimiter that makes it so confusing. Please consider the following simpler example first: MariaDB [(none)] > select 1; help contents --- 1 --- 1 --- 1 row in set (0.00 sec) -> ; You asked for help about help category: "Contents" For more information, type 'help <item>', where <item> is one of the following categories: Account Management ... Utility MariaDB [(none)] > As you can see, the 'help' command, when it's not first on the line, is not executed until you enter the delimiter. Same thing would have happened with your example, if you had entered the old delimiter after the 'delimiter ;' command: MariaDB [(none)] > delimiter || Here you have set delimiter to '||' MariaDB [(none)] > select 1; Here you entered 'select 1;' statement which is considered incomplete because there is no delimiter -> || delimiter ; Here you entered the delimiter, so select is now complete and is sent to server; and you also started a 'delimiter' command which is now waiting for the old delimiter to be finalized --- 1 --- 1 --- 1 row in set (0.00 sec) -> || MariaDB [(none)] > But instead of the old delimiter, you entered "select 1 ||". That's where the whole thing went pear-shaped. According to the documentation, a delimiter, when provided unquoted, should be read up to the first space or the end of line. But then again, it relates to the normal case, when the command is first in line, right? Here, instead, the end of line is ignored on whatever reason, and your delimiter is read further, till the first space. So, you end up with delimiter = ';select'. If you had tried to use it further, it would have worked: MariaDB [(none)] > delimiter || MariaDB [(none)] > select 1; -> || delimiter ; --- 1 --- 1 --- 1 row in set (0.01 sec) -> select 1 || MariaDB [(none)] > select 2 ;select --- 2 --- 2 --- 1 row in set (0.00 sec) And of course, after that you could have changed the delimiter in the usual way. While the situation you ended up in is confusing (since you don't know what your delimiter is), it's not nearly as hopeless as it seems. You could always end the vicious cycle using \c or \g command, it would have return you to the pristine prompt: MariaDB [(none)] > delimiter || MariaDB [(none)] > select 1; -> || delimiter ; --- 1 --- 1 --- 1 row in set (0.00 sec) -> select 1 || MariaDB [(none)] > select 1 ; -> select 1 ; -> select 1 || -> || ; -> \c MariaDB [(none)] > And here you could have changed the delimiter in the usual fashion. Hope it helps.

              People

              • Assignee:
                elenst Elena Stepanova
                Reporter:
                f_razzoli Federico Razzoli
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: