(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]/
