Bug #16050 whitespace confuses delimiter in script
Submitted: 28 Dec 2005 19:41 Modified: 30 Dec 2005 8:21
Reporter: Mark Johnson (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Query Browser Severity:S3 (Non-critical)
Version:1.1.17 OS:Linux (linux 2.6.12; slackware 10.2)
Assigned to: Alfredo Kojima CPU Architecture:Any

[28 Dec 2005 19:41] Mark Johnson
Description:
I tried to execute a script file, which was DOS-formatted.  This failed due to the delimiter being incorrectly set.

How to repeat:
1. The first line of the script file sets "DELIMITER $$".  However, the file is DOS-formatted.  The system sets the delimiter to "$$\r" rather simply than "$$".
2. After a few lines of good code, I had a line ended with "$$ \r". NOTE the space.  This caused the system to not recognize the delimiter.  This caused an error making two statements not get executed.  (I closed the error window by clicking its X in the upper right corner since in my original script the error message more than filled the screen.)
3. Later statements in the script were executed.

When I try to close the script tab by clicking on its little red X, it would almost always crash query browser with a segmentation fault.  

I can supply a sample script if needed.  It created a few tables, and then executed a few ALTER TABLE statements to create a compound primary key, create a unique index, and foreign keys.

Suggested fix:
1.  Query browser should not suffer a segmentation fault when closing this script window after the error.
2.  The delimiter should not simply take all characters to the end of the line; rather it should ignore white space characters at the end of the line.
[28 Dec 2005 19:56] Mark Johnson
I just tried this with clicking skip in the error dialog.  After a couple of skips, I got the following crash:

glibmm-ERROR **:
unhandled exception (type std::exception) in signal handler:
what: basic_string::assign

aborting...
/usr/local/bin/mysql-query-browser: line 20: 29087 Aborted                 $PRG-bin

I am using glibmm version 2.6.1
[28 Dec 2005 22:41] MySQL Verification Team
Could you please provide the script.

Thanks in advance.
[29 Dec 2005 1:49] Mark Johnson
The following is the script.  The "^M" indicates a carriage-return character.  The script did work correctly when in unix text format.

DELIMITER $$ ^M
^M
CREATE TABLE IF NOT EXISTS `IsItABug`.`Daddy` (^M
   id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,^M
   name NVARCHAR(50) NOT NULL^M
   ) Engine=InnoDB$$^M
^M
CREATE TABLE IF NOT EXISTS `IsItABug`.`Mommy` (^M
   id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,^M
   name NVARCHAR(50) NOT NULL^M
   ) Engine=InnoDB$$^M
^M
CREATE TABLE IF NOT EXISTS `IsItABug`.`Child` (^M
   DaddyID INT NOT NULL,^M
   MommyID INT NOT NULL^M
   ) Engine=InnoDB$$^M
^M
CREATE TABLE IF NOT EXISTS `IsItABug`.`PostalCode` (^M
   id INT AUTO_INCREMENT PRIMARY KEY NOT NULL ,^M
   PostalCode VARCHAR(50) NOT NULL ^M
   ) ENGINE=InnoDB$$^M
^M
^M
ALTER TABLE `IsItABug`.`Child`  ADD ^M
        CONSTRAINT PK_IsItABug PRIMARY KEY ^M
        (^M
                DaddyID,^M
                MommyID^M
        ) $$ ^M
^M
ALTER TABLE `IsItABug`.`PostalCode`^M
        ADD CONSTRAINT Unique_PostalCode UNIQUE INDEX (PostalCode)$$^M
^M
ALTER TABLE `IsItABug`.`Child` ^M
        ADD CONSTRAINT FK_Child_Daddy FOREIGN KEY ^M
        (^M
                DaddyID^M
        ) REFERENCES `IsItABug`.`Daddy` (^M
                id^M
        ),^M
        ADD CONSTRAINT FK_Child_Mommy FOREIGN KEY ^M
        (^M
                MommyID^M
        ) REFERENCES `IsItABug`.`Mommy` (^M
                id^M
        )$$^M
^M
DELIMITER ;^M
[30 Dec 2005 8:21] Alfredo Kojima
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html