DBIx::Connector::Driver::Oracle - Oracle-specific connection interface


DBIx-Connector documentation Contained in the DBIx-Connector distribution.

Index


Code Index:

Name

Top

DBIx::Connector::Driver::Oracle - Oracle-specific connection interface

Description

Top

This subclass of DBIx::Connector::Driver provides Oracle-specific implementations of the following methods:

ping
savepoint
release
rollback_to

Authors

Top

This module was written and is maintained by:

David E. Wheeler <david@kineticode.com>

It is based on code written by:

Matt S. Trout <mst@shadowcatsystems.co.uk>
Peter Rabbitson <rabbit+dbic@rabbit.us>
David Jack Olrik <djo@cpan.org>

Copyright and License

Top


DBIx-Connector documentation Contained in the DBIx-Connector distribution.

package DBIx::Connector::Driver::Oracle;

use strict;
use warnings;
use base 'DBIx::Connector::Driver';
our $VERSION = '0.45';

# Note from https://rt.cpan.org/Ticket/Display.html?id=47005:
# DBD::Oracle has some shutdown state in which it will return 1 on ping as
# long as the socket is still open. This however did not guarantee the server
# is any longer in a state to execute queries. So what happened was:
#
# 1) the weird state is reached
# 2) a txn_do takes place and fails on the first sql command
# 3) the code calls ping() and gets a connected reply
# 4) the txn_do is not retried
# 5) ...
# 6) users lose profit

sub ping {
    my ($self, $dbh) = @_;
    eval {
        local $dbh->{RaiseError} = 1;
        $dbh->do('select 1 from dual');
    };
    return $@ ? 0 : 1;
}

sub savepoint {
    my ($self, $dbh, $name) = @_;
    $dbh->do("SAVEPOINT $name");
}

# Oracle automatically releases a savepoint when you start another one with
# the same name.
sub release { 1 }

sub rollback_to {
    my ($self, $dbh, $name) = @_;
    $dbh->do("ROLLBACK TO SAVEPOINT $name");
}

1;
__END__