From: csaba at alum dot mit dot edu
Operating system: Win 2K
PHP version: 5.0.0RC1
PHP Bug Type: SQLite related
Bug description: ATTACH DATABASE not working
Description:
------------
I've been using mysqlite regularly for the past two weeks, no complaints.
However, I cannot seem to do a SQLite ATTACH DATABASE at all. Variations
I have tried: sqlite_popen in place of sqlite_open (especially when $db1
was ':memory:', closing $db1 before attaching, using ':memory:' in place
of either 'Delme1.db1' or 'Delme2.db1'. I have also tried this
with and without open_basedir set to "." in my Apache 2.0.48
Csaba Gabor
Reproduce code:
---------------
$db1 = sqlite_open('Delme.db1', 0666, $sqliteerror);
sqlite_query ($db1, 'DROP TABLE Tab1;');
sqlite_query($db1, "CREATE TABLE Tab1 (Id INTEGER PRIMARY KEY, Fld1
VARCHAR(16));");
sqlite_query ($db1, "INSERT INTO Tab1 VALUES (NULL, 'foo1');");
print "<br>Rows: in DB1: " . sqlite_fetch_single (sqlite_query($db1,
"SELECT COUNT(*) FROM Tab1;"));
$db2 = sqlite_open('Delme.db2', 0666, $sqliteerror);
sqlite_query ($db2, 'DROP TABLE Tab2;');
sqlite_query($db2, "CREATE TABLE Tab2 (Id2 INTEGER PRIMARY KEY, Fld2
VARCHAR(8));");
sqlite_query ($db2, "INSERT INTO Tab2 VALUES (NULL, 'bar2');");
sqlite_query ($db2, "INSERT INTO Tab2 VALUES (NULL, 'bar3');");
print "<br>Rows in DB2: " . sqlite_fetch_single (sqlite_query($db2,
"SELECT COUNT(*) FROM Tab2;"));
@sqlite_query ($db2, "DETACH DATABASE db;");
sqlite_query ($db2, "ATTACH DATABASE 'Delme.db1' AS db4;");
$aRes = sqlite_array_query ($db2, "SELECT * FROM db4.Tab1;");
Expected result:
----------------
I expect that I can use the attached database as described at SQLite's
homepage.
Actual result:
--------------
Instead, in pretty much all the variants that I tried, I get the following
error on the ATTACH DATABASE line:
Warning: sqlite_query() [function.sqlite-query]: cannot attach empty
database: db4 in MyPHPFilesDir/myPHPCode.php on line 15
The following (last) line also gets a complaint but by then the damage has
already been done.
At some point, when I was testing using db3 (in place of where db4 now
is), I got the complaint that the database (db3) was already in use. I
don't know how that complaint started originating, nor could I get rid of
it. Going to db4 got me back to the usual complaint I indicated above.
--
Edit bug report at http://bugs.php.net/?id=27911&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27911&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27911&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27911&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27911&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27911&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27911&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27911&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27911&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27911&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27911&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27911&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27911&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27911&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27911&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27911&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27911&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27911&r=float