I'll fix it for the next release. (I might do it by having the DBI disable RaiseError and PrintError for the ping method.)
Tim. On Fri, Nov 23, 2001 at 12:13:34PM +1100, Fox, Michael wrote: > I see what you mean now, and I agree with you. If the dbh->ping is supposed > to be used for testing that a connection is still working, why should it > raise an error (even if RaiseError =1) rather than just returning an undef > (the same as it does with RaiseError=0)? > > BTW I tested this with perl 5.6.0, DBI-1.20 and DBD-Oracle-1.12 and got the > same results. > > -----Original Message----- > From: Andrei A. Voropaev [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 22, 2001 5:57 PM > To: Fox, Michael > Subject: Re: :Oracle ping terminates script > > > Well. I know that I have disconnected. This is just a script to reveal the > problem. The real problem is happening under mod_perl in Apache::DBI. There > Oracle connection handle gets corrupted (don't ask me why) and then we have > to > disconnect. But Apache::DBI attempts to ping on this cached connection and > produces the messages in error log. > > The problem is that ping is not supposed to print any error messages and it > is > not supposed to terminate the script if it gets "disconnected" $dbh. It > should > silently return false and nothing else. It does not do this. > > Andrei > > On Thu, Nov 22, 2001 at 09:04:15AM +1100, Fox, Michael wrote: > > You disconnected after the first ping, so the second ping failed as the > > output showed. > > > > The second version just handled this condition, and went on to excute the > > next statement, ie 'Finished work' not 'OK2' > > > > -----Original Message----- > > From: Andrei A. Voropaev [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, November 21, 2001 8:51 PM > > To: [EMAIL PROTECTED] > > Subject: DBD::Oracle ping terminates script > > > > > > Hi! > > > > I have hit very weird problem with method 'ping' of DBD::Oracle. Here's > > small script that illustrates it. > > > > --------------------------- > > #!/usr/bin/perl > > use DBI; > > > > my $dbh= DBI->connect('dbi:Oracle:mydb', 'myuser', 'mypass', {RaiseError > => > > 1, PrintError => 1, AutoCommit => 0}); > > die unless $dbh; > > > > print "OK 1\n" if $dbh->ping; > > > > $dbh->disconnect; > > > > print "OK 2\n" if $dbh->ping; > > print "Finished work\n"; > > --------------------------------- > > > > This script never prints out "Finished work". Instead it only prints > > "DBD::Oracle::db ping failed: ERROR Database disconnected at test.pl line > > 11" > > and dies afterwards. > > > > The weird part is that the script > > > > --------------------------- > > #!/usr/bin/perl > > use DBI; > > > > my $dbh= DBI->connect('dbi:Oracle:mydb', 'myuser', 'mypass', {RaiseError > => > > 1, PrintError => 1, AutoCommit => 0}); > > die unless $dbh; > > > > print "OK 1\n" if $dbh->ping; > > > > $dbh->disconnect; > > > > print "OK 2\n" if ping($dbh); > > print "Finished work\n"; > > > > sub ping { > > my($dbh) = @_; > > my $ok = 0; > > warn "New ping\n"; > > eval { > > local $SIG{__DIE__}; > > local $SIG{__WARN__}; > > # we know that Oracle 7 prepare does a describe so this will > > # actually talk to the server and is this a valid and cheap > > test. > > my $sth = $dbh->prepare("select SYSDATE from DUAL /* ping > */"); > > # But Oracle 8 doesn't talk to server unless we describe the > > query > > $ok = $sth && $sth->FETCH('NUM_OF_FIELDS'); > > }; > > return ($@) ? 0 : $ok; > > } > > > > --------------------------------- > > > > works the way it is expected. Namely prints output > > OK 1 > > Finished work > > > > That's exactly the same ping function just copied to my own namespace! > > I'm not subscribed to the list yet, so if some more information is needed > > then > > please email to me directly. > > > > $DBD::Oracle::VERSION = '1.07'; > > > > Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: > > Platform: > > osname=linux, osvers=2.2.17-8smp, archname=i386-linux > > uname='linux porky.devel.redhat.com 2.2.17-8smp #1 smp fri nov 17 > > 16:12:17 est 2000 i686 unknown ' > > config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dcc=gcc > > -Dcccdlflags=-fPIC -Dinstallprefix=/usr -Dprefix=/usr > -Darchname=i386-linux > > -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm -Di_gdbm -Di_shadow -Di_syslog > > -Dman3ext=3pm -Uuselargefiles' > > hint=recommended, useposix=true, d_sigaction=define > > usethreads=undef use5005threads=undef useithreads=undef > > usemultiplicity=undef > > useperlio=undef d_sfio=undef uselargefiles=undef > > use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef > > Compiler: > > cc='gcc', optimize='-O2 -march=i386 -mcpu=i686', gccversion=2.96 > > 20000731 (Red Hat Linux 7.1 2.96-79) > > cppflags='-fno-strict-aliasing' > > ccflags ='-fno-strict-aliasing' > > stdchar='char', d_stdstdio=define, usevfork=false > > intsize=4, longsize=4, ptrsize=4, doublesize=8 > > d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 > > ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', > > lseeksize=4 > > alignbytes=4, usemymalloc=n, prototype=define > > Linker and Libraries: > > ld='gcc', ldflags =' -L/usr/local/lib' > > libpth=/usr/local/lib /lib /usr/lib > > libs=-lnsl -ldl -lm -lc -lcrypt > > libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a > > 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: > > Built under linux > > Compiled at Mar 23 2001 12:49:50 > > @INC: > > /usr/lib/perl5/5.6.0/i386-linux > > /usr/lib/perl5/5.6.0 > > /usr/lib/perl5/site_perl/5.6.0/i386-linux > > /usr/lib/perl5/site_perl/5.6.0 > > /usr/lib/perl5/site_perl > > . > > Australia Post is committed to providing our customers with excellent > service. If we can assist you in any way please either telephone 13 13 18 > or visit our website www.auspost.com.au. > > > > CAUTION > > > > This e-mail and any files transmitted with it are privileged and > confidential information intended for the use of the addressee. The > confidentiality and/or privilege in this e-mail is not waived, lost or > destroyed if it has been transmitted to you in error. If you have received > this e-mail in error you must (a) not disseminate, copy or take any action > in reliance on it; (b) please notify Australia Post immediately by return > e-mail to the sender; and (c) please delete the original e-mail. > Australia Post is committed to providing our customers with excellent service. If >we can assist you in any way please either telephone 13 13 18 or visit our website >www.auspost.com.au. > > CAUTION > > This e-mail and any files transmitted with it are privileged and confidential >information intended for the use of the addressee. The confidentiality and/or >privilege in this e-mail is not waived, lost or destroyed if it has been transmitted >to you in error. If you have received this e-mail in error you must (a) not >disseminate, copy or take any action in reliance on it; (b) please notify Australia >Post immediately by return e-mail to the sender; and (c) please delete the original >e-mail. >