Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-13244

`DEFAULT` & `COMMENT` doens't work sometimes.

Details

    Description

      I was working on Windows 7 and developing a Laravel project with MariaDB 10.2.6.
      The bug was found when I tried to define a datatable:

      CREATE TABLE `users` (
        `id` int(10) UNSIGNED NOT NULL,
        `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
        `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
        `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'null when sign-up via oauth',
        `message` int(11) NOT NULL DEFAULT '0' COMMENT 'Id of the last message that has been read',
        `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        `created_at` timestamp NULL DEFAULT NULL,
        `updated_at` timestamp NULL DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
      

      The columns `password` and `message` are both defined with default value and comment. However, column `message` is not what defined as the above SQL lines.

      I tested this carefully on my windows, but I was not able to get access to the Internet on that machine.

      Attachments

        1. 1.png
          43 kB
          Alice Sherepa
        2. 2.png
          49 kB
          Alice Sherepa
        3. 2.png
          53 kB
          Alice Sherepa
        4. IMG_20170706_103442_HDR.jpg
          1.93 MB
          PHP.Developer
        5. IMG_20170706_103540_HDR.jpg
          1.56 MB
          PHP.Developer
        6. IMG_20170706_104136_HDR.jpg
          1.23 MB
          PHP.Developer

        Issue Links

          Activity

            Could you please explain what is wrong, exactly? What does it mean, "column `message` is not what defined as the above SQL lines"?

            elenst Elena Stepanova added a comment - Could you please explain what is wrong, exactly? What does it mean, "column `message` is not what defined as the above SQL lines"?
            masterwto PHP.Developer added a comment -

            I am sorry for not having described it clearly.
            Column 'message' has no default value or comment, when I executed the SQL above.
            My MariaDB server is 10.2.6 windows x64.
            Thanks for reading.

            masterwto PHP.Developer added a comment - I am sorry for not having described it clearly. Column 'message' has no default value or comment, when I executed the SQL above. My MariaDB server is 10.2.6 windows x64. Thanks for reading.

            Please paste the unabridged output of

            DROP TABLE IF EXISTS `users`;
             
            CREATE TABLE `users` (
              `id` int(10) UNSIGNED NOT NULL,
              `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
              `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
              `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'null when sign-up via oauth',
              `message` int(11) NOT NULL DEFAULT '0' COMMENT 'Id of the last message that has been read',
              `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              `created_at` timestamp NULL DEFAULT NULL,
              `updated_at` timestamp NULL DEFAULT NULL
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
             
            SHOW CREATE TABLE `users`;
            

            from your MySQL client.

            elenst Elena Stepanova added a comment - Please paste the unabridged output of DROP TABLE IF EXISTS `users`;   CREATE TABLE `users` ( `id` int (10) UNSIGNED NOT NULL , ` name ` varchar (255) COLLATE utf8mb4_unicode_ci NOT NULL , `email` varchar (255) COLLATE utf8mb4_unicode_ci NOT NULL , ` password ` varchar (255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'null when sign-up via oauth' , `message` int (11) NOT NULL DEFAULT '0' COMMENT 'Id of the last message that has been read' , `remember_token` varchar (100) COLLATE utf8mb4_unicode_ci DEFAULT NULL , `created_at` timestamp NULL DEFAULT NULL , `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE =utf8mb4_unicode_ci;   SHOW CREATE TABLE `users`; from your MySQL client.
            masterwto PHP.Developer added a comment -

            This is the definition from heidisql:

            This is the table, column 'message' with missing default value and missing comment.

            This is the output when executed from the command window.

            No error is reported.

            masterwto PHP.Developer added a comment - This is the definition from heidisql: This is the table, column 'message' with missing default value and missing comment. This is the output when executed from the command window. No error is reported.
            alice Alice Sherepa added a comment -

            Thanks for the report.
            Reproduced on Heidisql 9.4 with MariaDB 10.2.6. (Windows 8)
            An error does not appear with MariaDB 10.1

            When column type is int (or bigint, tinyint, decimal, float, double) and column has default value (and this value <>null) and a comment simultaneously, then heidisql substitude column definition to DEFAULT ''.
            Works as expected with string types and date types.

            create table a (i int default 5 comment 'qqq');
             
            CREATE TABLE `a` (
            	`i` INT(11) NULL DEFAULT ''
            )
            COLLATE='latin1_swedish_ci'
            ENGINE=InnoDB
            ;
            


            alice Alice Sherepa added a comment - Thanks for the report. Reproduced on Heidisql 9.4 with MariaDB 10.2.6. (Windows 8) An error does not appear with MariaDB 10.1 When column type is int (or bigint, tinyint, decimal, float, double) and column has default value (and this value <>null) and a comment simultaneously, then heidisql substitude column definition to DEFAULT ''. Works as expected with string types and date types. create table a (i int default 5 comment 'qqq' );   CREATE TABLE `a` ( `i` INT( 11 ) NULL DEFAULT '' ) COLLATE= 'latin1_swedish_ci' ENGINE=InnoDB ;

            This is HeidiSQL bug.
            Note the difference between 10.1 and 10.2:

            10.1

            MariaDB [test]> show create table a\G
            *************************** 1. row ***************************
                   Table: a
            Create Table: CREATE TABLE `a` (
              `i` int(11) DEFAULT '5' COMMENT 'qqq'
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1
            1 row in set (0.00 sec)
            

            10.2

            MariaDB [test]> show create table a\G
            *************************** 1. row ***************************
                   Table: a
            Create Table: CREATE TABLE `a` (
              `i` int(11) DEFAULT 5 COMMENT 'qqq'
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1
            1 row in set (0.00 sec)
            

            Apparently, HeidiSQL expects '5', default value in quotes. That's why it works for strings and stopped working for numbers.

            serg Sergei Golubchik added a comment - This is HeidiSQL bug. Note the difference between 10.1 and 10.2: 10.1 MariaDB [test]> show create table a\G *************************** 1. row *************************** Table : a Create Table : CREATE TABLE `a` ( `i` int (11) DEFAULT '5' COMMENT 'qqq' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec) 10.2 MariaDB [test]> show create table a\G *************************** 1. row *************************** Table : a Create Table : CREATE TABLE `a` ( `i` int (11) DEFAULT 5 COMMENT 'qqq' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec) Apparently, HeidiSQL expects '5' , default value in quotes. That's why it works for strings and stopped working for numbers.

            As discussed, we need to wait for the bugfix in HeidiSQL and then update the version that we package in MSIs. Thus, I'm re-opening the report, it will stay assigned to alice who'll monitor the upstream bugfix, and when it's ready, will reassign it to wlad for proper packaging.

            elenst Elena Stepanova added a comment - As discussed, we need to wait for the bugfix in HeidiSQL and then update the version that we package in MSIs. Thus, I'm re-opening the report, it will stay assigned to alice who'll monitor the upstream bugfix, and when it's ready, will reassign it to wlad for proper packaging.

            People

              Unassigned Unassigned
              masterwto PHP.Developer
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.