PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2 » Bug #1092

nextID error

Details

Submitted2004-03-30 04:58 UTC
Fromdjcricket at djcricket dot com
StatusBogus
PackageMDB2
PHP Version4.3.4
OSFreeBSD 5.2-CURRENT
Roadmaps(Not assigned)

Comments

[2004-03-30 04:58 UTC] djcricket at djcricket dot com

Description:
------------
MDB2 v.2.0.0.beta.2
SQLite v.2.8.12

Using the SQLite driver for MDB2, when I call the nextID () function, I get a 'MDB2 Error: unknown error' with userinfo of '[Last query: INSERT INTO proposition_id_seq (sequence) VALUES (NULL)]
[Native code: 14]
[Native message: unable to open database file]'.

Reproduce code:
---------------
$mdb2 = &MDB2:: Connect ( 'sqlite:////path/to/sqlite.db' );
$mdb->nextID ();

Expected result:
----------------
1

Actual result:
--------------
pear_error Object
(
[error_message_prefix] =>
[mode] => 16
[level] => 1024
[code] => -1
[message] => MDB2 Error: unknown error
[userinfo] => [Last query: INSERT INTO proposition_id_seq (sequence) VALUES (NULL)]
[Native code: 14]
[Native message: unable to open database file]

[backtrace] => Array
(
[0] => Array
(
[file] => /usr/local/share/pear/PEAR.php
[line] => 534
[function] => pear_error
[class] => pear_error
[type] => ->
[args] => Array
(
[0] => MDB2 Error: unknown error
[1] => -1
[2] => 16
[3] => pear_error
[4] => [Last query: INSERT INTO proposition_id_seq (sequence) VALUES (NULL)]
[Native code: 14]
[Native message: unable to open database file]

)

)

[1] => Array
(
[file] => /usr/local/share/pear/MDB2.php
[line] => 1039
[function] => raiseerror
[class] => pear
[type] => ::
[args] => Array
(
[0] => MDB2 Error: unknown error
[1] => -1
[2] =>
[3] =>
[4] => [Last query: INSERT INTO proposition_id_seq (sequence) VALUES (NULL)]
[Native code: 14]
[Native message: unable to open database file]

)

)

[2] => Array
(
[file] => /usr/local/share/pear/MDB2/Driver/sqlite.php
[line] => 468
[function] => raiseerror
[class] => mdb2_driver_sqlite
[type] => ->
[args] => Array
(
)

)

[3] => Array
(
[file] => /usr/home/justinh/public_html/svote/test.php
[line] => 17
[function] => query
[class] => mdb2_driver_sqlite
[type] => ->
[args] => Array
(
[0] => INSERT INTO proposition_id_seq (sequence) VALUES (NULL)
)

)

)

[callback] => pear_error
)

pear_error Object
(
[error_message_prefix] =>
[mode] => 16
[level] => 1024
[code] => -1
[message] => MDB2 Error: unknown error
[userinfo] => [Last query: INSERT INTO proposition_id_seq (sequence) VALUES (NULL)]
[Native code: 14]
[Native message: unable to open database file]

[backtrace] => Array
(
[0] => Array
(
[file] => /usr/local/share/pear/PEAR.php
[line] => 534
[function] => pear_error
[class] => pear_error
[type] => ->
[args] => Array
(
[0] => MDB2 Error: unknown error
[1] => -1
[2] => 16
[3] => pear_error
[4] => [Last query: INSERT INTO proposition_id_seq (sequence) VALUES (NULL)]
[Native code: 14]
[Native message: unable to open database file]

)

)

[1] => Array
(
[file] => /usr/local/share/pear/MDB2.php
[line] => 1039
[function] => raiseerror
[class] => pear
[type] => ::
[args] => Array
(
[0] => MDB2 Error: unknown error
[1] => -1
[2] =>
[3] =>
[4] => [Last query: INSERT INTO proposition_id_seq (sequence) VALUES (NULL)]
[Native code: 14]
[Native message: unable to open database file]

)

)

[2] => Array
(
[file] => /usr/local/share/pear/MDB2/Driver/sqlite.php
[line] => 468
[function] => raiseerror
[class] => mdb2_driver_sqlite
[type] => ->
[args] => Array
(
)

)

[3] => Array
(
[file] => /usr/home/justinh/public_html/svote/test.php
[line] => 17
[function] => query
[class] => mdb2_driver_sqlite
[type] => ->
[args] => Array
(
[0] => INSERT INTO proposition_id_seq (sequence) VALUES (NULL)
)

)

)

[callback] => pear_error
)

[2004-03-30 22:19 UTC] djcricket at djcricket dot com

More information:

The sqlite.db file is created on the command-line from a test class I've written. It uses the Manager class and an XML file. Information is inserted via other test classes. Some of those test classes use the nextID function without any problems.

I've tried some queries and they all work fine, but using nextID or executing the 'INSERT
INTO proposition_id_seq (sequence) VALUES (NULL)' manually both fail with the posted error.

[2004-03-30 22:21 UTC] djcricket at djcricket dot com

To clairify about my previous post, the paragraph about the nextID failing refers to trying to load the sqlite.db file via the webserver. The database file has been chmod'ed to 777.

[2004-03-31 01:06 UTC] djcricket at djcricket dot com

The sequence does exist and the SQL statement executes without error from the command line SQLite client, but throws that error when attempting call nextID () via a webpage.

[2004-03-31 03:44 UTC] djcricket at djcricket dot com

More investigation:

In attempt to better isolate the problem, I've installed the MDB2 CVS build and tried a series of basic SQL commands, loaded via a website and the console.

Console: All queries work fine.
Webpage: Read queries are fine, however manipulation queries do not work. This explains the failure from the nextID () function.

[2004-03-31 14:48 UTC] djcricket at djcricket dot com

The error is permissions based. SQLite requires the directory the database file resides in to be writable by the webserver in order to write lock files. I'm labeling this bogus and closing it.