| Bug #14188 | BINARY variables have no 0x00 padding | ||
|---|---|---|---|
| Submitted: | 20 Oct 2005 18:22 | Modified: | 7 Dec 2005 19:24 |
| Reporter: | Peter Gulutzan | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.0.15-BK, 5.0.16-debug | OS: | Linux (Linux) |
| Assigned to: | Alexander Nozdrin | CPU Architecture: | Any |
[21 Oct 2005 13:47]
Valeriy Kravchuk
Verified on 5.0.15 (ChangeSet@1.2022, 2005-10-20 11:12:34+05:00, bar@mysql.com) on Linux:
mysql> delimiter //
mysql> create procedure ph0 (p1 binary(2)) begin declare v1 binary(2)
-> default 0x41; select hex(p1),hex(v1); end//
Query OK, 0 rows affected (0,02 sec)
mysql> call ph0(0x41)//
+---------+---------+
| hex(p1) | hex(v1) |
+---------+---------+
| 41 | 41 |
+---------+---------+
1 row in set (0,00 sec)
Query OK, 0 rows affected (0,00 sec)
mysql> create table tbi(c1 binary(2))//
Query OK, 0 rows affected (0,01 sec)
mysql> insert into tbi values (0x41)//
Query OK, 1 row affected (0,01 sec)
mysql> select hex(c1) from tbi//
+---------+
| hex(c1) |
+---------+
| 4100 |
+---------+
1 row in set (0,00 sec)
mysql> select version()//
+-----------+
| version() |
+-----------+
| 5.0.15 |
+-----------+
1 row in set (0,00 sec)
[7 Dec 2005 19:24]
Paul DuBois
Noted in 5.0.18 changelog.

Description: Rule: "zero padding on insert". For any change of a BINARY(n) target, e.g. INSERT or UPDATE or "SET variable=value", if length(target) > length(source), pad target with trailing 0x00 ('\0') bytes. It does happen if the target is a column. It doesn't happen if the target is a variable or parameter. This test was originally mentioned in a comment for bug#9278. Fix should be for 5.0 only. How to repeat: mysql> delimiter // mysql> create procedure ph0 (p1 binary(2)) begin declare v1 binary(2) default 0x41; select hex(p1),hex(v1); end// Query OK, 0 rows affected (0.03 sec) mysql> call ph0(0x41)// +---------+---------+ | hex(p1) | hex(v1) | +---------+---------+ | 41 | 41 | +---------+---------+ 1 row in set (0.01 sec)