Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 5000
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: swany [...] easynews.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.29
Fixed in: (no value)



Subject: ATTACH database does not work
Attempting to use the ATTACH command does not work. An error is returned each time. Show quoted text
-----------------TEST DATABASE----------------------------- [/home/tester/scripts/indexer]: sqlite test2.db SQLite version 2.8.6 Enter ".help" for instructions
sqlite> .tables sqlite> create table test(t varchar2(200)); sqlite> .tables
test
sqlite>
-----------------TEST SCRIPT------------------------------- use DBI; $lite = DBI->connect('DBI:SQLite:test.db',"",""); #open a new db $sql = "attach database \"test2.db\" as data;"; #attach existing db $sth=$lite->prepare($sql); #prep statement #trying to attach the database causes an error $sth->execute; #STATEMENT FAILS
-----------------ERROR OUTPUT------------------------------- DBD::SQLite::st execute failed: SQL logic error or missing database at test.pl line 9.
[guest - Wed Jan 21 20:17:28 2004]: Show quoted text
> Attempting to use the ATTACH command does not work. An error is > returned > each time. > > > -----------------TEST DATABASE----------------------------- > [/home/tester/scripts/indexer]: sqlite test2.db > SQLite version 2.8.6 > Enter ".help" for instructions
> sqlite> .tables > sqlite> create table test(t varchar2(200)); > sqlite> .tables
> test
> sqlite>
> > -----------------TEST SCRIPT------------------------------- > use DBI; > $lite = DBI->connect('DBI:SQLite:test.db',"",""); #open a new db > > $sql = "attach database \"test2.db\" as data;"; #attach existing db > $sth=$lite->prepare($sql); #prep statement > > #trying to attach the database causes an error > $sth->execute; #STATEMENT FAILS > > -----------------ERROR OUTPUT------------------------------- > DBD::SQLite::st execute failed: SQL logic error or missing database
at Show quoted text
> test.pl line 9. >
This is fixed by moving to the newest version of SQLite CVS.. It appears to be a bug in SQLite. On my system I removed all the sqlite C and object files from the Makefile, and added -lsqlite to the linker options. That way it uses the newest version of SQLite that I have installed on the system.
The following patch will fix the problem in the version of SQLite included with DBD-SQLite. This is essentially a copy of the CVS check-in by Dr H to fix the bug in the current version. --- attach.c 2003/12/06 22:22:36 1.8 +++ attach.c 2004/01/20 11:54:03 1.9 @@ -28,7 +28,10 @@ int rc, i; char *zFile, *zName; sqlite *db; + Vdbe *v; + v = sqliteGetVdbe(pParse); + sqliteVdbeAddOp(v, OP_Halt, 0, 0); if( pParse->explain ) return; db = pParse->db; if( db->file_format<4 ){ @@ -117,7 +120,10 @@ void sqliteDetach(Parse *pParse, Token *pDbname){ int i; sqlite *db; + Vdbe *v; + v = sqliteGetVdbe(pParse); + sqliteVdbeAddOp(v, OP_Halt, 0, 0); if( pParse->explain ) return; db = pParse->db; for(i=0; i<db->nDb; i++){