Re: bug in DBD::MySQL on Ubuntu / Sarge
Patrick Galbraith <[email protected]>
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <[email protected]> |
Martin,
It doesn't look like a DBD::mysql problem to me. It has something to do
with the script. What does the output of program show? Perhaps print out
"print substr($dcref, -11) . "\n"; prior to each call of do to see that
it's actually passing the value to the driver. Or, try it without the
substring call. Try some variation to see if the problem is in the value
being passed to do.
regards,
Patrick
Martin Waite wrote:
> Hi,
>
> I have come across a problem in DBD::MySQL while porting code from Woody
> to Sarge and Ubuntu (both hoary and breezy).
>
> The following script creates a simple test table and attempts to perform
> 6 updates. The first 3 updates work correctly, but in the final 3
> updates, the key is erroneously taken as NULL:
>
> #! /usr/bin/perl5 -w
>
> use strict;
> use DBI;
>
> my $dbh = DBI->connect( "dbi:mysql:test:host=chadwick:port=3306",
> 'testuser', 'test', {RaiseError=>1, PrintError=>0} );
>
>
> $dbh->do( "drop table if exists update_bug" );
> $dbh->do( "create table update_bug( k int not null primary key, status int not null )" );
>
> my $v = '4000930012345671';
>
> $dbh->do( "update update_bug set status = 5 where k = ?", undef, substr( $v, -11 ) ); # OK
> $dbh->do( "update update_bug set status = 5 where k = ?", undef, substr( $v, -11 ) ); # OK
>
> cancel( $v ); # OK
> cancel( $v ); # bug - k is NULL
> cancel( $v ); # bug - k is NULL
> cancel( $v ); # bug - k is NULL
>
> sub cancel {
> my ( $dcref ) = @_;
> print "DCREF: $dcref\n";
> $dbh->do( "update update_bug set status = 5 where k = ?", undef, substr( $dcref, -11 ) );
> }
>
>
>
> In the Query log of the 4.1.11 database we're connecting to, we see:
>
> 060526 14:24:52 4605 Connect testuser@chadwick on test
> 4605 Query SET AUTOCOMMIT=1
> 4605 Query drop table if exists update_bug
> 4605 Query create table update_bug( k int not null primary key, status int not null )
> 4605 Query update update_bug set status = 5 where k = '30012345671'
> 4605 Query update update_bug set status = 5 where k = '30012345671'
> 4605 Query update update_bug set status = 5 where k = '30012345671'
> 4605 Query update update_bug set status = 5 where k = NULL
> 4605 Query update update_bug set status = 5 where k = NULL
> 4605 Query update update_bug set status = 5 where k = NULL
> 4605 Quit
>
>
>
> The problem seems to be related to the fact that a substring expression
> is passed as an argument to DBI::do, but only when the DBI::do is called
> within a subroutine.
>
> I'm stumped here. Is this a bug in Perl or DBD::MySQL, or just the
> versions on Sarge and Ubuntu ?
>
> regards,
> Martin
>
>
>
>
>
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/[email protected]