[MDEV-30450] Truncation without warning Created: 2023-01-23  Updated: 2023-01-23

Status: Open
Project: MariaDB Server
Component/s: Variables
Affects Version/s: 10.10.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Georg Richter Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When trying to represent the binary string of a user variable the output is 0, but no warning was returned.

How to repeat:

MariaDB [test]> set @a:=b'101';
Query OK, 0 rows affected (0,001 sec)
 
MariaDB [test]> select hex(@a);
+---------+
| hex(@a) |
+---------+
| 05      |
+---------+
1 row in set (0,001 sec)
 
MariaDB [test]> select bin(hex(@a));
+--------------+
| bin(hex(@a)) |
+--------------+
| 101          |
+--------------+
1 row in set (0,001 sec)
 
# No warning returned
MariaDB [test]> select bin(@a);
+---------+
| bin(@a) |
+---------+
| 0       |
+---------+
1 row in set (0,001 sec)

Works as expected with MySQL :

MySQL [(none)]> set @a:=b'101';
Query OK, 0 rows affected (0,001 sec)
 
MySQL [(none)]> select bin(@a);
+---------+
| bin(@a) |
+---------+
| 0       |
+---------+
1 row in set, 1 warning (0,001 sec)
 
MySQL [(none)]> show warnings;
+---------+------+-------------------------------------------+
| Level   | Code | Message                                   |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect DECIMAL value: '\x05' |
+---------+------+-------------------------------------------+
1 row in set (0,001 sec)


Generated at Thu Feb 08 10:16:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.