1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
use strict; use warnings;
package DBIx::Connector::Driver::Oracle;
use DBIx::Connector::Driver;
our $VERSION = '0.60';
our @ISA = qw( DBIx::Connector::Driver );
# 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__
=head1 NAME
DBIx::Connector::Driver::Oracle - Oracle-specific connection interface
=head1 DESCRIPTION
This subclass of L<DBIx::Connector::Driver|DBIx::Connector::Driver> provides
Oracle-specific implementations of the following methods:
=over
=item C<ping>
=item C<savepoint>
=item C<release>
=item C<rollback_to>
=back
=head1 AUTHORS
This module was written by:
=over
=item David E. Wheeler <david@kineticode.com>
=back
It is based on code written by:
=over
=item Matt S. Trout <mst@shadowcatsystems.co.uk>
=item Peter Rabbitson <rabbit+dbic@rabbit.us>
=item David Jack Olrik <djo@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2009-2013 David E. Wheeler. Some Rights Reserved.
This module is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
|