Informix/Storage.pm

filter: Statementstmt 61.2% 95 / 155 Branchbran 26.5% 17 / 64 Conditioncond 20.0% 8 / 40 MC/DCmcdc 9.0% 2 / 22 Subroutinesub 70.5% 24 / 34 Podpod 83.3% 5 / 6 totaltotal 47.0% 151 / 321 CC 53 SCAR 42.7
CC
53
Cov
46%
_select_table_name
182.0
_gen_sql_bind
160.2
_adjust_bind_values
72.0
CRAP 71.8
« Informix/Test/Conformance.pm ↑ Summary Informix/DDL.pm »
1 package DBIO::Informix::Storage;
2 # ABSTRACT: Base Storage Class for Informix Support
3  
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 our $VERSION = '0.900004';
8  
9 12 ▶use base qw/DBIO::Storage::DBI/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 12 __PACKAGE__->register_driver('Informix' => __PACKAGE__);
13  
14 12 ▶use Context::Preserve 'preserve_context';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use DBI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use DBIO::Exception ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 ▶use DBIO::Informix::Types qw(lob_kind is_numeric_type);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 12 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 12 __PACKAGE__->sql_quote_char ('"');
22 12 __PACKAGE__->datetime_parser_type (
23 'DBIO::Informix::Storage::DateTime::Format'
24 );
25 12 __PACKAGE__->sql_maker_class('DBIO::Informix::SQLMaker');
26  
27 0 ▶sub dbio_deploy_class { 'DBIO::Informix::Deploy' }
Subroutine dbio_deploy_class: not called CC=1 SCAR=6.9
Pod undocumented
28  
29  
30 0 ▶sub deploy_setup { }
Subroutine deploy_setup: not called CC=1 SCAR=0.0
Pod documented
31  
32  
33 4 ▶sub _connect {
Subroutine _connect: called CC=1 SCAR=0.0
34 4 my $self = shift;
35 4 local $ENV{DELIMIDENT} = 'y';
36 4 return $self->next::method(@_);
37 }
38  
39  
40 # ADR 0026 (karr k23) -- DDL in a LOGGED Informix database is part of the
41 # transaction and is undone by ROLLBACK. Measured against Informix 15.0.1:
42 # CREATE TABLE, DROP TABLE, ALTER TABLE ADD / DROP / MODIFY of a column,
43 # ADD / DROP CONSTRAINT FOREIGN KEY, CREATE [UNIQUE] INDEX, DROP INDEX,
44 # CREATE VIEW, RENAME COLUMN and RENAME TABLE, each issued after BEGIN WORK,
45 # were all taken back by ROLLBACK WORK (t/65-transactional-ddl.t, live block).
46 # So core wraps a deploy's DDL loop in txn_do and a failing statement takes
47 # the earlier ones with it.
48 #
49 # The one place it does not hold is an UNLOGGED database (CREATE DATABASE
50 # without WITH LOG): there BEGIN WORK is SQL -256 "Transaction not available"
51 # and a connection with AutoCommit off cannot be made at all, so no DBIO
52 # transaction exists there, DDL or not, and declaring 1 changes nothing for
53 # it. The answer is therefore a class fact and not a probe of
54 # sysmaster:sysdatabases.is_logging.
55 12 __PACKAGE__->_use_transactional_ddl(1);
56  
57 # ADR 0037 (karr k23) -- Informix 15.0.1 takes a FROM-less SELECT and takes
58 # FROM sysmaster:sysdual. Neither is what this hook may rely on: it is a
59 # static class fact that cannot ask which release it talks to, a FROM-less
60 # SELECT is not something the older releases are known to take, and sysdual
61 # is a cross-database reference into sysmaster. systables is in every
62 # database of every release, and tabid 1 is systables itself, so exactly one
63 # row. Only the FROM clause is ours; the CASE spelling stays core's.
64 2 ▶sub _exists_value_sql {
Subroutine _exists_value_sql: called CC=1 SCAR=0.0
65 2 my $self = shift;
66  
67 2 return $self->next::method(@_) . ' FROM systables WHERE tabid = 1';
68 }
69  
70 12 __PACKAGE__->_use_supports_exists_query(1);
71  
72 # ADR 0039 (karr k23) -- UNION, UNION ALL, INTERSECT and EXCEPT are spelled
73 # as core's base map spells them (all four measured on Informix 15.0.1; MINUS
74 # is a synonym of EXCEPT). INTERSECT ALL and EXCEPT ALL are SQL -201 there.
75 # The refusal is unconditional: the hook cannot ask the server's release, and
76 # no release is known to have them.
77 12 my %UNSUPPORTED_SET_OPERATION = map { $_ => 1 } qw(intersect_all except_all);
78  
79 9 ▶sub _set_operation_keyword {
Subroutine _set_operation_keyword: called CC=3 SCAR=11.0
80 9 my ($self, $op) = @_;
81  
82 $self->throw_exception(
83 "Informix cannot express the set operation '$op': it has UNION, UNION ALL, "
84 . 'INTERSECT and EXCEPT (MINUS) and only in their distinct forms -- '
85 . 'INTERSECT ALL and EXCEPT ALL are a syntax error, SQL -201 (measured on '
86 . 'Informix 15.0.1). The refusal holds for every release because this hook '
87 . 'chooses the keyword without a connection (ADR 0039 section 7). The '
88 . 'distinct forms, INTERSECT and EXCEPT, are available as $rs->intersect '
89 . 'and $rs->except.'
90 9 ▶ ) if defined $op and $UNSUPPORTED_SET_OPERATION{$op};
Branch: 1 branch
BranchTrueFalseTotal
if defined $op and $UNSUPPORTED_SET_OPERATION{$op} 3 6 9
Condition66%2/3
defined $op and $UNSUPPORTED_SET_OPERATION{$op}
!ll&&!rl&&r
063
MC/DC50%1/2
defined $op and $UNSUPPORTED_SET_OPERATION{$op}
defined $op $UNSUPPORTED_SET_OPERATION{$op}
Truth table66%2/3
A and B
A= defined $opB= $UNSUPPORTED_SET_OPERATION{$op}
ABresult
0X0
100
111
91  
92 6 return $self->next::method($op);
93 }
94  
95 # ADR 0011 / karr k23 -- Informix 15.0.1 has no random-number function:
96 # RANDOM(), RAND(), DBMS_RANDOM_RANDOM() and a dbms_random package are all
97 # SQL -674 "Routine can not be resolved" (and the SQL Syntax reference lists
98 # no such function among the math functions). Inheriting core's RANDOM()
99 # would be the same -674 from the server; naming something invented
100 # (a session id, a clock) would shuffle nothing. So the hook refuses, at
101 # query-build time, and says why.
102 2 ▶sub _random_function {
Subroutine _random_function: called CC=1 SCAR=0.0
103 2 my $self = shift;
104  
105 2 $self->throw_exception(
106 'Informix has no random-number function, so $rs->rand cannot order by '
107 . 'one: RANDOM(), RAND() and DBMS_RANDOM are all SQL -674 (routine can not '
108 . 'be resolved) on Informix 15.0.1. A random function has to exist on the '
109 . 'server first (an SPL or UDR routine of your own), and can then be '
110 . 'ordered by through the order_by attribute.'
111 );
112 }
113  
114 # ADR 0040 section 7 (karr k23) -- the engine answers somewhere this seam does
115 # not reach. Informix has no EXPLAIN statement (core's inherited one is SQL
116 # -201); its plan facility is SET EXPLAIN ON [AVOID_EXECUTE], which writes the
117 # plan to the file sqexplain.out on the SERVER. The one place SQL can see a
118 # plan, sysmaster:syssqexplain, lists the statements running at the moment of
119 # the query that reads it (measured on 15.0.1: the row's plan is that of the
120 # query reading the view, the explained statement of a moment earlier is not
121 # there), so there is no second statement to read a plan back with. Refused
122 # before any statement is issued; in particular SET EXPLAIN is never turned on
123 # for the session as a side effect.
124 1 ▶sub _explain_query {
Subroutine _explain_query: called CC=1 SCAR=0.0
125 1 my $self = shift;
126  
127 1 $self->throw_exception(
128 'Informix cannot return a query plan as rows: it has no EXPLAIN '
129 . 'statement (SQL -201), and SET EXPLAIN ON [AVOID_EXECUTE] writes the plan '
130 . 'to the file sqexplain.out on the database server, where no statement of '
131 . 'this connection can read it back. sysmaster:syssqexplain shows only the '
132 . 'statements running at that moment, not the one explained before. Read '
133 . 'the plan from sqexplain.out on the server.'
134 );
135 }
136  
137 # ADR 0057 (karr k23) -- DBD::Informix takes dbi:Informix:database[@server]
138 # and nothing else: dbi:Informix:database=x and dbi:Informix:dbname=x;server=y
139 # are SQL -354. What follows the @ is a DBSERVERNAME of the sqlhosts file,
140 # not a host name: "database@a.host.name" and "database@server:9088" are both
141 # SQL -25555 "Server ... is not listed as a dbserver name in sqlhosts".
142 11 ▶sub _connect_params_dsn {
Subroutine _connect_params_dsn: called CC=4 SCAR=13.9
143 11 my ($self, $driver, $params) = @_;
144  
145 11 my ($dbname, $host, $port) = @{$params}{qw(dbname host port)};
146  
147 11 my $form = "DBD::$driver connects with dbi:$driver:<database>[\@<server>], "
148 . 'where the server is a DBSERVERNAME of the sqlhosts file';
149  
150 11 ▶ $self->throw_exception(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dbname 1 10 11
151 "Cannot build a DBD::$driver DSN from connection parameters without a "
152 . "dbname: $form, and a DBIO storage needs a database. Give dbname, or "
153 . 'supply a dsn instead.'
154 ) unless defined $dbname;
155  
156 10 ▶ $self->throw_exception(
Branch: 1 branch
BranchTrueFalseTotal
if defined $port 2 8 10
157 "Cannot build a DBD::$driver DSN from the connection parameter port: "
158 . "$form. The port belongs to that server's entry in sqlhosts and the DSN "
159 . 'has no place for it, so a port given here would be dropped and the '
160 . 'connection would go wherever sqlhosts says. Leave port out (host is '
161 . 'the DBSERVERNAME), or supply a dsn instead.'
162 ) if defined $port;
163  
164 8 ▶ return defined $host
Branch: 1 branch
BranchTrueFalseTotal
defined $host ? : 4 4 8
165 ? "dbi:$driver:$dbname\@$host"
166 : "dbi:$driver:$dbname";
167 }
168  
169 # ADR 0013 addendum (karr k23) -- the HostBound view's seam. The same form,
170 # the same meaning of the host: the view's host replaces the DBSERVERNAME of
171 # dbi:Informix:database@server, and a DSN that names none gets it. A view
172 # that carries a port declines: the DSN cannot say it (see above). Every
173 # other form -- the key=value one core's default writes included -- is no
174 # Informix DSN, and declines too. The form is named, never a value.
175 8 ▶sub _bind_host_into_dsn {
Subroutine _bind_host_into_dsn: called CC=4 SCAR=13.9
176 8 my ($self, $driver, $dsn, $host, $port) = @_;
177  
178 8 ▶ return (undef, 'a DSN that is not of the form dbi:Informix:database[@server]')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dsn and $dsn =~ /\A(dbi:Informix(?:\([^)]*\))?:)([^\@;=]*)(?:\@[^;=]*)?\z/is 2 6 8
Condition66%2/3
defined $dsn and $dsn =~ /\A(dbi:Informix(?:\([^)]*\))?:)([^\@;=]*)(?:\@[^;=]*)?\z/is
!ll&&!rl&&r
026
MC/DC50%1/2
defined $dsn and $dsn =~ /\A(dbi:Informix(?:\([^)]*\))?:)([^\@;=]*)(?:\@[^;=]*)?\z/is
defined $dsn $dsn =~ /\A(dbi:Informix(?:\([^)]*\))?:)([^\@;=]*)(?:\@[^;=]*)?\z/is
Truth table66%2/3
A and B
A= defined $dsnB= $dsn =~ /\A(dbi:Informix(?:\([^)]*\))?:)([^\@;=]*)(?:\@[^;=]*)?\z/is
ABresult
0X0
100
111
179 unless defined $dsn
180 and $dsn =~ /\A(dbi:Informix(?:\([^)]*\))?:)([^@;=]*)(?:\@[^;=]*)?\z/is;
181 6 my ($prefix, $database) = ($1, $2);
182  
183 6 ▶ return (undef, 'a view with a port; the DSN has no place for a port, it '
Branch: 1 branch
BranchTrueFalseTotal
if defined $port 1 5 6
184 . 'belongs to the server\'s entry in sqlhosts')
185 if defined $port;
186  
187 5 return "$prefix$database\@$host";
188 }
189  
190  
191 12 __PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
192  
193  
194 0 ▶sub _execute {
Subroutine _execute: not called CC=3 SCAR=24.8
195 0 my $self = shift;
196 0 my ($rv, $sth, @rest) = $self->next::method(@_);
197  
198 0 ▶ $self->__last_insert_id($sth->{ix_sqlerrd}[1])
Branch: 1 branch
BranchTrueFalseTotal
if $self->_perform_autoinc_retrieval 0 0 0
199 if $self->_perform_autoinc_retrieval;
200  
201 0 ▶ return (wantarray ? ($rv, $sth, @rest) : $rv);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
202 }
203  
204 0 ▶sub last_insert_id {
Subroutine last_insert_id: not called CC=1 SCAR=6.9
Pod documented
205 0 shift->__last_insert_id;
206 }
207  
208  
209  
210 0 ▶sub bind_attribute_by_data_type {
Subroutine bind_attribute_by_data_type: not called CC=3 SCAR=24.8
Pod documented
211 0 my ($self, $data_type) = @_;
212 0 ▶ my $kind = lob_kind($data_type) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $kind = lob_kind($data_type) or return 0 0 0
213 0 ▶ return $kind eq 'text' ? DBI::SQL_LONGVARCHAR() : DBI::SQL_LONGVARBINARY();
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'text' ? : 0 0 0
214 }
215  
216  
217 5 ▶sub _gen_sql_bind {
Subroutine _gen_sql_bind: called CC=19 SCAR=50.8
218 5 my ($self, $op, $ident, $args) = @_;
219  
220 5 my ($sql, $bind) = $self->next::method($op, $ident, $args);
221  
222 5 ▶ if ($op eq 'select') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "select") 5 0 5
223 5 for my $b (@$bind) {
224 6 my ($info, $v) = @$b;
225 6 ▶ next unless ref $info eq 'HASH' and defined $v and !ref $v;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $info eq "HASH" and defined $v and not ref $v 0 6 6
Condition33%2/6
ref $info eq "HASH" and defined $v and not ref $v
!ll&&!rl&&r
006
ref $info eq "HASH" and defined $v
!ll&&!rl&&r
006
MC/DC0%0/3
ref $info eq "HASH" and defined $v and not ref $v
ref $info eq "HASH" defined $v not ref $v
Truth table25%1/4
A and B and not(C)
A= ref $info eq "HASH"B= defined $vC= not ref $v
ABCresult
0XX0
10X0
1100
1111
226 6 ▶ my $kind = lob_kind($info->{sqlt_datatype}, $info->{sqlt_size}) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $kind = lob_kind($info->{"sqlt_datatype"}, $info->{"sqlt_size"}) or next 0 6 6
227 0 ▶ my $column = $info->{dbic_colname} // '?';
Condition0%0/2
$info->{"dbic_colname"} // "?"
l!l
00
MC/DC0%0/1
$info->{"dbic_colname"} // "?"
$info->{"dbic_colname"}
Truth table0%0/2
A
A= $info->{"dbic_colname"}
Aresult
11
00
228 0 my ($alias) = $column =~ /\A(.*)\.[^.]*\z/;
229 0 $column =~ s/\A.*\.//;
230 0 my $table = $self->_select_table_name($ident, $alias);
231  
232 # the other TEXT / BYTE columns of the table, which cannot be compared either
233 0 my %lob;
234 0 for my $name ($self->schema->sources) {
235 0 my $source = $self->schema->source($name);
236 0 ▶ next unless !ref $source->name and $source->name eq $table;
Branch: 1 branch
BranchTrueFalseTotal
unless not ref $source->name and $source->name eq $table 0 0 0
Condition0%0/3
not ref $source->name and $source->name eq $table
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $source->name and $source->name eq $table
not ref $source->name $source->name eq $table
Truth table0%0/3
not(A) and B
A= not ref $source->nameB= $source->name eq $table
ABresult
0X0
100
111
237 0 my $infos = $source->columns_info;
238 0 $lob{$_} = 1 for grep { lob_kind($infos->{$_}{data_type}, $infos->{$_}{size}) } $source->columns;
239 }
240 0 ▶ my $lobs = %lob ? " ($table holds the TEXT or BYTE columns " . join(', ', sort keys %lob) . ')' : '';
Branch: 1 branch
BranchTrueFalseTotal
%lob ? : 0 0 0
241  
242 0 ▶ DBIO::Exception->throw(sprintf
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'text' ? : 0 0 0
243 'refusing to compare the %s column %s.%s with a bound value: Informix allows no '
244 . 'TEXT or BYTE in a comparison (-615, Blobs are not allowed in this expression; '
245 . 'a cast to a character type is refused as well, -9634)%s. Compare a column that is '
246 . 'not a TEXT or BYTE.',
247 ($kind eq 'text' ? 'TEXT' : 'BYTE'), $table, $column, $lobs);
248 }
249 }
250  
251 5 $sql = $self->_strip_sql_comments($sql);
252  
253 5 ▶ if ($op eq 'insert' and Scalar::Util::blessed($ident)
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "insert" and builtin::blessed($ident) and $sql =~ /\A(INSERT INTO .+?) DEFAULT VALUES\z/s) 0 5 5
Condition33%2/6
$op eq "insert" and builtin::blessed($ident) and $sql =~ /\A(INSERT INTO .+?) DEFAULT VALUES\z/s
!ll&&!rl&&r
500
$op eq "insert" and builtin::blessed($ident)
!ll&&!rl&&r
500
MC/DC0%0/3
$op eq "insert" and builtin::blessed($ident) and $sql =~ /\A(INSERT INTO .+?) DEFAULT VALUES\z/s
$op eq "insert" builtin::blessed($ident) $sql =~ /\A(INSERT INTO .+?) DEFAULT VALUES\z/s
Truth table25%1/4
A and B and C
A= $op eq "insert"B= builtin::blessed($ident)C= $sql =~ /\A(INSERT INTO .+?) DEFAULT VALUES\z/s
ABCresult
0XX0
10X0
1100
1111
254 and $sql =~ /\A(INSERT INTO .+?) DEFAULT VALUES\z/s) {
255 0 my $head = $1;
256 0 my $infos = $ident->columns_info;
257 0 my ($auto) = grep { $infos->{$_}{is_auto_increment} } $ident->columns;
258 0 my ($nullable) = grep { $infos->{$_}{is_nullable} } $ident->columns;
259 0 ▶ if (defined $auto) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $auto) { } 0 0 0
elsif (defined $nullable) { } 0 0 0
260 0 $sql = sprintf '%s (%s) VALUES (0)', $head, $self->sql_maker->_quote($auto);
261 }
262 elsif (defined $nullable) {
263 0 $sql = sprintf '%s (%s) VALUES (NULL)', $head, $self->sql_maker->_quote($nullable);
264 }
265 }
266  
267 5 return ($sql, $bind);
268 }
269  
270 # the table behind an alias of a SELECT's from, for a message
271 0 ▶sub _select_table_name {
Subroutine _select_table_name: not called CC=13 SCAR=52.0
272 0 my ($self, $ident, $alias) = @_;
273  
274 0 ▶ return $ident->name if Scalar::Util::blessed($ident) and $ident->can('name') and !ref $ident->name;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($ident) and $ident->can("name") and not ref $ident->name 0 0 0
Condition0%0/6
builtin::blessed($ident) and $ident->can("name") and not ref $ident->name
!ll&&!rl&&r
000
builtin::blessed($ident) and $ident->can("name")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($ident) and $ident->can("name") and not ref $ident->name
builtin::blessed($ident) $ident->can("name") not ref $ident->name
Truth table0%0/4
A and B and not(C)
A= builtin::blessed($ident)B= $ident->can("name")C= not ref $ident->name
ABCresult
0XX0
10X0
1100
1111
275  
276 0 my %table;
277 0 ▶ for my $part (ref $ident eq 'ARRAY' ? @$ident : ()) {
Branch: 1 branch
BranchTrueFalseTotal
ref $ident eq 'ARRAY' ? : 0 0 0
278 0 ▶ my $hash = ref $part eq 'ARRAY' ? $part->[0] : $part;
Branch: 1 branch
BranchTrueFalseTotal
ref $part eq 'ARRAY' ? : 0 0 0
279 0 ▶ next unless ref $hash eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $hash eq "HASH" 0 0 0
280 0 for my $key (grep { !/\A-/ } keys %$hash) {
281 0 ▶ $table{$key} = $hash->{$key} unless ref $hash->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $hash->{$key} 0 0 0
282 }
283 }
284  
285 0 ▶ return $table{$alias} if defined $alias and defined $table{$alias};
Branch: 1 branch
BranchTrueFalseTotal
if defined $alias and defined $table{$alias} 0 0 0
Condition0%0/3
defined $alias and defined $table{$alias}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $alias and defined $table{$alias}
defined $alias defined $table{$alias}
Truth table0%0/3
A and B
A= defined $aliasB= defined $table{$alias}
ABresult
0X0
100
111
286 0 ▶ return (values %table)[0] if keys %table == 1;
Branch: 1 branch
BranchTrueFalseTotal
if keys %table == 1 0 0 0
287 0 return '?';
288 }
289  
290 # /* ... */ comments out of a statement, found by reading the SQL: one in a
291 # string, an identifier or another comment is not one
292 5 ▶sub _strip_sql_comments {
Subroutine _strip_sql_comments: called CC=4 SCAR=23.7
293 5 my ($self, $sql) = @_;
294 5 ▶ return $sql unless index($sql, '/*') >= 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($sql, "/*") != -1 5 0 5
295  
296 0 my $out = '';
297 0 ▶ while ($sql =~ m~\G(?: ('(?:[^']|'')*') | ("(?:[^"]|"")*") | (--[^\n]*(?:\n|\z)) | (\{[^}]*\}) | (/\*\+.*?\*/) | (/\*.*?\*/) | (.) )~gsx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sql =~ m[\G(?: ('(?:[^']|'')*') | ("(?:[^"]|"")*") | (--[^\n]*(?:\n|\z)) | (\{[^}]*\}) | (/\*\+.*?\*/) | (/\*.*?\*/) | (.) )]gsx) 0 0 0
298 0 ▶ $out .= defined $6 ? ' ' : $&;
Branch: 1 branch
BranchTrueFalseTotal
defined $6 ? : 0 0 0
299 }
300 0 return $out;
301 }
302  
303 # A value for a numeric column that is no number (karr k24). DBD::Informix
304 # hands the server the text of the value, and the server turns '' into NULL
305 # without a word (a row with a NULL where the caller wrote ''), while 'x' is
306 # an error (-1213). So that the answer does not depend on the text, a value
307 # that is no number for a numeric column is refused before the DBD sees it.
308 # The column is known from the bind's sqlt_datatype; a parameter without it is
309 # left as the caller wrote it.
310 0 ▶sub _adjust_bind_values {
Subroutine _adjust_bind_values: not called CC=8 SCAR=42.8
311 0 my ($self, $sth, $bind, $bind_attrs) = @_;
312  
313 0 for my $b (@$bind) {
314 0 my ($info, $v) = @$b;
315 0 ▶ next unless ref $info eq 'HASH' and defined $v and !ref $v;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $info eq "HASH" and defined $v and not ref $v 0 0 0
Condition0%0/6
ref $info eq "HASH" and defined $v and not ref $v
!ll&&!rl&&r
000
ref $info eq "HASH" and defined $v
!ll&&!rl&&r
000
MC/DC0%0/3
ref $info eq "HASH" and defined $v and not ref $v
ref $info eq "HASH" defined $v not ref $v
Truth table0%0/4
A and B and not(C)
A= ref $info eq "HASH"B= defined $vC= not ref $v
ABCresult
0XX0
10X0
1100
1111
316 0 ▶ next unless is_numeric_type($info->{sqlt_datatype});
Branch: 1 branch
BranchTrueFalseTotal
unless is_numeric_type($info->{"sqlt_datatype"}) 0 0 0
317 0 ▶ next if Scalar::Util::looks_like_number($v);
Branch: 1 branch
BranchTrueFalseTotal
if &Scalar::Util::looks_like_number($v) 0 0 0
318 DBIO::Exception->throw(sprintf
319 q{refusing the value '%s' for the numeric column '%s': it is no number, and Informix would }
320 . q{store NULL for '' or answer a conversion error (-1213) for other text},
321 0 ▶ $v, $info->{dbic_colname} // '?');
Condition0%0/2
$info->{"dbic_colname"} // "?"
l!l
00
MC/DC0%0/1
$info->{"dbic_colname"} // "?"
$info->{"dbic_colname"}
Truth table0%0/2
A
A= $info->{"dbic_colname"}
Aresult
11
00
322 }
323  
324 0 return $self->next::method($sth, $bind, $bind_attrs);
325 }
326  
327 0 ▶sub _exec_svp_begin {
Subroutine _exec_svp_begin: not called CC=1 SCAR=6.9
328 0 my ($self, $name) = @_;
329  
330 0 $self->_dbh->do("SAVEPOINT $name");
331 }
332  
333 # can't release savepoints
334 0 ▶sub _exec_svp_release { 1 }
Subroutine _exec_svp_release: not called CC=1 SCAR=6.9
335  
336 0 ▶sub _exec_svp_rollback {
Subroutine _exec_svp_rollback: not called CC=1 SCAR=6.9
337 0 my ($self, $name) = @_;
338  
339 0 $self->_dbh->do("ROLLBACK TO SAVEPOINT $name")
340 }
341  
342 1 ▶sub with_deferred_fk_checks {
Subroutine with_deferred_fk_checks: called CC=1 SCAR=0.0
Pod documented
343 1 my ($self, $sub) = @_;
344  
345 1 my $txn_scope_guard = $self->txn_scope_guard;
346  
347 1 $self->_do_query('SET CONSTRAINTS ALL DEFERRED');
348  
349 # constraint mode ends with the transaction: IMMEDIATE after the COMMIT is
350 # -255 "Not in transaction". Before it, it also runs the deferred checks.
351 1 ▶ return preserve_context { $sub->() } after => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
352 1 $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
353 1 $txn_scope_guard->commit;
354 1 };
355 }
356  
357  
358  
359 1 ▶sub connect_call_datetime_setup {
Subroutine connect_call_datetime_setup: called CC=1 SCAR=0.0
Pod documented
360 1 my $self = shift;
361  
362 1 delete @ENV{qw/DBDATE DBCENTURY/};
363  
364 1 $ENV{GL_DATE} = "%m/%d/%Y";
365 1 $ENV{GL_DATETIME} = "%Y-%m-%d %H:%M:%S.%F5";
366 }
367  
368  
369 package DBIO::Informix::Storage::DateTime::Format;
370  
371 12 ▶use base 'DBIO::Storage::DateTimeFormat';
Subroutine BEGIN: called CC=1 SCAR=0.0
372  
373 # No preferred_format_class: there is no maintained DateTime::Format::Informix.
374 12 __PACKAGE__->datetime_parse_pattern('%Y-%m-%d %H:%M:%S.%5N'); # %F %T
375 12 __PACKAGE__->datetime_format_pattern('%Y-%m-%d %H:%M:%S.%5N');
376 12 __PACKAGE__->date_parse_pattern('%m/%d/%Y');
377 12 __PACKAGE__->date_format_pattern('%m/%d/%Y');
378  
379 12 1;
380  
381 __END__
« Informix/Test/Conformance.pm ↑ Summary Informix/DDL.pm »