|
|
Re: bug in DBD::MySQL on Ubuntu / Sarge: msg#00045
db.mysql.perl
|
Subject: |
Re: bug in DBD::MySQL on Ubuntu / Sarge |
Hi Patrick,
I have compiled up v 3.0004 on Woody (Perl 5.6.1), and the script works
properly.
The problem seems to be tied to the version of Perl that is used.
regards,
Martin
Martin Waite wrote:
Hi Patrick,
I have changed the cancel subroutine to print out the substr expression:
sub cancel {
my ( $dcref ) = @_;
print "DCREF: $dcref\n";
print "update update_bug set status = 5 where k = ? ", substr(
$dcref, -11 ), "\n";
$dbh->do( "update update_bug set status = 5 where k = ?", undef,
substr( $dcref, -11 ) );
}
The output from the program now is:
martin@chadwick:~$ perl -w ~/ed/adhoc/update-bug
DCREF: 4000930012345671
update update_bug set status = 5 where k = ? 30012345671
DCREF: 4000930012345671
update update_bug set status = 5 where k = ? 30012345671
DCREF: 4000930012345671
update update_bug set status = 5 where k = ? 30012345671
DCREF: 4000930012345671
update update_bug set status = 5 where k = ? 30012345671
Which is what I'd expect, however the query log still shows:
4655 Query SET AUTOCOMMIT=1
4655 Query drop table if exists update_bug
4655 Query create table update_bug( k int not
null primary key, status int not null )
4655 Query update update_bug set status = 5
where k = '30012345671'
4655 Query update update_bug set status = 5
where k = '30012345671'
4655 Query update update_bug set status = 5
where k = '30012345671'
4655 Query update update_bug set status = 5
where k = NULL
4655 Query update update_bug set status = 5
where k = NULL
4655 Query update update_bug set status = 5
where k = NULL
4655 Quit
I have raised this issue through the MySQL Network, and they have
raised a bug. They tried the script on Suse, and the same problem
appears.
I have downloaded the latest DBD (3.0004) and the problem still
applies (this linked against the 5.0.20a client libraries). Poking
around in dbdimp.c, I noticed that a whole lot of debug switches on if
you set dbis->debug to 2, so in mysql_st_internal_execute, I set
dbis->debug to 2, but then the problem goes away. Very frustrating.
(By the way, what is the proper way to set debugging on ?)
My plan of action is to attempt to compile the woody DBD (v1.22 !) on
sarge/perl 5.8.4 and see if that works - but the version might be too
old to work with the new Perl. Probably easier to compile the newest
DBD on woody against Perl 5.6 and see if the problem follows with it.
I notice in the release email for DBD 3.0004 that you say threading
must be switched off on Solaris. The version of Perl on sarge /
ubuntu has threading switched on. I don't know how much of this is
relevant, but below I include the output of Perl -V for the two hosts
the script fails on (Sarge and Ubuntu), and the one it works on (Woody).
regards,
Martin
sarge: perl -V
Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
Platform:
osname=linux, osvers=2.6.15, archname=i386-linux-thread-multi
uname='linux ninsei 2.6.15 #1 smp preempt sat jan 7 12:47:52 pst
2006 i686 gnulinux '
config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN
-Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr
-Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8
-Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5
-Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local
-Dsitelib=/usr/local/share/perl/5.8.4
-Dsitearch=/usr/local/lib/perl/5.8.4 -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1
-Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl
-Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm
-Duseshrplib -Dlibperl=libperl.so.5.8.4 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN
-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-13)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
perllibs=-ldl -lm -lpthread -lc -lcrypt
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true,
libperl=libperl.so.5.8.4
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Jan 12 2006 14:54:46
@INC:
/etc/perl
/usr/local/lib/perl/5.8.4
/usr/local/share/perl/5.8.4
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.8
/usr/share/perl/5.8
/usr/local/lib/site_perl
.
Ubuntu: perl -V
Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
Platform:
osname=linux, osvers=2.6.8.1, archname=i386-linux-thread-multi
uname='linux terranova 2.6.8.1 #1 smp sat feb 26 13:03:40 utc 2005
i686 gnulinux '
config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN
-Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr
-Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8
-Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5
-Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local
-Dsitelib=/usr/local/share/perl/5.8.4
-Dsitearch=/usr/local/lib/perl/5.8.4 -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1
-Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl
-Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm
-Duseshrplib -Dlibperl=libperl.so.5.8.4 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN
-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='3.3.4 (Debian 1:3.3.4-9ubuntu5)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
perllibs=-ldl -lm -lpthread -lc -lcrypt
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true,
libperl=libperl.so.5.8.4
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Mar 9 2005 11:10:00
@INC:
/etc/perl
/usr/local/lib/perl/5.8.4
/usr/local/share/perl/5.8.4
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.8
/usr/share/perl/5.8
/usr/local/lib/site_perl
.
Woody: perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=linux, osvers=2.4.28-es, archname=i386-linux
uname='linux gluck 2.4.28-es #1 smp wed jan 12 09:55:22 est 2005
i686 unknown '
config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC
-Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.1
-Darchlib=/usr/lib/perl/5.6.1 -Dvendorprefix=/usr
-Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5
-Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.1
-Dsitearch=/usr/local/lib/perl/5.6.1 -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl
-Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Duseshrplib
-Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.4 20011002 (Debian prerelease)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -ldb -ldl -lm -lc -lcrypt
perllibs=-ldl -lm -lc -lcrypt
libc=/lib/libc-2.2.5.so, so=so, useshrplib=true,
libperl=libperl.so.5.6.1
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Mar 18 2005 16:57:39
@INC:
/usr/local/lib/perl/5.6.1
/usr/local/share/perl/5.6.1
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.6.1
/usr/share/perl/5.6.1
/usr/local/lib/site_perl/i386-linux
/usr/local/lib/site_perl
.
Patrick Galbraith wrote:
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/perl?unsub=gcdmp-msql-mysql-modules@xxxxxxxxxxx
|
|