Bug #22533 Traditional: Too-long bit value not rejected
Submitted: 20 Sep 2006 22:51 Modified: 26 Feb 2007 20:46
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version:5.1.12-beta-debug/5.0bk OS:Linux (SUSE 10.0 / 64-bit)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[20 Sep 2006 22:51] Peter Gulutzan
Description:
I create a table with a BIT(64) column.
I insert a value which has more than 64 bits in it.
There is no error, even though sql_mode=traditional.

How to repeat:
mysql> set sql_mode=traditional;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t25 (s1 bit(8));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t25 values (0xfff);
ERROR 1406 (22001): Data too long for column 's1' at row 1
mysql> create table t26 (s1 bit(64));
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t26 values (0xffffffffffffffffffffffffff);
Query OK, 1 row affected (0.00 sec)
[20 Sep 2006 23:26] Godofredo Miguel Solorzano
Thank you for the bug report. Verified as described.
[27 Oct 2006 1:16] Peter Gulutzan
The previous comment is correct. Let me try to say it differently.

If I insert hexadecimal values into a BIT or BIGINT target, some
trimming can occur. For example:

mysql> create table t30 (s1 bigint unsigned);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t30 values (0xffffffffffffffffffffffffffffffff);
Query OK, 1 row affected (0.00 sec)
[4 Dec 2006 9:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/16369

ChangeSet@1.2558, 2006-12-04 13:28:38+04:00, ramil@mysql.com +5 -0
  Fix for bug #22533: Traditional: Too-long bit value not rejected.
  
  Storing >8 byte hexadecimal values in bigint fields we don't check data.
  Fix: check if the data fits the {u}longlong range.
[6 Dec 2006 12:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/16515

ChangeSet@1.2558, 2006-12-06 16:32:12+04:00, ramil@mysql.com +4 -0
  Fix for bug #22533: Traditional: Too-long bit value not rejected.
  
  Problem: storing >=8 byte hexadecimal values we don't check data.
  Fix: check if the data fits the {u}longlong range.
[7 Dec 2006 4:57] Alexander Barkov
The patch http://lists.mysql.com/commits/16515 looks ok to push.
[31 Jan 2007 19:15] Chad MILLER
Available in 5.0.36, 5.1.15-beta.
[26 Feb 2007 20:46] Paul Dubois
Noted in 4.1.23, 5.0.36, 5.1.16 changelogs.

Storing values specified as hexadecimal values 64 or more bits long
into BIT(64), BIGINT, or BIGINT UNSIGNED columns did not raise any
warning or error if the value was out of range.

(4.1.23 entry does not mention BIT)