#33844 [Opn]: Apache2 crashes when SQLite PDO returns 0 Rows

From: Date: Sun, 24 Jul 2005 06:16:17 +0000
Subject: #33844 [Opn]: Apache2 crashes when SQLite PDO returns 0 Rows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-82375@lists.php.net to get a copy of this message
ID: 33844 User updated by: dangerousdave86 at hotmail dot com Reported By: dangerousdave86 at hotmail dot com Status: Open Bug Type: Reproducible crash Operating System: Windows XP Pro SP1 PHP Version: 5.1.0b3 New Comment: Decided to create reproduce code in the end. Previous Comments: ------------------------------------------------------------------------ [2005-07-24 08:14:07] dangerousdave86 at hotmail dot com Description: ------------ When I query an SQLite database through PHP5.1.0b3's PDO functions on Apache2.0.54, everything appears fine. This is until I query the database with a SELECT that matches no rows. What I mean by this is that when I do a SELECT with criteria I know will match DB rows, it returns the rows nicely. When I query the DB using a criteria I know will not match any rows in the database, PHP stops at the $PDO->Query call and Apache crashes. Apache Crash data: Faulting application Apache.exe, version 2.0.54.0, faulting module php5ts.dll, version 5.1.0.0, fault address 0x00008034. I have not attempted to reproduce this bug outside of my current project, if this would help I can do it. But to reproduce I think all is necersary is to run a select on an SQLite Database that will not return any rows. I know that I have not coded this problem myself, as when I swap to the MySQL PDO driver, there are no issues whatsoever. The current goal of my PHP project is to migrate to SQLite from MySQL, and this bug is standing right in the way of doing so. So until it is fixed I am kind of stuck. Any feedback would be appreciated, I'll do my best to help anyone who tries to find the problem. Reproduce code: --------------- <?php // Reproduce SQLite bug // Assumes file permissions are good if (file_exists ('database1.db')) unlink ('database1.db'); // Create the new PDO object $PDO = new PDO ('sqlite:database1.db'); // Fill the database with test data $PDO->query ('CREATE TABLE "test_table" ( "test_index" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "test_data" TEXT NOT NULL default "")'); for ($i = 1; $i <= 10; $i++) $PDO->query ('INSERT INTO test_table ("test_data") VALUES ("value '.$i.'")'); // Possible die here to stop and check the database worked using SQLite3.exe from sqlite.org // die; $query_match = 'SELECT * FROM test_table WHERE test_data = "value 5"'; $query_nomatch = 'SELECT * FROM test_table WHERE test_data = "value 100"'; // Run working query $PDOStatement = $PDO->query ($query_match); $results = $PDOStatement->fetchAll (PDO_FETCH_ASSOC); file_put_contents ('debug.txt',print_r ($results, TRUE), FILE_APPEND); // Run non-working query $PDOStatement = $PDO->query ($query_nomatch); // The program will never get to here $results = $PDOStatement->fetchAll (PDO_FETCH_ASSOC); file_put_contents ('debug.txt',print_r ($results, TRUE), FILE_APPEND); ?> Expected result: ---------------- I would expect this script to just execute, outputing a blank page and a text file with some information in it. Actual result: -------------- Apache crashes ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33844&edit=1

« previous php.bugs (#82375) next »