Another overhaul of transaction/savepoint handling
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC / Firebird.pm
CommitLineData
dff4c3a3 1package DBIx::Class::Storage::DBI::ODBC::Firebird;
2
3use strict;
4use warnings;
e46df41a 5use base 'DBIx::Class::Storage::DBI::Firebird::Common';
dff4c3a3 6use mro 'c3';
e02b39b4 7use Try::Tiny;
8use namespace::clean;
dff4c3a3 9
dff4c3a3 10=head1 NAME
11
12DBIx::Class::Storage::DBI::ODBC::Firebird - Driver for using the Firebird RDBMS
13through ODBC
14
d1fc96c7 15=head1 DESCRIPTION
dff4c3a3 16
e46df41a 17Most functionality is provided by
18L<DBIx::Class::Storage::DBI::Firebird::Common>, see that driver for details.
dff4c3a3 19
90489c23 20To build the ODBC driver for Firebird on Linux for unixODBC, see:
21
22L<http://www.firebirdnews.org/?p=1324>
23
d1fc96c7 24This driver does not suffer from the nested statement handles across commits
a870aa85 25issue that the L<DBD::InterBase|DBIx::Class::Storage::DBI::InterBase> or the
26L<DBD::Firebird|DBIx::Class::Storage::DBI::Firebird> based driver does. This
27makes it more suitable for long running processes such as under L<Catalyst>.
d1fc96c7 28
1ae0a36c 29=cut
30
6f7a118e 31__PACKAGE__->datetime_parser_type ('DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format');
32
e02b39b4 33# releasing savepoints doesn't work for some reason, but that shouldn't matter
90d7422f 34sub _exec_svp_release { 1 }
5c6ed0b5 35
90d7422f 36sub _exec_svp_rollback {
e02b39b4 37 my ($self, $name) = @_;
38
39 try {
40 $self->_dbh->do("ROLLBACK TO SAVEPOINT $name")
41 }
42 catch {
43 # Firebird ODBC driver bug, ignore
44 if (not /Unable to fetch information about the error/) {
45 $self->throw_exception($_);
46 }
47 };
48}
49
c5827074 50package # hide from PAUSE
51 DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format;
52
53# inherit parse/format date
54our @ISA = 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format';
55
a870aa85 56my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T
c5827074 57my $timestamp_parser;
58
59sub parse_datetime {
60 shift;
61 require DateTime::Format::Strptime;
62 $timestamp_parser ||= DateTime::Format::Strptime->new(
63 pattern => $timestamp_format,
64 on_error => 'croak',
65 );
66 return $timestamp_parser->parse_datetime(shift);
67}
68
69sub format_datetime {
70 shift;
71 require DateTime::Format::Strptime;
72 $timestamp_parser ||= DateTime::Format::Strptime->new(
73 pattern => $timestamp_format,
74 on_error => 'croak',
75 );
76 return $timestamp_parser->format_datetime(shift);
77}
78
1ae0a36c 791;
80
dff4c3a3 81=head1 AUTHOR
82
83See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
84
85=head1 LICENSE
86
87You may distribute this code under the same terms as Perl itself.
88
89=cut
e02b39b4 90# vim:sts=2 sw=2: