perlquestion
bsb
<b>Update: DBD::SQLite 1.14 now uses sqlite3_prepare_v2
and this problem has gone away. MattSargeant++</b>
<br><br>
I just dist-upgraded my system and have since encountered
the SQLite "database schema has changed" error in an
application that worked prior to the upgrade.
<br><br>
The "change" involved is running ANALYZE which
invalidates prepared statement handles
(see <a href="http://www.sqlite.org/faq.html#q17">the
SQLite FAQ</a>). Unfortunately, I don't control what
is prepared where as I use Class::DBI so I'm looking
to either revert to a working set of modules or
work around the problem at a lower level.
<br><br>
Does the code below reproduce the problem for other people?
<br>
Any tips on same versions or work-arounds?
<code>
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
unlink "a.db";
my $dbh = DBI->connect("dbi:SQLite:dbname=a.db") or die;
print '$DBI::VERSION ',$DBI::VERSION, "\n";
print '$DBD::SQLite::VERSION ',$DBD::SQLite::VERSION, "\n";
$dbh->do("create table a as select 123 as b");
my $sth = $dbh->prepare('select "hello" from a');
$dbh->do("analyze");
print "got ", $dbh->selectrow_array($sth), "\n";
$sth->finish;
#undef $sth; # to stop "closing dbh with active statement handles"
# http://rt.cpan.org/Ticket/Display.html?id=22688
$dbh->disconnect;
__END__
$ perl analyze_changed.pl
$DBI::VERSION 1.53
$DBD::SQLite::VERSION 1.13
DBD::SQLite::db selectrow_array failed: database schema has changed(1) at dbdimp.c line 421 at analyze_changed.pl line 16.
got
</code>
<b>Update:</b> I'm starting to think that the changes
during the upgrade causing this problem to manifest
were at the Class::DBI/Ima::DBI level. On my laptop
I get an error for the above but an older version
is the application (using ANALYZE) is fine.
I'll compare versions tomorrow.
<code>
$DBI::VERSION 1.51
$DBD::SQLite::VERSION 1.12
DBD::SQLite::db selectrow_array failed: database schema has changed(1) at dbdimp.c line 416 at - line 16.
got
</code>