Skip Menu |

This queue is for tickets about the POE-Component-EasyDBI CPAN distribution.

Report information
The Basics
Id: 48457
Status: rejected
Worked: 30 min
Priority: 0/
Queue: POE-Component-EasyDBI

People
Owner: GVL [...] cpan.org
Requestors: acferen [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.23
Fixed in: 1.24



Subject: SubProcess may not include all required modules (alt_fork only)
Because of the way alt_fork runs perl all modules needed may not get loaded. There may be other modules that tickle this bug, but I ran into it with Math::BigInt. Attached is a simple script to reproduce the problem. SimpleDBI has essentially the same issue see RT ticket #48401 for one possible solution.
Subject: dbi-easy.pl
use POE qw( Component::EasyDBI ); use Math::BigInt; # Set up the DBI POE::Component::EasyDBI->spawn( # or new(), which returns an obj alias => 'EasyDBI', dsn => 'DBI:mysql:database=test;host=localhost;port=3306', username => 'user', password => 'password', alt_fork => 1, ); # Create our own session to communicate with EasyDBI POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->post( 'EasyDBI', do => { sql => 'CREATE TABLE IF NOT EXISTS `test`.`my_bigint` (`my_int` INTEGER NOT NULL) ENGINE = MyISAM', event => 'table_created', } ); }, simple_res => sub { if ($_[ARG0]->{error}) { warn "EasyDBI : ",$_[ARG0]->{error},"\n"; warn "EasyDBI : ",$_[ARG0]->{sql},"\n"; } else { warn "success\n"; } }, table_created => sub { my $val = int(rand(42)); my $bi_val = Math::BigInt->new("-$val"); $_[KERNEL]->post( 'EasyDBI', insert => { sql => 'INSERT INTO `test`.`my_bigint` (`my_int`) VALUES (?)', placeholders => [$val], event => 'simple_res', }, ); $_[KERNEL]->post( 'EasyDBI', insert => { sql => 'INSERT INTO `test`.`my_bigint` (`my_int`) VALUES (?)', placeholders => [$bi_val], event => 'simple_res', }, ); $_[KERNEL]->post( 'EasyDBI' => 'shutdown' ); }, }, ); $poe_kernel->run();
On Wed Aug 05 12:06:46 2009, acferen@yahoo.com wrote: Show quoted text
> Because of the way alt_fork runs perl all modules needed > may not get loaded. There may be other modules that tickle this bug, > but I ran into it with Math::BigInt. > > Attached is a simple script to reproduce the problem. > > SimpleDBI has essentially the same issue see RT ticket #48401 for one > possible solution.
You're doing it wrong. You're trying to insert a blessed reference into the database. Math::BigInt tries to stringify it with Math::BigInt::Calc->_str() but fails to find the _str method because Math::BigInt::Calc doesn't get loaded because of the way alt_fork is designed (it executes another copy of the interpreter). You should call $bi_val->bstr in the placeholders and stringify the number or quote "$bi_val" to stringify it using overload.
Subject: easydbi-rt48457.pl
#!/usr/bin/env perl use strict; use warnings; use lib 'POE-Component-EasyDBI/lib'; use POE qw( Component::EasyDBI ); use Data::Dumper; use Math::BigInt; # Set up the DBI POE::Component::EasyDBI->spawn( # or new(), which returns an obj alias => 'EasyDBI', dsn => 'dbi:SQLite:easydbi.db', username => 'user', password => 'password', alt_fork => 1, ); # Create our own session to communicate with EasyDBI POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->post( 'EasyDBI', do => { sql => 'CREATE TABLE IF NOT EXISTS my_bigint (my_int INTEGER NOT NULL)', event => 'table_created', } ); }, simple_res => sub { if ($_[ARG0]->{error}) { warn "EasyDBI : ",$_[ARG0]->{error},"\n"; warn "EasyDBI : ",$_[ARG0]->{sql},"\n"; } else { warn "success\n"; } }, table_created => sub { my $val = int(rand(42)); my $bi_val = Math::BigInt->new("-$val"); $_[KERNEL]->post( 'EasyDBI', insert => { sql => 'INSERT INTO my_bigint (my_int) VALUES (?)', placeholders => [$val], event => 'simple_res', }, ); $_[KERNEL]->post( 'EasyDBI', insert => { sql => 'INSERT INTO my_bigint (my_int) VALUES (?)', placeholders => ["$bi_val"], event => 'simple_res', }, ); $_[KERNEL]->post('EasyDBI' => 'shutdown'); }, }, ); POE::Kernel->run();