line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Storage::DBI::InterBase; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1212
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
83
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
89
|
|
5
|
3
|
|
|
3
|
|
15
|
use base qw/DBIx::Class::Storage::DBI::Firebird::Common/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1563
|
|
6
|
3
|
|
|
3
|
|
20
|
use mro 'c3'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
12
|
|
7
|
3
|
|
|
3
|
|
75
|
use Try::Tiny; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
128
|
|
8
|
3
|
|
|
3
|
|
15
|
use namespace::clean; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
DBIx::Class::Storage::DBI::InterBase - Driver for the Firebird RDBMS via |
13
|
|
|
|
|
|
|
L<DBD::InterBase> |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This driver is a subclass of L<DBIx::Class::Storage::DBI::Firebird::Common> for |
18
|
|
|
|
|
|
|
use with L<DBD::InterBase>, see that driver for general details. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
You need to use either the |
21
|
|
|
|
|
|
|
L<disable_sth_caching|DBIx::Class::Storage::DBI/disable_sth_caching> option or |
22
|
|
|
|
|
|
|
L</connect_call_use_softcommit> (see L</CAVEATS>) for your code to function |
23
|
|
|
|
|
|
|
correctly with this driver. Otherwise you will likely get bizarre error messages |
24
|
|
|
|
|
|
|
such as C<no statement executing>. The alternative is to use the |
25
|
|
|
|
|
|
|
L<ODBC|DBIx::Class::Storage::DBI::ODBC::Firebird> driver, which is more suitable |
26
|
|
|
|
|
|
|
for long running processes such as under L<Catalyst>. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
To turn on L<DBIx::Class::InflateColumn::DateTime> support, see |
29
|
|
|
|
|
|
|
L</connect_call_datetime_setup>. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _ping { |
34
|
0
|
|
|
0
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
my $dbh = $self->_dbh or return 0; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
local $dbh->{RaiseError} = 1; |
39
|
0
|
|
|
|
|
|
local $dbh->{PrintError} = 0; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return try { |
42
|
0
|
|
|
0
|
|
|
$dbh->do('select 1 from rdb$database'); |
43
|
0
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
} catch { |
45
|
0
|
|
|
0
|
|
|
0; |
46
|
0
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# We want dialect 3 for new features and quoting to work, DBD::InterBase uses |
50
|
|
|
|
|
|
|
# dialect 1 (interbase compat) by default. |
51
|
|
|
|
|
|
|
sub _init { |
52
|
0
|
|
|
0
|
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
$self->_set_sql_dialect(3); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _set_sql_dialect { |
57
|
0
|
|
|
0
|
|
|
my $self = shift; |
58
|
0
|
|
0
|
|
|
|
my $val = shift || 3; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $dsn = $self->_dbi_connect_info->[0]; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
return if ref($dsn) eq 'CODE'; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ($dsn !~ /ib_dialect=/) { |
65
|
0
|
|
|
|
|
|
$self->_dbi_connect_info->[0] = "$dsn;ib_dialect=$val"; |
66
|
0
|
|
|
|
|
|
my $connected = defined $self->_dbh; |
67
|
0
|
|
|
|
|
|
$self->disconnect; |
68
|
0
|
0
|
|
|
|
|
$self->ensure_connected if $connected; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 connect_call_use_softcommit |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Used as: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
on_connect_call => 'use_softcommit' |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the |
79
|
|
|
|
|
|
|
L<DBD::InterBase> C<ib_softcommit> option. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
You need either this option or C<< disable_sth_caching => 1 >> for |
82
|
|
|
|
|
|
|
L<DBIx::Class> code to function correctly (otherwise you may get C<no statement |
83
|
|
|
|
|
|
|
executing> errors.) Or use the L<ODBC|DBIx::Class::Storage::DBI::ODBC::Firebird> |
84
|
|
|
|
|
|
|
driver. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The downside of using this option is that your process will B<NOT> see UPDATEs, |
87
|
|
|
|
|
|
|
INSERTs and DELETEs from other processes for already open statements. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub connect_call_use_softcommit { |
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$self->_dbh->{ib_softcommit} = 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 connect_call_datetime_setup |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Used as: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
on_connect_call => 'datetime_setup' |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the date and |
104
|
|
|
|
|
|
|
timestamp formats using: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$dbh->{ib_time_all} = 'ISO'; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
See L<DBD::InterBase> for more details. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The C<TIMESTAMP> data type supports up to 4 digits after the decimal point for |
111
|
|
|
|
|
|
|
second precision. The full precision is used. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The C<DATE> data type stores the date portion only, and it B<MUST> be declared |
114
|
|
|
|
|
|
|
with: |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
data_type => 'date' |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
in your Result class. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Timestamp columns can be declared with either C<datetime> or C<timestamp>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
You will need the L<DateTime::Format::Strptime> module for inflation to work. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
For L<DBIx::Class::Storage::DBI::ODBC::Firebird>, this is a noop. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub connect_call_datetime_setup { |
129
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$self->_get_dbh->{ib_time_all} = 'ISO'; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 CAVEATS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 4 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
with L</connect_call_use_softcommit>, you will not be able to see changes made |
141
|
|
|
|
|
|
|
to data in other processes. If this is an issue, use |
142
|
|
|
|
|
|
|
L<disable_sth_caching|DBIx::Class::Storage::DBI/disable_sth_caching> as a |
143
|
|
|
|
|
|
|
workaround for the C<no statement executing> errors, this of course adversely |
144
|
|
|
|
|
|
|
affects performance. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Alternately, use the L<ODBC|DBIx::Class::Storage::DBI::ODBC::Firebird> driver. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 FURTHER QUESTIONS? |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> |
157
|
|
|
|
|
|
|
by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can |
158
|
|
|
|
|
|
|
redistribute it and/or modify it under the same terms as the |
159
|
|
|
|
|
|
|
L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# vim:sts=2 sw=2: |