Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0b4

Bug #19304 Doesn't return all values from bit fields correctly
Submitted: 2012-02-24 03:50 UTC
From: daftmav Assigned:
Status: Open Package: MDB2_Driver_mysql
PHP Version: 5.3.2 OS: Ubuntu
Roadmaps: (Not assigned)    
Subscription  


 [2012-02-24 03:50 UTC] daftmav (Atilla Hulsebos)
Description: ------------ Some values from bit fields are incorrectly returned as zero (or null?). Not sure why it's only doing this with some bits 'on', but not when other bits are also 'on'. Makes me think it has something to do with bits being returned as weird ascii characters from the DB and MDB2 filters or can't handle some of them? Stable 4.2.1 does not have this issue and correctly returns all bit values. Tested with MDB2 2.5.0b3 and MDB2_Driver_mysql 1.5.0b3 Also tried 2.5.0b2 but it's the same. I found it because I'm moving a site to a php5 setup and 2.4.1 has al sorts of errors with it so I tried the beta. Test script: --------------- A table with some sample data included: http://pastebin.com/ckvX78u4 Because bit values are returned like actual bits, I've added a simple test script which shows the problem in a more readable format. Expected result: ---------------- 1 [ascii value: 1 ] 00000001 : one 2 [ascii value: 2 ] 00000010 : two 3 [ascii value: 4 ] 00000100 : three 4 [ascii value: 8 ] 00001000 : four 5 [ascii value: 16 ] 00010000 : five 6 [ascii value: 32 ] 00100000 : six 7 [ascii value: 64 ] 01000000 : seven 8 [ascii value: 128 ] 10000000 : eight 9 [ascii value: 3 ] 00000011 : one and two 10 [ascii value: 5 ] 00000101 : one and three 11 [ascii value: 9 ] 00001001 : one and four 12 [ascii value: 17 ] 00010001 : one and five 13 [ascii value: 33 ] 00100001 : one and six 14 [ascii value: 65 ] 01000001 : one and seven 15 [ascii value: 129 ] 10000001 : one and eight Actual result: -------------- Note: row 6 and 11 are wrong (zero): 1 [ascii value: 1 ] 00000001 : one 2 [ascii value: 2 ] 00000010 : two 3 [ascii value: 4 ] 00000100 : three 4 [ascii value: 8 ] 00001000 : four 5 [ascii value: 16 ] 00010000 : five 6 [ascii value: 0 ] 00000000 : six <<<--- zero 7 [ascii value: 64 ] 01000000 : seven 8 [ascii value: 128 ] 10000000 : eight 9 [ascii value: 3 ] 00000011 : one and two 10 [ascii value: 5 ] 00000101 : one and three 11 [ascii value: 0 ] 00000000 : one and four <<<--- zero 12 [ascii value: 17 ] 00010001 : one and five 13 [ascii value: 33 ] 00100001 : one and six 14 [ascii value: 65 ] 01000001 : one and seven 15 [ascii value: 129 ] 10000001 : one and eight

Comments

 [2012-02-24 17:18 UTC] daftmav (Atilla Hulsebos)
I thought I should probably move to the mysqli driver, but that shows even weirder results and it gets all the bits wrong. With MDB2_Driver_mysqli 1.5.0b3 on the same 8-bit test sample, it shows the 6th bit always on, 7th and 8th always zero, and well... everything is wrong: 1 [ascii value: 49 ] 00110001 : one 2 [ascii value: 50 ] 00110010 : two 3 [ascii value: 52 ] 00110100 : three 4 [ascii value: 56 ] 00111000 : four 5 [ascii value: 49 ] 00110001 : five 6 [ascii value: 51 ] 00110011 : six 7 [ascii value: 54 ] 00110110 : seven 8 [ascii value: 49 ] 00110001 : eight 9 [ascii value: 51 ] 00110011 : one and two 10 [ascii value: 53 ] 00110101 : one and three 11 [ascii value: 57 ] 00111001 : one and four 12 [ascii value: 49 ] 00110001 : one and five 13 [ascii value: 51 ] 00110011 : one and six 14 [ascii value: 54 ] 00110110 : one and seven 15 [ascii value: 49 ] 00110001 : one and eight
 [2012-02-24 17:52 UTC] daftmav (Atilla Hulsebos)
-Package: MDB2 +Package: MDB2_Driver_mysql
 [2012-02-24 17:58 UTC] daftmav (Atilla Hulsebos)
Please disregard my previous comment. The mysqli driver returns bit fields as their decimal value. Hence me using php's ord() to show the decimal value of the bit was wrong, which is required with the results from the mysql driver. So the problem is only with the mysql driver not handling bits as expected. Again, stable 4.2.1 with mysql driver does not have this problem. Solution for me seems to be to just move to mysqli driver and remove the use of ord() in my code...