Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DBD-Oracle CPAN distribution.

Report information
The Basics
Id: 72623
Status: resolved
Priority: 0/
Queue: DBD-Oracle

People
Owner: Nobody in particular
Requestors: cj10 [...] cam.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] ora_server_version when database is not open
Download (untitled) / with headers
text/plain 802b
I was recently using perl to monitor a Data Guard standby database. I don't have an Active Data Guard licence, so my standby database is mounted, but not open. (I was conected using ora_session_mode=>ORA_SYSDBA.) I noticed 'undefined value' warnings from Oracle.pm. These were caused by the subroutine ora_server_version, which was attempting to fetch the version numbers from the view product_component_version. This view is only available if the database is open. The view v$version provides the same data, in a slightly different format. This view is available in mounted databases, whether open or not. Here is a patch against the trunk (revision 15009) which changes ora_server_version to use v$version instead of product_component_version. P.S. v$version dates back at least to Oracle 7.3.4.
Subject: server_version_patch.txt
Index: Oracle.pm =================================================================== --- Oracle.pm (revision 15009) +++ Oracle.pm (working copy) @@ -952,12 +952,15 @@ sub ora_server_version { my $dbh = shift; return $dbh->{ora_server_version} if defined $dbh->{ora_server_version}; - $dbh->{ora_server_version} = - [ split /\./, $dbh->selectrow_array(<<'SQL', undef, 'Oracle%', 'Personal Oracle%') .'']; -SELECT version - FROM product_component_version - WHERE product LIKE ? or product LIKE ? + my $banner = $dbh->selectrow_array(<<'SQL', undef, 'Oracle%', 'Personal Oracle%'); +SELECT banner + FROM v$version + WHERE banner LIKE ? OR banner LIKE ? SQL + if (defined $banner) { + $dbh->{ora_server_version} = [$1, $2, $3, $4, $5] if + $banner =~ /(?:^|\s)(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\d+)(?:\s|$)/; + } } sub ora_nls_parameters {
From: cj10 [...] cam.ac.uk
Download (untitled) / with headers
text/plain 117b
... and, with apologies, here is another version of the patch, which odes exactly the same thing, but more elegantly.
Subject: server_version_patch_2.txt
Index: Oracle.pm =================================================================== --- Oracle.pm (revision 15009) +++ Oracle.pm (working copy) @@ -952,12 +952,15 @@ sub ora_server_version { my $dbh = shift; return $dbh->{ora_server_version} if defined $dbh->{ora_server_version}; - $dbh->{ora_server_version} = - [ split /\./, $dbh->selectrow_array(<<'SQL', undef, 'Oracle%', 'Personal Oracle%') .'']; -SELECT version - FROM product_component_version - WHERE product LIKE ? or product LIKE ? + my $banner = $dbh->selectrow_array(<<'SQL', undef, 'Oracle%', 'Personal Oracle%'); +SELECT banner + FROM v$version + WHERE banner LIKE ? OR banner LIKE ? SQL + if (defined $banner) { + my @version = $banner =~ /(?:^|\s)(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\d+)(?:\s|$)/; + $dbh->{ora_server_version} = \@version if @version; + } } sub ora_nls_parameters {
Download (untitled) / with headers
text/plain 248b
On Tue Nov 22 12:27:24 2011, cj10@cam.ac.uk wrote: Show quoted text
> ... and, with apologies, here is another version of the patch, which > odes exactly the same thing, but more elegantly.
Thanks Charles, applied to trunk. Martin -- Martin J. Evans Wetherby, UK
v1.38 released.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.