Req #74883 [NEW]: SQLite3::__construct() produces "out of memory" exception with invalid flags

From: Date: Sat, 08 Jul 2017 21:00:39 +0000
Subject: Req #74883 [NEW]: SQLite3::__construct() produces "out of memory" exception with invalid flags
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209925@lists.php.net to get a copy of this message
From:             jeroen at treurniet dot us
Operating system: Windows
PHP version:      7.1.7
Package:          SQLite related
Bug Type:         Feature/Change Request
Bug description:SQLite3::__construct() produces "out of memory" exception with invalid
flags

Description:
------------
When opening a SQLite3 database with both the SQLITE3_OPEN_READONLY and
SQLITE3_OPEN_CREATE flags, an exception thrown which reads "Unable to
open database: out of memory".

While it is understandable that it doesn't make sense to combine the two
flags (since creating a new database would require writing, and opening
an empty database that cannot be written to is probably not very
helpful), the "out of memory" error is confusing, and does not seem like
an accurate description of the problem. Especially since the
documentation for neither SQLite3::__construct() and SQLite3::open()
hints to this, I was personally stuck for some time figuring out why it
was telling me it was out of memory.

This behavior occurs regardless of whether or not the specified database
file actually exists/is readable.

I propose that when either of these functions is called with
SQLITE3_OPEN_READONLY, they should either silently ignore the
SQLITE3_OPEN_CREATE flag if it is specified, or produce an E_NOTICE with
a more helpful message, rather than throwing a fatal error with an
unhelpful description ("out of memory").

Test script:
---------------
$db = new SQLite3( "my_database.db", SQLITE3_OPEN_READONLY |
SQLITE3_OPEN_CREATE );

Expected result:
----------------
Either silently ignore the SQLITE3_OPEN_CREATE flag, or throw an
E_NOTICE rather than an exception.

Actual result:
--------------
Fatal error: Uncaught Exception: Unable to open database: out of memory
in ...

-- 
Edit bug report at https://bugs.php.net/bug.php?id=74883&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74883&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74883&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74883&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74883&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74883&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74883&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74883&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74883&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74883&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74883&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74883&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74883&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74883&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74883&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74883&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74883&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74883&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74883&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74883&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74883&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#209925) next »