php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47159 Creating a prepared statement without executing it makes database unclosable
Submitted: 2009-01-20 03:38 UTC Modified: 2009-01-20 09:59 UTC
From: pcdinh at gmail dot com Assigned:
Status: Closed Package: SQLite related
PHP Version: 5.3.0alpha3 OS: Windows XP SP3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 + 42 = ?
Subscribe to this entry?

 
 [2009-01-20 03:38 UTC] pcdinh at gmail dot com
Description:
------------
A database connection to SQLite3 can not be closed if I create a prepared statement without executing it.

Of course, I have already closed that statement explicitly before closing the database connection handler.

I had this warning: Unable to close due to unfinalised statements. It means that an invocation to close() on a statement handler does not work.

Reproduce code:
---------------
<?php

// By default, open uses SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE.
$db   = new SQLite3('./test.db');

$sql  = 'SELECT 1';

$stmt = $db->prepare($sql);

// Commenting out the line intentionally
// $rs = $stmt->execute();

if (true === $stmt->close())
{
    echo 'Statement is already closed but in this case it is not. ';
}

if (false === $db->close())
{
    echo 'But database connection can not be closed due to an error: '.$db->lastErrorMsg();
}
?>

Expected result:
----------------
Database connection should be closed as usual

Actual result:
--------------
The error message:

Statement is already closed but in this case it is not.
Warning: SQLite3::close() [sqlite3.close]: Unable to close database: 5, Unable to close due to unfinalised statements in D:\wvbsrc\repos\pone\trunk\tests\Plugin\test2_sqlite3.php on line 18
But database connection can not be closed due to an error: Unable to close due to unfinalised statements

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-20 09:59 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.

This is loosely related to bug #47145 which I fixed last night.

I've however checked all the prepare calls now to make sure things are free'd
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 08:01:28 2024 UTC