php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56297 Columns returning as NULL, even thou contain not NULL data.
Submitted: 2005-02-12 21:44 UTC Modified: 2005-02-27 20:32 UTC
From: Jared dot Williams1 at ntlworld dot com Assigned: wez (profile)
Status: Closed Package: PDO_SQLITE (PECL)
PHP Version: 5_0 CVS-2005-02-12 (dev) OS: Windows 2000/IIS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Jared dot Williams1 at ntlworld dot com
New email:
PHP Version: OS:

 

 [2005-02-12 21:44 UTC] Jared dot Williams1 at ntlworld dot com
Description:
------------
I _think_ (and hope) I've encounted an sqlite bug with 3.0.7, which does not seem present in the "official" sqlite3 (3.0.8) cmdline tool.

I cannot find the releveant sqlite ticket to prove this, but I think its highly unlikely PDO itself is causing it.

Several columns are always coming back with containing NULL, even thou there is some data in some rows, but modifing the SQL so one of these columns in used in the WHERE clause.

 


Reproduce code:
---------------
	$pdo = new PDO('sqlite:Xtvd.sql3', '', '');
	// Returns 94 rows all with p.starRating = NULL
	$stmt = $pdo->query("SELECT DISTINCT p.*
						FROM Program AS p INNER JOIN Schedule AS s ON s.program = p.id
						WHERE s.time BETWEEN '2005-02-13T01:30:00Z' AND '2005-02-13T13:30:00Z';");
	var_dump($stmt->fetchAll(PDO_FETCH_OBJ));

	echo '<hr />';
	// Returns 13 rows...
	$stmt = $pdo->query("SELECT DISTINCT p.*
						FROM Program AS p INNER JOIN Schedule AS s ON s.program = p.id
						WHERE s.time BETWEEN '2005-02-13T01:30:00Z' AND '2005-02-13T13:30:00Z'
								AND p.starRating IS NOT NULL
						;");
	var_dump($stmt->fetchAll(PDO_FETCH_OBJ));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-12 22:48 UTC] wez@php.net
Can you try manually building pdo_sqlite and linking against the sqlite 3.0.8 libraries?

Something like this:

wget http://pecl.php.net/get/PDO_SQLITE
tar xzf PDO_SQLITE-*.tgz
cd PDO_SQLITE-*
phpize
./configure --with-pdo-sqlite=/sqlite/prefix
make
make install
 [2005-02-13 09:56 UTC] Jared dot Williams1 at ntlworld dot com
Recompiled pdo_sqlite with 3.0.8 (& vs.net2003) and problem still exists.

Also tried "official" sqlite3 3.0.7 tool and problem doesnt appear.

Reclassified as PDO_SQLITE Bug.

Test case:

http://homepage.ntlworld.com/jared.williams/php5/bug3452.zip

Containing an sqlite3 database, and a php page, demonstrating the problem.
 [2005-02-19 07:44 UTC] Jared dot Williams1 at ntlworld dot com
Ooops, for got change bug type.
 [2005-02-27 00:25 UTC] wez@php.net
I've spent a lot of time sniffing around this tonight, and I believe it to be a bug in the sqlite library when using sqlite3_prepare() and sqlite3_step().  The library is telling PDO that the column type is NULL; even if I disregard that and ask for the data, the library returns me a NULL.

I'm opening a ticket on the sqlite site now.
 [2005-02-27 00:44 UTC] wez@php.net
SQLite ticket is:
http://www.sqlite.org/cvstrac/tktview?tn=1143
 [2005-02-27 20:32 UTC] wez@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

The problem was that the sqlite driver was telling PDO that the column was always NULL in situations where the first row of the query came back with a NULL value.
I've corrected this issue in CVS, and it should be available to you in the next windows snap build.
I'm going to double-check that the windows build actually builds now, because I also upgraded the bundled sqlite to 3.1.3.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed May 22 18:01:28 2019 UTC