Edit report at https://bugs.php.net/bug.php?id=63916&edit=1

 ID:                 63916
 Updated by:         lstro...@php.net
 Reported by:        google...@php.net
 Summary:            PDO::PARAM_INT casts to 32bit int internally even on
                     64bit builds in pdo_sqlite
-Status:             Closed
+Status:             Feedback
 Type:               Bug
 Package:            PDO related
 PHP Version:        5.4.10
 Block user comment: N
 Private report:     N

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.4-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Merged into 5.4, 5.5 and master


Previous Comments:
------------------------------------------------------------------------
[2013-01-14 16:59:42] lstro...@php.net

Automatic comment on behalf of lstrojny
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=1e9a3ed234af443170d9ea8280a556d85299e301
Log: Fix bug #63916: PDO::PARAM_INT casts to 32bit int internally even on 64bit 
builds in pdo_sqlite

------------------------------------------------------------------------
[2013-01-12 22:03:19] google...@php.net

This seems to be a regression from the PHP-5.2 branch as well. After testing on 
PHP-
5.2,5.3,5.4,5.5,and master branches I found that the issue did not exist back 
in ext/sqlite2 
as string casting was done instead of using integer types. The issue probably 
was over looked 
when the sqlite3 driver was ported in to replace the old ext/sqlite2.

Regression results:

http://playground.sheriframadan.com/testphphL1I9j

------------------------------------------------------------------------
[2013-01-06 18:49:11] google...@php.net

Related To: Bug #63921

------------------------------------------------------------------------
[2013-01-06 12:57:28] google...@php.net

Because we're currently running 3 branches I've sent the PR for this to master 
and I'm asking for it to be merged into 5.3.NEXT, 5.4.NEXT, and 5.5.NEXT 
respectively to maintain consistency.

https://github.com/php/php-src/pull/253/

------------------------------------------------------------------------
[2013-01-06 05:20:07] google...@php.net

Description:
------------
Binding a PDO parameter with pdo_sqlite on 64bit builds with PDO::PARAM_INT 
forces the param to be cast internally to an int. This means 64bit ints will be 
cast down to 32bit ints internally even if PHP was compiled against a 64bit 
arch.

Test script:
---------------
$num = 100004313234244; // notice this exceeds 32 bits
$conn = new PDO('sqlite::memory:');
$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, 
PRIMARY KEY(id))');

$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)');
$stmt->bindValue(':id', 1, PDO::PARAM_INT);
$stmt->bindValue(':num', $num, PDO::PARAM_INT);
$stmt->execute();

$stmt = $conn->query('SELECT num FROM users');
$result = $stmt->fetchAll(PDO::FETCH_COLUMN);

printf("Expected: %d Received: %d\n", $num, $result[0]);

Expected result:
----------------
// expected to output
Expected: 100004313234244 Received: 100004313234244

Actual result:
--------------
// instead we get output of
Expected: 100004313234244 Received: 294714180


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63916&edit=1

Reply via email to