On Windows I've been using DBD::SQLite 1.12 because I get a lot of error messages on my console if I use version 1.13 with Class::DBI.
I've just come back up to the 1.13 version to do some investigation, so I thought I'd run your test script to see what happened. It looked like it ran OK, I got this output: C:\Documents and Settings\steven\My Documents\code\perl\testers>sqlite3 test.db SQLite version 3.3.5 Enter ".help" for instructions sqlite> create table table1 (text not null); sqlite> .quit C:\Documents and Settings\steven\My Documents\code\perl\testers>perl -MDBD::SQLi te -e "print $DBD::SQLite::VERSION" 1.13 C:\Documents and Settings\steven\My Documents\code\perl\testers>perl -v This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 33 registered patches, see perl -V for more detail) ... Binary build 819 [267479] provided by ActiveState http://www.ActiveState.com Built Aug 29 2006 12:42:41 C:\Documents and Settings\steven\My Documents\code\perl\testers>perl dbixc_exception 1.try to insert NULL value: DBD::SQLite::st execute failed: table1.text may not be NULL(1) at dbdimp.c line 402 at c:/Perl/site/lib/DBIx/Class/Storage/DBI.pm line 771. OOOPS: Caught exception >DBIx::Class::ResultSet::create(): Error executing 'INSE RT INTO table1 (text) VALUES (?)': table1.text may not be NULL(1) at dbdimp.c li ne 402 at dbixc_exception line 22<! 2.try to insert NULL value: DBD::SQLite::st execute failed: table1.text may not be NULL(21) at dbdimp.c line 376 at c:/Perl/site/lib/DBIx/Class/Storage/DBI.pm line 771. OOOPS: Caught exception >DBIx::Class::ResultSet::create(): Error executing 'INSE RT INTO table1 (text) VALUES (?)': table1.text may not be NULL(21) at dbdimp.c l ine 376 at dbixc_exception line 22<! If this line is printed, you didn't reproduce the error. Stephan Brunner wrote: >(Maybe my mail has been overlooked because I unintentionally replied to >the "Prefetching multiple has_many relationships" thread. I dare to post it >again.) > >Hi all, > >there's some details / history to this issue at >http://www.mail-archive.com/sqlite-users%40sqlite.org/msg18725.html > >Basline: My app (using DBIC 0.07002, DBD::SQLite 1.13, Perl 5.8.7 on kubuntu >6.06) is sometimes segfaulting when I repeatedly cause an exception in the >database (e.g. via invalid inserts). >I tracked down the issue to a minimum sample script (see below for sample with >DBIC; see discussion above for sample with CDBI). > >The thing is: the segfault occurs when using DBIC or CDBI, but not if I'm >using plain DBI. I'm not deep enought into this stuff to know what DBIC and >CDBI do different than plain DBI... > >The other thing is: It happens with DBD::SQLite 1.13, but not with 1.12 nor >1.11. > >I'm quite confused and don't know where exactly the problem lies (that's why I >CC'ed Matt Sergeant with the first post to this list). >Maybe as a first step, could some of you try to reproduce the behaviour I'm >seeing? Of course, any other help is much appreciated! > >Thanks & regards, >Stephan > >Here is a working sample with plain DBI. It catches two exceptions and >gracefully exits: >#------------------------------------------------------------------------- >#!/usr/bin/perl >use warnings; >use strict; > >use DBI; > >unlink "test.db"; # make sure we start from scratch >my $dbh = DBI->connect('dbi:SQLite:dbname=test.db'); >$dbh->do('CREATE TABLE table1 (text NOT NULL)'); >$dbh->{RaiseError} = 1; > ># Generate exceptions by trying to insert NULL values >foreach (1..2) { > print "$_.try to insert NULL value:\n"; > eval { > my $sth = $dbh->prepare('INSERT INTO table1 VALUES (?)'); > $sth->execute(undef); > # also working: > # $dbh->do('INSERT INTO table1 VALUES(NULL)'); > }; > if ($@) { > chomp $@; > print "OOOPS: Caught exception >$@<!\n"; > } >} >$dbh->disconnect; >#------------------------------------------------------------------------- > >Here is the same thing (?) using DBIx::Class. It requires the file test.db to >exist with the schema "CREATE TABLE table1 (text NOT NULL)". >On my box, it segfaults when attempting the second invalid insert: >#------------------------------------------------------------------------- >#!/usr/bin/perl >use warnings; >use strict; > >package My::Schema::Table1; >use base 'DBIx::Class'; >__PACKAGE__->load_components(qw/Core/); >__PACKAGE__->table('table1'); >__PACKAGE__->add_columns(qw/text/); > >package My::Schema; >use base qw/DBIx::Class::Schema/; >__PACKAGE__->load_classes('Table1'); > >package main; >my $schema = My::Schema->connect("dbi:SQLite:dbname=test.db"); > ># Generate exceptions by trying to insert NULL values >foreach (1..2) { > print "$_.try to insert NULL value:\n"; > eval { > $schema->resultset('Table1')->create({ text => undef }); > }; > if ($@) { > chomp $@; > print "OOOPS: Caught exception >$@<!\n"; > } >} >print "If this line is printed, you didn't reproduce the error.\n"; > >_______________________________________________ >List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class >Wiki: http://dbix-class.shadowcatsystems.co.uk/ >IRC: irc.perl.org#dbix-class >SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ >Searchable Archive: http://www.mail-archive.com/[email protected]/ > > > > _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[email protected]/
