Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 46627
Status: resolved
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: STEFFENW [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.608
Fixed in: (no value)



Subject: DBD::File is damaged now
You passed 2 parameters where 1 required [for Statement " UPDATE dbd_po_test.po SET fuzzy=? WHERE msgid=? But there are 2 "?" inside the statement and 2 given parameters. Version 1.607 has no such error.
Subject: Re: [rt.cpan.org #46627] DBD::File is damaged now
Date: Wed, 3 Jun 2009 08:12:36 +0200
To: bug-DBI [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Tue, 02 Jun 2009 15:59:26 -0400, "Steffen Winkler via RT" <bug-DBI@rt.cpan.org> wrote: Show quoted text
> You passed 2 parameters where 1 required [for Statement " > UPDATE dbd_po_test.po > SET fuzzy=? > WHERE msgid=? > > But there are 2 "?" inside the statement and 2 given parameters. > > Version 1.607 has no such error.
Can you tell me the environment a bit more, as I cannot reproduce that in a DBD::CSV setting --8<--- test.pl use strict; use warnings; use Test::More; use DBI; ok (my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { AutoCommit => 1, f_ext => ".csv/r", }), "connect"); ok ($dbh->do ("create table foo (id integer, name char (20))"), "create"); ok (my $sth = $dbh->prepare ("insert into foo values (?, ?)"), "prepare ins"); ok ($sth->execute (1, "Steffen"), "insert 1"); ok ($sth->execute (2, "Tux"), "insert 2"); ok ($sth->finish, "finish"); ok ($sth = $dbh->prepare ("update foo set name = ? where id = ?"), "prepare upd"); ok ($sth->execute ("Tim", 1), "update"); ok ($sth->finish, "finish"); open my $fh, "<", "foo.csv"; is (scalar <$fh>, qq{id,name\r\n}, "Field names"); is (scalar <$fh>, qq{1,Tim\r\n}, "Record 1"); is (scalar <$fh>, qq{2,Tux\r\n}, "Record 2"); is (scalar <$fh>, undef, "EOF"); close $fh; ok ($dbh->do ("drop table foo"), "drop"); done_testing (); -->8--- DBD-CSV $ prove -lv test.pl test.pl .. ok 1 - connect ok 2 - create ok 3 - prepare ins ok 4 - insert 1 ok 5 - insert 2 ok 6 - finish ok 7 - prepare upd ok 8 - update ok 9 - finish ok 10 - Field names ok 11 - Record 1 ok 12 - Record 2 ok 13 - EOF ok 14 - drop 1..14 ok All tests successful. Files=1, Tests=14, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.13 cusr 0.00 csys = 0.16 CPU) Result: PASS $ perl -MV=DBI DBI /pro/lib/perl5/site_perl/5.10.0/i686-linux-64int/DBI.pm: 1.608 $ perl -MV=DBD::File DBD::File /pro/lib/perl5/site_perl/5.10.0/i686-linux-64int/DBD/File.pm: 0.37 $ perl -MV=SQL::Statement SQL::Statement /pro/lib/perl5/site_perl/5.10.0/SQL/Statement.pm: 1.20 $ -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
I'll build the complete example.
I have rewritten my test for DBD::CSV. test.t ----------------------------------------------------------------------- #!perl -T use strict; use warnings; use Test::More tests => 33 + 1; use Test::NoWarnings; BEGIN { require_ok('DBI'); } my $dbh; # connext { $dbh = DBI->connect( 'dbi:CSV:f_dir=.', undef, undef, { RaiseError => 1, PrintError => 0, AutoCommit => 1, }, ); isa_ok($dbh, 'DBI::db', 'connect'); } # create table { unlink 'test.csv'; $dbh->do(<<'EO_SQL'); create table test.csv ( msgid varchar, msgstr varchar, fuzzy integer, c_format integer, php_format integer ) EO_SQL $dbh->do(<<'EO_SQL', undef, q{}, 'header'); INSERT INTO test.csv ( msgid, msgstr, ) VALUES (?, ?) EO_SQL $dbh->do(<<'EO_SQL', undef, 'id', 'str'); INSERT INTO test.csv ( msgid, msgstr, ) VALUES (?, ?) EO_SQL } { my $sth_update = $dbh->prepare(<<'EO_SQL'); UPDATE test.csv SET fuzzy=? WHERE msgid=? EO_SQL isa_ok($sth_update, 'DBI::st', 'prepare update header'); my $sth_select = $dbh->prepare(<<'EO_SQL'); SELECT fuzzy FROM test.csv WHERE msgid=? EO_SQL isa_ok($sth_select, 'DBI::st', 'prepare select header'); my @data = ( { test => 'header fuzzy=1', set => 1, get => [1], }, { test => 'header fuzzy=0', set => 0, get => [0], }, ); for my $data (@data) { my $result = $sth_update->execute($data->{set}, q{}); is($result, 1, "update: $data->{test}"); $result = $sth_select->execute(q{}); is($result, 1, "select: $data->{test}"); $result = $sth_select->fetchrow_arrayref(); is_deeply($result, $data->{get}, "fetch result: $data->{test}"); } } # change flags { my $sth_update = $dbh->prepare(<<'EO_SQL'); UPDATE test.csv SET fuzzy=?, c_format=?, php_format=? WHERE msgid=? EO_SQL isa_ok($sth_update, 'DBI::st'); my $sth_select = $dbh->prepare(<<'EO_SQL'); SELECT fuzzy, c_format, php_format FROM test.csv WHERE msgid=? EO_SQL isa_ok($sth_select, 'DBI::st'); my @data = ( { test => 'fuzzy=1', set => [1, 0, 0], get => [ { fuzzy => 1, c_format => 0, php_format => 0, }, ], }, { test => 'c-format=1', set => [0, 1, 0], get => [ { fuzzy => 0, c_format => 1, php_format => 0, }, ], }, { test => 'php-format=1', set => [0, 0, 1], get => [ { fuzzy => 0, c_format => 0, php_format => 1, }, ], callback => sub { check_file(shift, 'php-format') }, }, { test => 'c-format=-1', set => [0, -1, 0], get => [ { fuzzy => 0, c_format => -1, php_format => 0, }, ], callback => sub { check_file(shift, 'no-c-format') }, }, { test => 'php-format=-1', set => [0, 0, -1], get => [ { fuzzy => 0, c_format => 0, php_format => -1, }, ], callback => sub { check_file(shift, 'no-php-format') }, }, { test => 'all=1', set => [(1) x 3], get => [ { fuzzy => 1, c_format => 1, php_format => 1, }, ], callback => sub { check_file(shift, 'all') }, }, { test => 'all=0', set => [(0) x 3], get => [ { fuzzy => 0, c_format => 0, php_format => 0, }, ], callback => sub { check_file(shift) }, }, ); for my $data (@data) { my $result = $sth_update->execute( @{ $data->{set} }, 'id', ); is($result, 1, "update: $data->{test}"); $result = $sth_select->execute('id'); is($result, 1, "select: $data->{test}"); $result = $sth_select->fetchall_arrayref({}); is_deeply($result, $data->{get}, "fetch result: $data->{test}"); } } ----------------------------------------------------------------------- result DBI 1.604 ----------------------------------------------------------------------- D:\>perl -T test.t 1..34 ok 1 - require DBI; ok 2 - connect isa DBI::db ok 3 - prepare update header isa DBI::st ok 4 - prepare select header isa DBI::st ok 5 - update: header fuzzy=1 ok 6 - select: header fuzzy=1 ok 7 - fetch result: header fuzzy=1 ok 8 - update: header fuzzy=0 ok 9 - select: header fuzzy=0 ok 10 - fetch result: header fuzzy=0 ok 11 - The object isa DBI::st ok 12 - The object isa DBI::st ok 13 - update: fuzzy=1 ok 14 - select: fuzzy=1 ok 15 - fetch result: fuzzy=1 ok 16 - update: c-format=1 ok 17 - select: c-format=1 ok 18 - fetch result: c-format=1 ok 19 - update: php-format=1 ok 20 - select: php-format=1 ok 21 - fetch result: php-format=1 ok 22 - update: c-format=-1 ok 23 - select: c-format=-1 ok 24 - fetch result: c-format=-1 ok 25 - update: php-format=-1 ok 26 - select: php-format=-1 ok 27 - fetch result: php-format=-1 ok 28 - update: all=1 ok 29 - select: all=1 ok 30 - fetch result: all=1 ok 31 - update: all=0 ok 32 - select: all=0 ok 33 - fetch result: all=0 ok 34 - no warnings ----------------------------------------------------------------------- result DBI 1.608 ----------------------------------------------------------------------- D:\>perl -T test.t 1..34 ok 1 - require DBI; ok 2 - connect isa DBI::db ok 3 - prepare update header isa DBI::st ok 4 - prepare select header isa DBI::st ok 5 - update: header fuzzy=1 ok 6 - select: header fuzzy=1 ok 7 - fetch result: header fuzzy=1 DBD::CSV::st execute failed: You passed 2 parameters where 1 required [for State ment " UPDATE test.csv SET fuzzy=? WHERE msgid=? "] at test.pl line 84. ok 8 - no warnings # Looks like you planned 34 tests but ran 8. # Looks like your test exited with 255 just after 8. -----------------------------------------------------------------------
Subject: Re: [rt.cpan.org #46627] DBD::File is damaged now
Date: Fri, 5 Jun 2009 08:57:33 +0200
To: bug-DBI [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Thu, 04 Jun 2009 16:35:04 -0400, "Steffen Winkler via RT" <bug-DBI@rt.cpan.org> wrote: Show quoted text
> I have rewritten my test for DBD::CSV.
I narrowed it down to the fact that it fails on the *second* call to the execute () of the update statement. -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
CC: Tim Bunce <tim.bunce [...] gmail.com>
Subject: Re: [rt.cpan.org #46627] DBD::File is damaged now
Date: Fri, 5 Jun 2009 09:42:17 +0200
To: bug-DBI [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 05 Jun 2009 02:57:52 -0400, "h.m.brand@xs4all.nl via RT" <bug-DBI@rt.cpan.org> wrote: Show quoted text
> Queue: DBI > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=46627 > > > On Thu, 04 Jun 2009 16:35:04 -0400, "Steffen Winkler via RT" > <bug-DBI@rt.cpan.org> wrote: >
> > I have rewritten my test for DBD::CSV.
> > I narrowed it down to the fact that it fails on the *second* call to > the execute () of the update statement.
This is a bug in SQL::Statement. I have changed DBD::File to check for the mismatch on the first execute of the handle only, and warn instead of return with an error. It's up to Tim to decide if this is serious enough to warrant a new release. Note that if you *do* have a mismatch in any of the subsequent executes, they are now ignored :( -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Fixed for next release (due soon)