Update: DBD::SQLite 1.14 now uses sqlite3_prepare_v2 and this problem has gone away. MattSargeant++

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.

The "change" involved is running ANALYZE which invalidates prepared statement handles (see the SQLite FAQ). 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.

Does the code below reproduce the problem for other people?
Any tips on same versions or work-arounds?
#!/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
Update: 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.
$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

In reply to Upgraded SQLite: "database changed" error by bsb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.