[MDEV-13244] `DEFAULT` & `COMMENT` doens't work sometimes. Created: 2017-07-05  Updated: 2021-02-12

Status: Stalled
Project: MariaDB Server
Component/s: Platform Windows
Affects Version/s: 10.2.6
Fix Version/s: 10.2

Type: Bug Priority: Minor
Reporter: PHP.Developer Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: upstream
Environment:

Windows 7 x64


Attachments: PNG File 1.png     PNG File 2.png     PNG File 2.png     JPEG File IMG_20170706_103442_HDR.jpg     JPEG File IMG_20170706_103540_HDR.jpg     JPEG File IMG_20170706_104136_HDR.jpg    
Issue Links:
Relates
relates to MDEV-13341 information_schema.columns Column_def... Closed

 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.



 Comments   
Comment by Elena Stepanova [ 2017-07-05 ]

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

Comment by PHP.Developer [ 2017-07-06 ]

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.

Comment by Elena Stepanova [ 2017-07-06 ]

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.

Comment by PHP.Developer [ 2017-07-06 ]

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.

Comment by Alice Sherepa [ 2017-07-07 ]

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
;


Comment by Sergei Golubchik [ 2017-07-07 ]

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.

Comment by Elena Stepanova [ 2017-07-09 ]

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.

Generated at Thu Feb 08 08:04:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.