Bug #75018 [Com]: Data corruption when reading fields of bit type
Edit report at https://bugs.php.net/bug.php?id=75018&edit=1
ID: 75018
Comment by: michal at cihar dot com
Reported by: ale5000 at gmail dot com
Summary: Data corruption when reading fields of bit type
Status: Open
Type: Bug
Package: MySQLi related
Operating System: Windows 7 64-bit
PHP Version: 7.1.7
Block user comment: N
Private report: N
New Comment:
I've just tested this and here is what I've found out:
- I can reproduce this when running 32-bit PHP on 64-bit Windows, it does not happen in 64-bit
builds
- The returned value seems to be random, depending on executed code or MySQL statements
- I can reproduce this behavior on PHP 7.1.7 and 7.2.0beta1
Results I got: 0x1508618400000000 0x100000000 0x10c6632400000000 (though this most likely
doesn't mean anything)
Previous Comments:
------------------------------------------------------------------------
[2017-08-01 14:19:29] ale5000 at gmail dot com
Description:
------------
It corrupt data when reading fields of bit type.
See the sample code.
The problem is possibly Windows specific but I'm not sure.
Test script:
---------------
<?php
$username = 'root';
$password = '';
$database_name = 'test_db';
$mysqli = new mysqli('127.0.0.1', $username, $password, $database_name);
if($mysqli->connect_errno) die('Error');
$sql = "CREATE TABLE test (bit_column_1 bit(1) NOT NULL) DEFAULT CHARSET=utf8";
$mysqli->query($sql);
$sql = "INSERT INTO test (bit_column_1) VALUES (0)";
$mysqli->query($sql);
$sql = "SELECT bit_column_1 FROM test";
if(!$result = $mysqli->query($sql)) die('Failed');
$row = $result->fetch_assoc();
echo "Result: ".$row['bit_column_1'];
Expected result:
----------------
0
Actual result:
--------------
668556962937438208
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75018&edit=1
Thread (8 messages)