| 1 | package DBIO::Firebird::Storage::InterBase; | ||||||||||||
| 2 | # ABSTRACT: Driver for the Firebird RDBMS via L<DBD::InterBase> | ||||||||||||
| 3 | |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use base qw/DBIO::Firebird::Storage::Common/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use mro 'c3'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 1 | DBIO::Storage::DBI->register_driver('InterBase' => __PACKAGE__); | |||||||||||
| 10 | |||||||||||||
| 11 | 1 | __PACKAGE__->datetime_parser_type('DBIO::Firebird::DateTime::Format'); | |||||||||||
| 12 | |||||||||||||
| 13 | 1 | ▶ | use Try::Tiny; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 1 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | |||||||||||||
| 17 | 0 | ▶ | sub _ping { | ||||||||||
|
Subroutine
_ping: not called CC=2 SCAR=17.9
| |||||||||||||
| 18 | 0 | my $self = shift; | |||||||||||
| 19 | |||||||||||||
| 20 | 0 | ▶ | my $dbh = $self->_dbh or return 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | |||||||||||||
| 22 | 0 | local $dbh->{RaiseError} = 1; | |||||||||||
| 23 | 0 | local $dbh->{PrintError} = 0; | |||||||||||
| 24 | |||||||||||||
| 25 | 0 | ▶ | return try { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 26 | 0 | $dbh->do('select 1 from rdb$database'); | |||||||||||
| 27 | 0 | 1; | |||||||||||
| 28 | 0 | ▶ | } catch { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 29 | 0 | 0; | |||||||||||
| 30 | 0 | }; | |||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | # We want dialect 3 for new features and quoting to work, DBD::InterBase uses | ||||||||||||
| 34 | # dialect 1 (interbase compat) by default. | ||||||||||||
| 35 | 0 | ▶ | sub _init { | ||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||
| 37 | 0 | $self->_set_sql_dialect(3); | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 0 | ▶ | sub _set_sql_dialect { | ||||||||||
|
Subroutine
_set_sql_dialect: not called CC=5 SCAR=34.0
| |||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||
| 42 | 0 | ▶ | my $val = shift || 3; | ||||||||||
|
Condition0%0/2
shift() || 3
MC/DC0%0/1
shift() || 3
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 43 | |||||||||||||
| 44 | 0 | my $dsn = $self->_dbi_connect_info->[0]; | |||||||||||
| 45 | |||||||||||||
| 46 | 0 | ▶ | return if ref($dsn) eq 'CODE'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | |||||||||||||
| 48 | 0 | ▶ | if ($dsn !~ /ib_dialect=/) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | 0 | $self->_dbi_connect_info->[0] = "$dsn;ib_dialect=$val"; | |||||||||||
| 50 | 0 | my $connected = defined $self->_dbh; | |||||||||||
| 51 | 0 | $self->disconnect; | |||||||||||
| 52 | 0 | ▶ | $self->ensure_connected if $connected; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 53 | } | ||||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | |||||||||||||
| 57 | 0 | ▶ | sub connect_call_use_softcommit { | ||||||||||
|
Subroutine
connect_call_use_softcommit: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 58 | 0 | my $self = shift; | |||||||||||
| 59 | |||||||||||||
| 60 | 0 | $self->_dbh->{ib_softcommit} = 1; | |||||||||||
| 61 | } | ||||||||||||
| 62 | |||||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | sub connect_call_datetime_setup { | ||||||||||
|
Subroutine
connect_call_datetime_setup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 65 | 0 | my $self = shift; | |||||||||||
| 66 | |||||||||||||
| 67 | 0 | $self->_get_dbh->{ib_time_all} = 'ISO'; | |||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | |||||||||||||
| 71 | 1 | 1; | |||||||||||
| 72 | |||||||||||||
| 73 | __END__ | ||||||||||||
| 74 | |||||||||||||
| 75 | =pod | ||||||||||||
| 76 | |||||||||||||
| 77 | =encoding UTF-8 | ||||||||||||
| 78 | |||||||||||||
| 79 | =head1 NAME | ||||||||||||
| 80 | |||||||||||||
| 81 | DBIO::Firebird::Storage::InterBase - Driver for the Firebird RDBMS via L<DBD::InterBase> | ||||||||||||
| 82 | |||||||||||||
| 83 | =head1 VERSION | ||||||||||||
| 84 | |||||||||||||
| 85 | version 0.900001 | ||||||||||||
| 86 | |||||||||||||
| 87 | =head1 DESCRIPTION | ||||||||||||
| 88 | |||||||||||||
| 89 | This driver is a subclass of L<DBIO::Firebird::Storage::Common> for | ||||||||||||
| 90 | use with L<DBD::InterBase>, see that driver for general details. | ||||||||||||
| 91 | |||||||||||||
| 92 | You need to use either the | ||||||||||||
| 93 | L<disable_sth_caching|DBIO::Storage::DBI/disable_sth_caching> option or | ||||||||||||
| 94 | L</connect_call_use_softcommit> (see L</CAVEATS>) for your code to function | ||||||||||||
| 95 | correctly with this driver. Otherwise you will likely get bizarre error messages | ||||||||||||
| 96 | such as C<no statement executing>. The alternative is to use the | ||||||||||||
| 97 | L<ODBC|DBIO::Storage::DBI::ODBC::Firebird> driver, which is more suitable | ||||||||||||
| 98 | for long running processes such as under L<Catalyst>. | ||||||||||||
| 99 | |||||||||||||
| 100 | To turn on L<DBIO::InflateColumn::DateTime> support, see | ||||||||||||
| 101 | L</connect_call_datetime_setup>. | ||||||||||||
| 102 | |||||||||||||
| 103 | =head1 METHODS | ||||||||||||
| 104 | |||||||||||||
| 105 | =head2 connect_call_use_softcommit | ||||||||||||
| 106 | |||||||||||||
| 107 | Used as: | ||||||||||||
| 108 | |||||||||||||
| 109 | on_connect_call => 'use_softcommit' | ||||||||||||
| 110 | |||||||||||||
| 111 | In L<connect_info|DBIO::Storage::DBI/connect_info> to set the | ||||||||||||
| 112 | L<DBD::InterBase> C<ib_softcommit> option. | ||||||||||||
| 113 | |||||||||||||
| 114 | You need either this option or C<< disable_sth_caching => 1 >> for | ||||||||||||
| 115 | L<DBIO> code to function correctly (otherwise you may get C<no statement | ||||||||||||
| 116 | executing> errors.) Or use the L<ODBC|DBIO::Storage::DBI::ODBC::Firebird> | ||||||||||||
| 117 | driver. | ||||||||||||
| 118 | |||||||||||||
| 119 | The downside of using this option is that your process will B<NOT> see UPDATEs, | ||||||||||||
| 120 | INSERTs and DELETEs from other processes for already open statements. | ||||||||||||
| 121 | |||||||||||||
| 122 | =head2 connect_call_datetime_setup | ||||||||||||
| 123 | |||||||||||||
| 124 | Used as: | ||||||||||||
| 125 | |||||||||||||
| 126 | on_connect_call => 'datetime_setup' | ||||||||||||
| 127 | |||||||||||||
| 128 | In L<connect_info|DBIO::Storage::DBI/connect_info> to set the date and | ||||||||||||
| 129 | timestamp formats using: | ||||||||||||
| 130 | |||||||||||||
| 131 | $dbh->{ib_time_all} = 'ISO'; | ||||||||||||
| 132 | |||||||||||||
| 133 | See L<DBD::InterBase> for more details. | ||||||||||||
| 134 | |||||||||||||
| 135 | The C<TIMESTAMP> data type supports up to 4 digits after the decimal point for | ||||||||||||
| 136 | second precision. The full precision is used. | ||||||||||||
| 137 | |||||||||||||
| 138 | The C<DATE> data type stores the date portion only, and it B<MUST> be declared | ||||||||||||
| 139 | with: | ||||||||||||
| 140 | |||||||||||||
| 141 | data_type => 'date' | ||||||||||||
| 142 | |||||||||||||
| 143 | in your Result class. | ||||||||||||
| 144 | |||||||||||||
| 145 | Timestamp columns can be declared with either C<datetime> or C<timestamp>. | ||||||||||||
| 146 | |||||||||||||
| 147 | Datetime inflation is handled by L<DBIO::Firebird::DateTime::Format> (a | ||||||||||||
| 148 | L<DBIO::Storage::DateTimeFormat> subclass backed by L<DateTime::Format::Strptime>), | ||||||||||||
| 149 | which is pulled in as a transitive dependency of L<DBIO>. | ||||||||||||
| 150 | |||||||||||||
| 151 | For L<DBIO::Storage::DBI::ODBC::Firebird>, this is a noop. | ||||||||||||
| 152 | |||||||||||||
| 153 | =head1 CAVEATS | ||||||||||||
| 154 | |||||||||||||
| 155 | =over 4 | ||||||||||||
| 156 | |||||||||||||
| 157 | =item * | ||||||||||||
| 158 | |||||||||||||
| 159 | with L</connect_call_use_softcommit>, you will not be able to see changes made | ||||||||||||
| 160 | to data in other processes. If this is an issue, use | ||||||||||||
| 161 | L<disable_sth_caching|DBIO::Storage::DBI/disable_sth_caching> as a | ||||||||||||
| 162 | workaround for the C<no statement executing> errors, this of course adversely | ||||||||||||
| 163 | affects performance. | ||||||||||||
| 164 | |||||||||||||
| 165 | Alternately, use the L<ODBC|DBIO::Storage::DBI::ODBC::Firebird> driver. | ||||||||||||
| 166 | |||||||||||||
| 167 | =back | ||||||||||||
| 168 | |||||||||||||
| 169 | =head1 SEE ALSO | ||||||||||||
| 170 | |||||||||||||
| 171 | =over | ||||||||||||
| 172 | |||||||||||||
| 173 | =item * L<DBIO::Firebird> - Firebird schema component | ||||||||||||
| 174 | |||||||||||||
| 175 | =item * L<DBIO::Firebird::Storage> - Firebird driver via L<DBD::Firebird> | ||||||||||||
| 176 | |||||||||||||
| 177 | =item * L<DBIO::Firebird::Storage::Common> - Shared Firebird/InterBase logic | ||||||||||||
| 178 | |||||||||||||
| 179 | =item * L<DBIO::Storage::DBI> - Base DBI storage class | ||||||||||||
| 180 | |||||||||||||
| 181 | =back | ||||||||||||
| 182 | |||||||||||||
| 183 | =head1 AUTHOR | ||||||||||||
| 184 | |||||||||||||
| 185 | DBIO & DBIx::Class Authors | ||||||||||||
| 186 | |||||||||||||
| 187 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 188 | |||||||||||||
| 189 | Copyright (C) 2026 DBIO Authors | ||||||||||||
| 190 | Portions Copyright (C) 2005-2025 DBIx::Class Authors | ||||||||||||
| 191 | Based on DBIx::Class, heavily modified. | ||||||||||||
| 192 | |||||||||||||
| 193 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 194 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 195 | |||||||||||||
| 196 | =cut | ||||||||||||