php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42443 PDO SQLite3 lacks integer type support
Submitted: 2007-08-27 10:42 UTC Modified: 2008-03-07 17:16 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: gwynne@php.net Assigned:
Status: Closed Package: SQLite related
PHP Version: 6CVS-2007-08-27 (CVS) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gwynne@php.net
New email:
PHP Version: OS:

 

 [2007-08-27 10:42 UTC] gwynne@php.net
Description:
------------
PDO SQLite3 calls sqlite3_bind_text() for all non-blob and non-null parameter types regardless of whether integer data is provided. Integer data can be bound with sqlite3_bind_int(), which saves memory space and improves efficiency, as well as storing the intended type in a database which uses SQLite3's value typing. Patch is at: http://news.php.net/php.internals/31935

Reproduce code:
---------------
Difficult to show reproduction.

Expected result:
----------------
Difficult to show reproduction.

Actual result:
--------------
Difficult to show reproduction.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-14 22:27 UTC] lapo at lapo dot it
Even worse than the integer case (which leads to inefficience) is the case of BLOBs, which leads to corruption of data: text values can't contain \0, while blob data can.

E.g. from command line sqlite3:
sqlite> SELECT LENGTH(X'12000000');
4
sqlite> SELECT LENGTH(CAST(X'12000000' AS text));
1

Because "case PDO_PARAM_LOB" falls through to "case PDO_PARAM_STR", which uses sqlite3_bind_text... using PDO is impossible to store BLOB data in Sqlite3.
 [2008-01-15 15:30 UTC] scottmac@php.net
I have a patch to deal with both of these issues here, just waiting to here back from Wez about adding it.
http://server.macvicar.net/patches/php-bug42443.patch
 [2008-01-16 14:43 UTC] lapo at lapo dot it
Thanks, I'll try it this evening. =)

The only remaining inconvenience may be that PHP strings can contain "\0" while SQLite texts apparently do not... but for short binary values in PHP strings are more common, such as in the result of serialize(), while PARAM_LOB *must* be used as a stream. On the other hand I really wouldn't know how to solve the problem otherwise (except creating a PARAM_BINARY that acts like PARAM_LOG but is used like PARAM_STR, but that would "break" the PDO API...).
 [2008-03-07 17:16 UTC] scottmac@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

In 5.3+ at the moment.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC