php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68393 PDO Does Not Produce Exception For 'sqlite:' With Missing Filepath
Submitted: 2014-11-10 21:59 UTC Modified: 2020-10-22 13:13 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: kyra at existing dot me Assigned: cmb (profile)
Status: Closed Package: PDO SQLite
PHP Version: 5.6.2 OS: Linux
Private report: No CVE-ID: None
 [2014-11-10 21:59 UTC] kyra at existing dot me
Description:
------------
I was passing the SQLite filepath portion of the DSN as a variable and happened to pass an empty string, but PDO did not raise an Exception, and gave no indication the connection had failed.

If you check out http://3v4l.org/o1k3M you can see at some point after PHP 5.2.14 that this behavior began.

Test script:
---------------
$db = new PDO('sqlite:');

Expected result:
----------------
Fatal error: Uncaught exception 'PDOException' with message...


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-10 22:38 UTC] salathe@php.net
From SQLite's point of view, this looks to be okay.

Here's a snippet from the SQLite docs[1], in the "Opening
A New Database Connection" section[2]:

  If the filename is an empty string, then a private,
  temporary on-disk database will be created. This 
  private database will be automatically deleted as 
  soon as the database connection is closed.

[1] http://www.sqlite.org/c3ref/intro.html
[2] http://www.sqlite.org/c3ref/open.html
 [2014-11-10 22:52 UTC] kyra at existing dot me
Is this temp database being created in /tmp or in the current directory?

Also, isn't this basically the same thing as using :memory to create a temp db, but on disk? I would have thought there would be a :disk option instead of assuming the user wanted to create a temp db on disk, and had not made a coding error.

Is there, or should there be a note about this behavior in the PHP docs? I know I was stumped by my try/catch not working as expected to warn me.
 [2015-06-22 12:19 UTC] mbeccati@php.net
-Type: Bug +Type: Documentation Problem
 [2015-06-22 12:19 UTC] mbeccati@php.net
Switching to documentation problem. Maybe it would be worth to add a note?
 [2015-06-22 15:05 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2015-06-22 15:05 UTC] cmb@php.net
The behavioral change has been introduced as fix for bug
#52010[1]. How temporary databases are handled by Sqlite3 is
#detailed in [2].

[1] <http://svn.php.net/viewvc/php/php-src/trunk/ext/pdo_sqlite/sqlite_driver.c?r1=300612&r2=300611&pathrev=300612>
[2] <https://www.sqlite.org/inmemorydb.html#temp_db>
 [2020-10-22 13:10 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=4d037a4cd06d326fa18bf46d6f7488566e60e9c7
Log: Fix #68393: PDO Does Not Produce Exception For 'sqlite:' With Missing Filepath
 [2020-10-22 13:10 UTC] phpdocbot@php.net
-Status: Verified +Status: Closed
 [2020-10-22 13:13 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-10-22 14:00 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=c824a9ced966198922a974e6256fe3f942c7d9aa
Log: Remove PDO sqlite2 driver related info, Fix #68393: PDO Does Not Produce Exception For 'sqlite:' ...
 [2020-12-30 11:58 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=7040ceed4e3c4ba1d3b365c4aaf05197cc6f7717
Log: Remove PDO sqlite2 driver related info, Fix #68393: PDO Does Not Produce Exception For 'sqlite:' ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 15:01:28 2024 UTC