From: leon at messiah dot co dot nz Operating system: Linux (Ubuntu 7.10) PHP version: 5.2.5 PHP Bug Type: PDO related Bug description: Unexpected SQLite SQLITE_SCHEMA error
Description: ------------ Using PHP 5.2.5 (SQLite 3.4.2) the PHP code below gives the SQLite error SQLITE_SCHEMA (database schema has changed). According to the SQLite documentation: "In SQLite version 3, an SQLITE_SCHEMA error can only occur when using the sqlite3_prepare()/sqlite3_step()/sqlite3_finalize() API to execute SQL, not when using the sqlite3_exec()." http://www.sqlite.org/faq.html#q15 In the following code I AM getting a SQLITE_SCHEMA error, but I am not using prepared queries. It would therefore seem that either the version of SQLite I am using breaks the above promise, or the PHP PDO interface is using prepared queries internally. Reproduce code: --------------- // Print variable utility function show($var) { print "<pre>\n"; print_r( $var ); print "</pre>\n\n"; } // Path of database file $path = '/tmp/pdo-bug.db'; // Create first connection object and create table $conn_1 = new PDO("sqlite:$path"); $conn_1->exec('CREATE TABLE test1 ( key, value );'); // Fetch list of tables using first connection $result = $conn_1->query("SELECT name FROM sqlite_master WHERE type='table';"); show($result->fetchAll()); // Create a second PDO connection object to same database file $conn_2 = new PDO("sqlite:$path"); // Create a second table using second connection $conn_2->exec('CREATE TABLE test2 ( key2, value2 );'); // Fetch list of tables using first connection // Print error information if query fails $result = $conn_1->query("SELECT name FROM sqlite_master;"); if( $result instanceof PDOStatement ) show( $result->fetchAll() ); else show( $conn_1->errorInfo() ); // Remove database file unlink($path); Expected result: ---------------- Array ( [0] => Array ( [name] => test1 [0] => test1 ) ) Array ( [0] => Array ( [name] => test1 [0] => test1 ) [1] => Array ( [name] => test2 [0] => test2 ) ) Actual result: -------------- Array ( [0] => Array ( [name] => test1 [0] => test1 ) ) Array ( [0] => HY000 [1] => 17 [2] => database schema has changed ) -- Edit bug report at http://bugs.php.net/?id=43942&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43942&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43942&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43942&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43942&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43942&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43942&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43942&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43942&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43942&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43942&r=support Expected behavior: http://bugs.php.net/fix.php?id=43942&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43942&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43942&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43942&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43942&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43942&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43942&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43942&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43942&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43942&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43942&r=mysqlcfg