Bug #104567 | Inconsistent result defining binary column default values | ||
---|---|---|---|
Submitted: | 8 Aug 2021 13:48 | Modified: | 16 Aug 2021 22:56 |
Reporter: | Peter Brawley (Basic Quality Contributor) | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Information schema | Severity: | S3 (Non-critical) |
Version: | 5.7, 8.0, 5.7.35, 8.0.26 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | default values, hex |
[8 Aug 2021 13:48]
Peter Brawley
[9 Aug 2021 7:21]
MySQL Verification Team
Hello Peter, Thank you for the report and feedback! Thanks, Umesh
[16 Aug 2021 14:15]
Bernt Marius Johnsen
Hi. The default value of the table is completely ok: mysql> CREATE TABLE t (col varbinary(100) DEFAULT X'aaaa00aaaaaaaaffffff' ) ENGINE=InnoDB; Query OK, 0 rows affected (0,00 sec) mysql> insert into t() values(); Query OK, 1 row affected (0,00 sec) mysql> select * from t; +------------------------+ | col | +------------------------+ | 0xAAAA00AAAAAAAAFFFFFF | +------------------------+ 1 row in set (0,00 sec) The problem is that show columns displays the default value incorrect of there is a 0-byte in the value: mysql> CREATE TABLE t1 ( col varbinary(100) DEFAULT X'aabbccddeeff' ) ENGINE=InnoDB; Query OK, 0 rows affected (0,01 sec) mysql> show columns from t1; +-------+----------------+------+-----+----------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------------+------+-----+----------------+-------+ | col | varbinary(100) | YES | | 0xAABBCCDDEEFF | | +-------+----------------+------+-----+----------------+-------+ 1 row in set (0,00 sec) mysql> CREATE TABLE t2 ( col varbinary(100) DEFAULT X'aa00bbccddeeff' ) ENGINE=InnoDB; Query OK, 0 rows affected (0,00 sec) mysql> show columns from t2; +-------+----------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------------+------+-----+---------+-------+ | col | varbinary(100) | YES | | 0xAA | | +-------+----------------+------+-----+---------+-------+ 1 row in set (0,01 sec)
[16 Aug 2021 22:56]
Peter Brawley
> Hi. The default value of the table is completely ok > The problem is that show columns displays the default value incorrect of there is a 0-byte in the value ?! The pad value is 0x00, so the default value is not completely ok, should not MySQL reject this?
[17 Aug 2021 7:10]
Bernt Marius Johnsen
MySQL does not pad VARBINARY (see https://dev.mysql.com/doc/refman/8.0/en/binary-varbinary.html) so as far as I can see, the problem is in SHOW COLUMNS.