[MDEV-19180] Long hex hybrids get cut in DEFAULT expressions Created: 2019-04-05  Updated: 2020-05-05

Status: Open
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Epic Link: Data type cleanups

 Description   

CREATE OR REPLACE TABLE t1 (a VARBINARY(32) DEFAULT CAST(0x00112233445566778899AABBCCDDEEFF AS BINARY));
SHOW CREATE TABLE t1;

+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                             |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` varbinary(32) DEFAULT (cast(0x8899aabbccddeeff as char charset binary))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+

Notice, the hex hybrid constant in the DEFAULT clause was cut from 16 bytes to 8 bytes.

If I use a hex string constat (instead of hex hybrid constant), it works as expected:

CREATE OR REPLACE TABLE t1 (a VARBINARY(32) DEFAULT CAST(X'00112233445566778899AABBCCDDEEFF' AS BINARY));
SHOW CREATE TABLE t1;

+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                              |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` varbinary(32) DEFAULT (cast(X'00112233445566778899aabbccddeeff' as char charset binary))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+


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