php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28235 SQLite returns null error message when database file isn't writable
Submitted: 2004-04-30 16:41 UTC Modified: 2004-07-18 01:00 UTC
Votes:4
Avg. Score:3.0 ± 2.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: simen at lunarlounge dot org Assigned:
Status: No Feedback Package: SQLite related
PHP Version: 5.0.0RC2 OS: Debian/GNU testing
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: simen at lunarlounge dot org
New email:
PHP Version: OS:

 

 [2004-04-30 16:41 UTC] simen at lunarlounge dot org
Description:
------------
The SQLite extension fail to detect when a database file isn't writable:

Warning: sqlite_query() [function.sqlite-query]: (null) in test.php on line 12



Reproduce code:
---------------
# touch test.sqlite
# chmod 0600 sqlite
# sqlite test.sqlite
> CREATE TABLE store (id INTEGER PRIMARY KEY, doc TEXT);

$db = sqlite_open('test.sqlite');

$sql = "INSERT INTO store (id, doc) VALUES (1, 'foo')";
$result = sqlite_query($db, $sql);

Expected result:
----------------
Warning: sqlite_query() [function.sqlite-query]: attempt to write a readonly database in test.php on line 12

Actual result:
--------------
Warning: sqlite_query() [function.sqlite-query]: (null) in test.php on line 12

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-13 12:43 UTC] nobody at example dot org
Never occured to me that this could be a bug, does the OO API handle this? 

  function connect(){
    try {
      if ( !$this->db_handle = @sqlite_open($this->db_name, 0666, $err) ){
        if ($this->db_handle===false){
          throw new DBEx('0: Could not open/create db or directory');
        } else {
          throw new DBEx(sqlite_last_error($this->db_handle).': '.
                    sqlite_error_string(sqlite_last_error($this->db_handle)));
        }
      } else { return true; }
    }
    catch (DBEx $ex){ $ex->borkage(); return false; }
  }
 [2004-07-10 14:48 UTC] wez@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

We upgraded the bundled sqlite library; please try the next snapshot (you might have to wait up to 3 hours) and see if this is fixed.
 [2004-07-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 02:01:29 2024 UTC