Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: arnaud [...] underlands.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.09
Fixed in: (no value)



Subject: Segfault when accessing $sth->{TYPE}
Hi, While testing Catalyst, I got a segfault, tracking down the bug, it lead me to Class::DBI::AsForm. I've contacted Tony Bowden the maintener who corrected me and spoted the problem in DBD::SQLite I don't know if it's related to bug #12347. I've include a test case that reproduce my problem, I've tried to make it as minimalistic as possible while staying close to my configuration. It segfaults on the to_field call... Hope this helps. Don't hesitate to ask any information you would need to correct it. Thanks in advance. Arnaud PS: My System is Gentoo Linux Class::DBI is 0.96 Class::DBI::AsForm is 2.41 Class::DBI::SQLite is 0.09 DBI is 1.47 DBD::SQLite is 1.09
#!/usr/bin/perl use strict; #Initialize the database require DBI; unlink 'bug.db'; my $dbh = DBI->connect("dbi:SQLite:dbname=bug.db"); my $sql = join( '', (<DATA>) ); for my $statement ( split /;/, $sql ) { $statement =~ s/\#.*$//mg; # strip # comments $statement =~ s/auto_increment//g; next unless $statement =~ /\S/; eval { $dbh->do($statement) }; die "$@: $statement" if $@; } package Bug; use base 'Class::DBI::SQLite'; use Class::DBI; use Class::DBI::AsForm; __PACKAGE__->set_db('Main', 'dbi:SQLite:dbname=bug.db', '', ''); package Bug::Level; use base 'Bug'; __PACKAGE__->table('Level'); #__PACKAGE__->columns(Primary => qw/id/); __PACKAGE__->columns(All => qw/id label/); package Bug::Test; use base 'Bug'; __PACKAGE__->table('Test'); #__PACKAGE__->columns(Primary => qw/id/); __PACKAGE__->columns(All => qw/id title description/); package Bug::Question; use base 'Bug'; __PACKAGE__->table('question'); #__PACKAGE__->columns(Primary => qw/id/); __PACKAGE__->columns(All => qw/id title test level description/); __PACKAGE__->has_a(level => 'Bug::Level'); __PACKAGE__->has_a(test => 'Bug::Test'); package main; my $level = Bug::Level->retrieve(1) or die "can't retrieve ($!)"; print $level->label; for (Bug::Question->columns) { print "$_ = ",Bug::Question->to_field($_)->as_XML, $/; } __DATA__ create table level ( id integer PRIMARY KEY, label varchar(40) ); INSERT INTO level ('label') VALUES ('level1'); INSERT INTO level ('label') VALUES ('level2'); create table test ( id integer PRIMARY KEY, title varchar(40) NOT NULL, description text ); INSERT INTO test ('title','description') VALUES ('test title 1','test 1 description'); create table question ( id integer primary key, title varchar(40) NOT NULL, test REFERENCES test, level REFERENCES level, description text );
From: Tom Hukins <tom [...] eborcom.com>
Here's a really simple example that exhibits the same behaviour. I discovered this independently but found a similar bug, so I thought I'd file it here rather than as a separate issue. Tom
#!/usr/bin/perl use strict; use warnings; use DBI (); use Fatal qw(open close); { my $dbh = DBI->connect('dbi:SQLite:dbname=test.db'); my $sql = do {local $/; <DATA>}; $dbh->do($sql) or die; } { my %result; my $dbh = DBI->connect('dbi:SQLite:dbname=test.db'); my $sth = $dbh->prepare("SELECT * FROM example WHERE 1=0"); $sth->execute; my @columns = @{$sth->{NAME}}; my $x = $sth->{TYPE}; } __DATA__ CREATE TABLE example ( id PRIMARY KEY, name );
Will be fixed in 1.13.