On Tue 25 Mar 2003 16:48, Tim Bunce <[EMAIL PROTECTED]> wrote:
> On Tue, Mar 25, 2003 at 03:58:18PM +0100, H.Merijn Brand wrote:
> > On Tue 25 Mar 2003 15:09, Tim Bunce <[EMAIL PROTECTED]> wrote:
> > > Here's a Release Candidate of DBD::Oracle 1.14:
> > > 
> > >   http://homepage.eircom.net/~timbunce/DBD-Oracle-1.14-20020325gamma.tar.gz
> > > 
> > > I'd appreciate it if people could give it a whirl ASAP...
> > 
> > 
> > Hmm, allow even better fallback mechanism for version detection from $OH?
> > 
> > --8<---
> > Using Oracle in /pro/oracle/v817
> > 
> > WARNING: could not decode oracle version from
> >         /pro/oracle/v817/orainst/inspdver
> > or from Oracle Home:
> >         /pro/oracle/v817
> > Oracle version based logic may produce erroneous results
> > -->8---
> 
> How about this (untested, but ready for Oracle 10 :-) ...
> 
> --- Makefile.PL 2003/03/25 13:53:55     1.103
> +++ Makefile.PL 2003/03/25 15:26:43
> @@ -143,13 +143,16 @@
>      elsif ( $OH =~ m!.*(\d+\.\d+\.\d+)! ) { #decode it from $OH if possible
>          $inspdver{RDBMS} = $1;
>      }
> +    elsif ( "$OH/" =~ m!\D(1?\d)(\d)(\d)\D!) { # scary but handy
> +        $inspdver{RDBMS} = join ".", $1, $2, $3;
> +    }
>      else {
>          print qq{
>  WARNING: could not decode oracle version from
>          $OH/orainst/inspdver
>  or from Oracle Home:
>          $OH
> -Oracle version based logic may produce erroneous results
> +Oracle version based logic in Makefile.PL may produce erroneous results.
>  };
>      }

Yep. Works.

> And isn't there a more reliable way if orainst/inspdver doesn't exist?
> There ought to be something somewhere that gives the version number!

Yes:
--8<--- Literal snippet from one of my scripts, DB version stored in $prod[5]
    # 7.3.4
    for (qw(orainst/unix.rgs orainst/unix.prd unix.prd)) {
        local $/ = undef;
        open my $info, "< $ora_home/$_" or next;
        $opt_v > 7 and print STDERR "Scanning $_ for version info ...\n";
        <$info> =~ m/\brdbms_common\b.*?"([\d.]+)"/s or next;
        $prod[5] = $1;
        last;
        }
    unless ($prod[5]) { # 8.1.7
        for (qw(install/unix.rgs)) {
            local $/ = undef;
            open my $info, "< $ora_home/$_" or next;
            $opt_v > 7 and print STDERR "Scanning $_ for version info ...\n";
            <$info> =~ m/^rdbms\s+([\d.]+)/m or next;
            $prod[5] = $1;
            last;
            }
        }
    $opt_v and print STDERR "ORACLE_VSN\tis $prod[5]\n";
-->8---

> > Maybe you can guard the tests against `closed' databases:
> > 
> > t/cursor.....Unable to connect to Oracle as foo/bar (ORA-01034: ORACLE not
> >  available
> > ORA-27101: shared memory realm does not exist
> > HP-UX Error: 2: No such file or directory (DBD ERROR: OCISessionBegin))
> > Tests skipped.
> 
> I'm not sure what you mean by "guard". At least it skipped the test cleanly :)

Skip all without warnings after first connect fail. It's useless anyway.

> > DBI connect('','foo/bar',...) failed: ORA-01034: ORACLE not available
> > ORA-27101: shared memory realm does not exist
> > HP-UX Error: 2: No such file or directory (DBD ERROR: OCISessionBegin) at /pro/3
> > gl/CPAN/DBD-Oracle-1.14/blib/lib/Oraperl.pm line 97
> > Use of uninitialized value in concatenation (.) or string at test.pl line 69.
> > Use of uninitialized value in concatenation (.) or string at test.pl line 69.
> > ora_login: :
> 
> Ah, interestingly this highlights a change that's broken the old
> Oraperl global $ora_errno and $ora_errstr variables. Umm, question is,
> can I summon the will to fix it...

As you did with the patch below :)

> > After starting the DB, I get
> > 
> > t/meta.......Use of uninitialized value in sprintf at 
> > /pro/3gl/CPAN/DBD-Oracle-1.14/blib/lib/DBD/Oracle/GetInfo.pm line 7.
> > Use of uninitialized value in sprintf at 
> > /pro/3gl/CPAN/DBD-Oracle-1.14/blib/lib/DBD/Oracle/GetInfo.pm line 7.
> > Use of uninitialized value in sprintf at 
> > /pro/3gl/CPAN/DBD-Oracle-1.14/blib/lib/DBD/Oracle/GetInfo.pm line 7.
> > Use of uninitialized value in sprintf at 
> > /pro/3gl/CPAN/DBD-Oracle-1.14/blib/lib/DBD/Oracle/GetInfo.pm line 7.
> 
> > --8<--- GetInfo.pm
> > my $fmt = '%02d.%02d.%1d%1d%1d%1d';   # ODBC version string: ##.##.#####
> > my $sql_driver_ver = sprintf $fmt, split (/\./, $DBD::Oracle::VERSION);
> > -->8---
> > 
> > $DBD::Oracle::VERSION = 1.14
> > maybe you want
> > my $sql_driver_ver = sprintf $fmt, split (/\./, 
> > "$DBD::Oracle::VERSION.0.0.0.0.0.0");
> 
> Done. Thanks.

Welcome.

-- 
H.Merijn Brand        Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 632 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
     WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.024 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/



Reply via email to