| 1 | package DBIO::Informix::Test::Conformance; | ||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Answers the shared conformance case table for the Informix driver | ||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 4 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use base 'DBIO::Test::Conformance'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use DBI (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use DBIO::Exception (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use DBIO::Informix::Util (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use DBIO::Informix::Deploy (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use DBIO::Informix::Introspect (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub conformance_live_available { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_live_available: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | return 0 unless length($ENV{DBIO_TEST_INFORMIX_DSN} // ''); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$ENV{"DBIO_TEST_INFORMIX_DSN"} // ""
MC/DC0%0/1
$ENV{"DBIO_TEST_INFORMIX_DSN"} // ""
$ENV{"DBIO_TEST_INFORMIX_DSN"}
Truth table0%0/2
A
A= $ENV{"DBIO_TEST_INFORMIX_DSN"}
| |||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return eval { require DBD::Informix; 1 } ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 4 | my @CONNECT = qw(DBIO_TEST_INFORMIX_DSN DBIO_TEST_INFORMIX_USER DBIO_TEST_INFORMIX_PASS); | |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub conformance_connect { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_connect: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($class, $schema_class) = @_; | |||||||||||||||||||||||||||||||||
| 29 | 0 | $schema_class->load_components('Informix'); | |||||||||||||||||||||||||||||||||
| 30 | return $schema_class->connect( | ||||||||||||||||||||||||||||||||||
| 31 | 0 | @ENV{@CONNECT}, | |||||||||||||||||||||||||||||||||
| 32 | { RaiseError => 1, PrintError => 0, PrintWarn => 0, AutoCommit => 1 }, | ||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | # A connection of the conformance run's own, apart from the case's. | ||||||||||||||||||||||||||||||||||
| 37 | # DELIMIDENT is set for the connect: names are quoted like the storage does. | ||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub _own_dbh { | ||||||||||||||||||||||||||||||||
|
Subroutine
_own_dbh: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 39 | 0 | local $ENV{DELIMIDENT} = 'y'; | |||||||||||||||||||||||||||||||||
| 40 | return DBI->connect( | ||||||||||||||||||||||||||||||||||
| 41 | 0 | @ENV{@CONNECT}, | |||||||||||||||||||||||||||||||||
| 42 | { RaiseError => 1, PrintError => 0, PrintWarn => 0, AutoCommit => 1 }, | ||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub _trim { my ($s) = @_; $s =~ s/\s+\z// if defined $s; return $s } | ||||||||||||||||||||||||||||||||
|
Subroutine
_trim: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | # [ [ name, 'TABLE' | 'VIEW' ], ... ] of the user tables and views | ||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub _relations { | ||||||||||||||||||||||||||||||||
|
Subroutine
_relations: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 50 | 0 | my ($dbh) = @_; | |||||||||||||||||||||||||||||||||
| 51 | 0 | my $rows = $dbh->selectall_arrayref( | |||||||||||||||||||||||||||||||||
| 52 | q{SELECT TRIM(tabname), tabtype FROM systables WHERE tabid >= 100 AND tabtype IN ('T', 'V')}); | ||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | return [ map { [ $_->[0], $_->[1] eq 'V' ? 'VIEW' : 'TABLE' ] } @$rows ]; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub conformance_namespace { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_namespace: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 58 | 0 | my ($class, $schema, $case) = @_; | |||||||||||||||||||||||||||||||||
| 59 | 0 | my $dbh = _own_dbh(); | |||||||||||||||||||||||||||||||||
| 60 | 0 | my $there = eval { _relations($dbh) }; | |||||||||||||||||||||||||||||||||
| 61 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||
| 62 | 0 | $dbh->disconnect; | |||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | DBIO::Exception->throw("conformance: cannot look at the database: $err") if $err; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 64 | DBIO::Exception->throw('conformance: the database holds ' | ||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | . join(', ', map { "$_->[1] $_->[0]" } @$there) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 66 | . ' already; a case needs an empty database and it is not the run\'s to drop them') | ||||||||||||||||||||||||||||||||||
| 67 | if @$there; | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 0 | my (%tables, %views); | |||||||||||||||||||||||||||||||||
| 70 | 0 | for my $source_name ($schema->sources) { | |||||||||||||||||||||||||||||||||
| 71 | 0 | my $source = $schema->source($source_name); | |||||||||||||||||||||||||||||||||
| 72 | 0 | my $name = $source->name; | |||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | next if ref $name; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($source->isa('DBIO::ResultSource::View')) { $views{$name} = 1 } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 75 | 0 | else { $tables{$name} = 1 } | |||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||
| 77 | # A Diff case upgrades to a second declaration, whose sources create more | ||||||||||||||||||||||||||||||||||
| 78 | # objects: the cleanup has to find them as well. | ||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | for my $spec (@{ $case->{input}{to}{sources} || [] }) { | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$case->{'input'}{'to'}{'sources'} || []
MC/DC0%0/1
$case->{'input'}{'to'}{'sources'} || []
$case->{'input'}{'to'}{'sources'}
Truth table0%0/2
A
A= $case->{'input'}{'to'}{'sources'}
| |||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | next if !defined $spec->{table} or ref $spec->{table}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $spec->{"table"} or ref $spec->{"table"}
MC/DC0%0/2
not defined $spec->{"table"} or ref $spec->{"table"}
not defined $spec->{"table"}
ref $spec->{"table"}
Truth table0%0/3
not(A) or B
A= not defined $spec->{"table"}B= ref $spec->{"table"}
| |||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($spec->{view}) { $views{ $spec->{table} } = 1 } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 82 | 0 | else { $tables{ $spec->{table} } = 1 } | |||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | 0 | return { tables => [ sort keys %tables ], views => [ sort keys %views ] }; | |||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub conformance_install { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_install: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 89 | 0 | my ($class, $schema, $case) = @_; | |||||||||||||||||||||||||||||||||
| 90 | 0 | $schema->deploy; | |||||||||||||||||||||||||||||||||
| 91 | 0 | return; | |||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub conformance_cleanup { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_cleanup: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 96 | 0 | my ($class, $schema, $case, $namespace) = @_; | |||||||||||||||||||||||||||||||||
| 97 | 0 | eval { $schema->storage->disconnect }; | |||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | return unless ref $namespace eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my %want_table = map { $_ => 1 } @{ $namespace->{tables} || [] }; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$namespace->{'tables'} || []
MC/DC0%0/1
$namespace->{'tables'} || []
$namespace->{'tables'}
Truth table0%0/2
A
A= $namespace->{'tables'}
| |||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my %want_view = map { $_ => 1 } @{ $namespace->{views} || [] }; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$namespace->{'views'} || []
MC/DC0%0/1
$namespace->{'views'} || []
$namespace->{'views'}
Truth table0%0/2
A
A= $namespace->{'views'}
| |||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return unless %want_table or %want_view; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
%want_table or %want_view
MC/DC0%0/2
%want_table or %want_view
%want_table
%want_view
Truth table0%0/3
A or B
A= %want_tableB= %want_view
| |||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | my $q = sub { DBIO::Informix::Util::_quote_ident($_[0]) }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 105 | 0 | my $dbh = _own_dbh(); | |||||||||||||||||||||||||||||||||
| 106 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||
| 107 | 0 | my @rel = @{ _relations($dbh) }; | |||||||||||||||||||||||||||||||||
| 108 | # by the name of the mark, whatever kind of object the case left there | ||||||||||||||||||||||||||||||||||
| 109 | # (a driver that builds a view as a table is a finding of the case, not | ||||||||||||||||||||||||||||||||||
| 110 | # of the cleanup) | ||||||||||||||||||||||||||||||||||
| 111 | 0 | my %want = (%want_table, %want_view); | |||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my @views = grep { $_->[1] eq 'VIEW' and $want{ $_->[0] } } @rel; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_->[1] eq 'VIEW' && $want{$_->[0]}
MC/DC0%0/2
$_->[1] eq 'VIEW' && $want{$_->[0]}
$_->[1] eq 'VIEW'
$want{$_->[0]}
Truth table0%0/3
A && B
A= $_->[1] eq 'VIEW'B= $want{$_->[0]}
| |||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my @tables = grep { $_->[1] eq 'TABLE' and $want{ $_->[0] } } @rel; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_->[1] eq 'TABLE' && $want{$_->[0]}
MC/DC0%0/2
$_->[1] eq 'TABLE' && $want{$_->[0]}
$_->[1] eq 'TABLE'
$want{$_->[0]}
Truth table0%0/3
A && B
A= $_->[1] eq 'TABLE'B= $want{$_->[0]}
| |||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||
| 115 | 0 | my $fks = $dbh->selectall_arrayref(q{ | |||||||||||||||||||||||||||||||||
| 116 | SELECT TRIM(t.tabname), TRIM(c.constrname) | ||||||||||||||||||||||||||||||||||
| 117 | FROM sysconstraints c JOIN systables t ON t.tabid = c.tabid | ||||||||||||||||||||||||||||||||||
| 118 | WHERE c.constrtype = 'R' | ||||||||||||||||||||||||||||||||||
| 119 | }); | ||||||||||||||||||||||||||||||||||
| 120 | 0 | for my $fk (@$fks) { | |||||||||||||||||||||||||||||||||
| 121 | 0 | my ($table, $constraint) = @$fk; | |||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | next unless $want_table{$table} or $want_view{$table}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$want_table{$table} or $want_view{$table}
MC/DC0%0/2
$want_table{$table} or $want_view{$table}
$want_table{$table}
$want_view{$table}
Truth table0%0/3
A or B
A= $want_table{$table}B= $want_view{$table}
| |||||||||||||||||||||||||||||||||||
| 123 | 0 | $dbh->do(sprintf 'ALTER TABLE %s DROP CONSTRAINT %s', $q->($table), $q->($constraint)); | |||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||
| 125 | 0 | $dbh->do('DROP VIEW ' . $q->($_->[0])) for @views; | |||||||||||||||||||||||||||||||||
| 126 | 0 | $dbh->do('DROP TABLE ' . $q->($_->[0])) for @tables; | |||||||||||||||||||||||||||||||||
| 127 | 0 | 1; | |||||||||||||||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||||||||||||||
| 129 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||
| 130 | 0 | $dbh->disconnect; | |||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | DBIO::Exception->throw("conformance: cleanup failed: $err") unless $ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 132 | 0 | return; | |||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub conformance_diff_is_empty { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_diff_is_empty: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 137 | 0 | my ($class, $schema, $case) = @_; | |||||||||||||||||||||||||||||||||
| 138 | 0 | my $diff = DBIO::Informix::Deploy->new(schema => $schema)->diff; | |||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | return $diff->has_changes ? 0 : 1; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub conformance_upgrade { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_upgrade: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 144 | 0 | my ($class, $schema, $to_class, $case) = @_; | |||||||||||||||||||||||||||||||||
| 145 | # The case's own connection holds locks on its tables; the DDL of the | ||||||||||||||||||||||||||||||||||
| 146 | # upgrade and the DROP TABLE of the cleanup (each on a connection of their | ||||||||||||||||||||||||||||||||||
| 147 | # own) would wait for them. Nothing reads through the old schema once the | ||||||||||||||||||||||||||||||||||
| 148 | # upgrade starts. | ||||||||||||||||||||||||||||||||||
| 149 | 0 | eval { $schema->storage->disconnect }; | |||||||||||||||||||||||||||||||||
| 150 | 0 | my $to = $class->conformance_connect($to_class); | |||||||||||||||||||||||||||||||||
| 151 | 0 | DBIO::Informix::Deploy->new(schema => $to)->upgrade(allow_destructive => 1); | |||||||||||||||||||||||||||||||||
| 152 | 0 | return $to; | |||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub conformance_deploy { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_deploy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 157 | 0 | my ($class, $schema, $to_class, $case) = @_; | |||||||||||||||||||||||||||||||||
| 158 | 0 | eval { $schema->storage->disconnect }; | |||||||||||||||||||||||||||||||||
| 159 | 0 | my $to = $class->conformance_connect($to_class); | |||||||||||||||||||||||||||||||||
| 160 | 0 | return DBIO::Informix::Deploy->new(schema => $to); | |||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | 6 | ▶ | sub conformance_answered_through { { DDL => 2, Diff => 4, Bind => 1 } } | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_answered_through: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||
| 167 | 6 | ▶ | sub conformance_refusals { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_refusals: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 168 | return { | ||||||||||||||||||||||||||||||||||
| 169 | 6 | 'diff-column-added-not-null-populated' => { | |||||||||||||||||||||||||||||||||
| 170 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 171 | reason => qr/added NOT NULL without a default, and the table holds rows/, | ||||||||||||||||||||||||||||||||||
| 172 | }, | ||||||||||||||||||||||||||||||||||
| 173 | 'diff-not-null-over-nulls' => { | ||||||||||||||||||||||||||||||||||
| 174 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 175 | reason => qr/becomes NOT NULL, and the table holds rows where it is NULL/, | ||||||||||||||||||||||||||||||||||
| 176 | }, | ||||||||||||||||||||||||||||||||||
| 177 | 'bind-long-string' => { | ||||||||||||||||||||||||||||||||||
| 178 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 179 | reason => qr/Informix allows no TEXT or BYTE in a comparison/, | ||||||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||||
| 181 | 'bind-non-ascii' => { | ||||||||||||||||||||||||||||||||||
| 182 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 183 | reason => qr/Informix allows no TEXT or BYTE in a comparison/, | ||||||||||||||||||||||||||||||||||
| 184 | }, | ||||||||||||||||||||||||||||||||||
| 185 | 'bind-binary' => { | ||||||||||||||||||||||||||||||||||
| 186 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 187 | reason => qr/Informix allows no TEXT or BYTE in a comparison/, | ||||||||||||||||||||||||||||||||||
| 188 | }, | ||||||||||||||||||||||||||||||||||
| 189 | 'bind-lob-row-operations' => { | ||||||||||||||||||||||||||||||||||
| 190 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 191 | reason => qr/Informix allows no TEXT or BYTE in a comparison/, | ||||||||||||||||||||||||||||||||||
| 192 | }, | ||||||||||||||||||||||||||||||||||
| 193 | 'bind-lob-empty-and-large' => { | ||||||||||||||||||||||||||||||||||
| 194 | kind => 'deviation', | ||||||||||||||||||||||||||||||||||
| 195 | fact => qr/Lob\.t create: expected '', read back NULL.*Lob\.b create: expected '', read back NULL/s, | ||||||||||||||||||||||||||||||||||
| 196 | reason => 'Informix stores an empty TEXT or BYTE as NULL (a zero-length large object is not a value there; an empty LVARCHAR or CHAR is kept as it is); the large values of the case round-trip', | ||||||||||||||||||||||||||||||||||
| 197 | }, | ||||||||||||||||||||||||||||||||||
| 198 | 'ddl-type-size-bit' => { | ||||||||||||||||||||||||||||||||||
| 199 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 200 | reason => qr/no type for a bit string of a fixed width/, | ||||||||||||||||||||||||||||||||||
| 201 | }, | ||||||||||||||||||||||||||||||||||
| 202 | 'ddl-enum-value-apostrophe' => { | ||||||||||||||||||||||||||||||||||
| 203 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 204 | reason => qr/no enumerated type/, | ||||||||||||||||||||||||||||||||||
| 205 | }, | ||||||||||||||||||||||||||||||||||
| 206 | 'ddl-index-on-unique-columns' => { | ||||||||||||||||||||||||||||||||||
| 207 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 208 | reason => qr/Informix holds only one index there \(-350\)/, | ||||||||||||||||||||||||||||||||||
| 209 | }, | ||||||||||||||||||||||||||||||||||
| 210 | 'ddl-qualified-source-name' => { | ||||||||||||||||||||||||||||||||||
| 211 | kind => 'server', | ||||||||||||||||||||||||||||||||||
| 212 | reason => qr/Informix has no schemas/, | ||||||||||||||||||||||||||||||||||
| 213 | }, | ||||||||||||||||||||||||||||||||||
| 214 | 'ddl-type-size-char' => { | ||||||||||||||||||||||||||||||||||
| 215 | kind => 'deviation', | ||||||||||||||||||||||||||||||||||
| 216 | fact => qr/Sized: the server accepted a row it must reject/, | ||||||||||||||||||||||||||||||||||
| 217 | reason => 'Informix cuts a CHAR(n) or VARCHAR(n) value that is longer than n silently to n characters (measured on 15.0.1, no error and no warning in a logged database); the size is kept (column_size 10) and the driver does not check lengths itself', | ||||||||||||||||||||||||||||||||||
| 218 | }, | ||||||||||||||||||||||||||||||||||
| 219 | 'ddl-default-digit-string' => { | ||||||||||||||||||||||||||||||||||
| 220 | kind => 'deviation', | ||||||||||||||||||||||||||||||||||
| 221 | fact => qr/expected '007', read back '007 '/, | ||||||||||||||||||||||||||||||||||
| 222 | reason => 'Informix pads a CHAR(n) value with blanks to its length; that is the type\'s definition and the driver does not trim', | ||||||||||||||||||||||||||||||||||
| 223 | }, | ||||||||||||||||||||||||||||||||||
| 224 | }; | ||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub conformance_fact { | ||||||||||||||||||||||||||||||||
|
Subroutine
conformance_fact: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 229 | 0 | my ($class, $schema, $name, $args) = @_; | |||||||||||||||||||||||||||||||||
| 230 | 0 | my $table = $args->{table}; | |||||||||||||||||||||||||||||||||
| 231 | 0 | my $dbh = $schema->storage->dbh; | |||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||
| 233 | # Informix has no schemas: no table is in any namespace but the database's | ||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | return 0 if $name eq 'table_in_namespace'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||
| 236 | 0 | my $model = DBIO::Informix::Introspect->new(dbh => $dbh)->model; | |||||||||||||||||||||||||||||||||
| 237 | 0 | my $entry = $model->{tables}{$table}; | |||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | my @cols = @{ $args->{columns} || [] }; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'columns'} || []
MC/DC0%0/1
$args->{'columns'} || []
$args->{'columns'}
Truth table0%0/2
A
A= $args->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my $columns = $model->{columns}{$table} || []; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$model->{'columns'}{$table} || []
MC/DC0%0/1
$model->{'columns'}{$table} || []
$model->{'columns'}{$table}
Truth table0%0/2
A
A= $model->{'columns'}{$table}
| |||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ($name eq 'object_kind') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | return undef unless $entry; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | return $entry->{kind} eq 'view' ? 'view' : 'table'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($name eq 'table_name') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return $entry ? $entry->{table_name} : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($name eq 'column_names') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 249 | 0 | return [ map { $_->{column_name} } @$columns ]; | |||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if ($name eq 'column_size') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 252 | 0 | my ($col) = grep { $_->{column_name} eq $args->{column} } @$columns; | |||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | return undef unless $col; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | return ref $col->{size} ? $col->{size}[0] : $col->{size}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if ($name eq 'column_auto_increment') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 257 | 0 | my ($col) = grep { $_->{column_name} eq $args->{column} } @$columns; | |||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | return $col && $col->{is_auto_increment} ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$col and $col->{"is_auto_increment"}
MC/DC0%0/2
$col and $col->{"is_auto_increment"}
$col
$col->{"is_auto_increment"}
Truth table0%0/3
A and B
A= $colB= $col->{"is_auto_increment"}
| |||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if ($name eq 'primary_key_columns') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 261 | 0 | return [ map { $_->{column_name} } | |||||||||||||||||||||||||||||||||
| 262 | 0 | sort { $a->{pk_position} <=> $b->{pk_position} } | |||||||||||||||||||||||||||||||||
| 263 | 0 | grep { $_->{is_pk} } @$columns ]; | |||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ($name eq 'foreign_key_count') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | return scalar @{ $model->{foreign_keys}{$table} || [] }; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$model->{'foreign_keys'}{$table} || []
MC/DC0%0/1
$model->{'foreign_keys'}{$table} || []
$model->{'foreign_keys'}{$table}
Truth table0%0/2
A
A= $model->{'foreign_keys'}{$table}
| |||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||
| 269 | 0 | my $want = join "\0", @cols; | |||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ($name eq 'unique_exists') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 272 | # a unique constraint (not the primary key) or a unique index over | ||||||||||||||||||||||||||||||||||
| 273 | # exactly these columns | ||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | return (grep { $_->{unique} and $_->{constraint} ne 'P' and join("\0", @{ $_->{columns} }) eq $want } | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$_->{'unique'} && $_->{'constraint'} ne 'P' && join("\000", @{$_->{'columns'};}) eq $want
$_->{"unique"} and $_->{"constraint"} ne "P"
MC/DC0%0/3
$_->{'unique'} && $_->{'constraint'} ne 'P' && join("\000", @{$_->{'columns'};}) eq $want
$_->{"unique"}
$_->{"constraint"} ne "P"
join("\000", @{$_->{'columns'};}) eq $want
Truth table0%0/4
A and B && C
A= $_->{"unique"}B= $_->{"constraint"} ne "P"C= join("\000", @{$_->{'columns'};}) eq $want
| |||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | @{ _indexes($dbh, $table) }) ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ($name eq 'index_count') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 278 | # every index of the table over exactly these columns, the ones behind a | ||||||||||||||||||||||||||||||||||
| 279 | # unique constraint or a foreign key included, the primary key's excluded | ||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | return scalar grep { $_->{constraint} ne 'P' and join("\0", @{ $_->{columns} }) eq $want } | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_->{'constraint'} ne 'P' && join("\000", @{$_->{'columns'};}) eq $want
MC/DC0%0/2
$_->{'constraint'} ne 'P' && join("\000", @{$_->{'columns'};}) eq $want
$_->{'constraint'} ne 'P'
join("\000", @{$_->{'columns'};}) eq $want
Truth table0%0/3
A && B
A= $_->{'constraint'} ne 'P'B= join("\000", @{$_->{'columns'};}) eq $want
| |||||||||||||||||||||||||||||||||||
| 281 | 0 | @{ _indexes($dbh, $table) }; | |||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||
| 284 | 0 | DBIO::Exception->throw("unknown conformance fact '$name'"); | |||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||
| 287 | # Every index of a table straight from sysindexes, with the constraint type | ||||||||||||||||||||||||||||||||||
| 288 | # that owns it ('P', 'U', 'R', or '' for a plain index). | ||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub _indexes { | ||||||||||||||||||||||||||||||||
|
Subroutine
_indexes: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 290 | 0 | my ($dbh, $table) = @_; | |||||||||||||||||||||||||||||||||
| 291 | 0 | my $parts = join ', ', map { "i.part$_" } 1 .. 16; | |||||||||||||||||||||||||||||||||
| 292 | 0 | my $rows = $dbh->selectall_arrayref(qq{ | |||||||||||||||||||||||||||||||||
| 293 | SELECT TRIM(i.idxname), i.idxtype, i.tabid, $parts, | ||||||||||||||||||||||||||||||||||
| 294 | (SELECT MAX(c.constrtype) FROM sysconstraints c | ||||||||||||||||||||||||||||||||||
| 295 | WHERE c.tabid = i.tabid AND c.idxname = i.idxname) | ||||||||||||||||||||||||||||||||||
| 296 | FROM sysindexes i JOIN systables t ON t.tabid = i.tabid | ||||||||||||||||||||||||||||||||||
| 297 | WHERE t.tabname = ? | ||||||||||||||||||||||||||||||||||
| 298 | }, undef, $table); | ||||||||||||||||||||||||||||||||||
| 299 | 0 | my @out; | |||||||||||||||||||||||||||||||||
| 300 | 0 | for my $r (@$rows) { | |||||||||||||||||||||||||||||||||
| 301 | 0 | my ($idx, $type, $tabid, @rest) = @$r; | |||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my $constraint = _trim(pop @rest) // ''; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
_trim(pop @rest) // ""
MC/DC0%0/1
_trim(pop @rest) // ""
_trim(pop @rest)
Truth table0%0/2
A
A= _trim(pop @rest)
| |||||||||||||||||||||||||||||||||||
| 303 | 0 | my @parts = grep { $_ } @rest; | |||||||||||||||||||||||||||||||||
| 304 | 0 | my %name = map { @$_ } @{ $dbh->selectall_arrayref( | |||||||||||||||||||||||||||||||||
| 305 | 'SELECT colno, TRIM(colname) FROM syscolumns WHERE tabid = ?', undef, $tabid) }; | ||||||||||||||||||||||||||||||||||
| 306 | push @out, { | ||||||||||||||||||||||||||||||||||
| 307 | name => $idx, | ||||||||||||||||||||||||||||||||||
| 308 | unique => ($type eq 'U' ? 1 : 0), | ||||||||||||||||||||||||||||||||||
| 309 | constraint => $constraint, | ||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | columns => [ map { $name{ abs $_ } } @parts ], | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 311 | }; | ||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||
| 313 | 0 | return \@out; | |||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | 4 | 1; | |||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||
| 318 | __END__ | ||||||||||||||||||||||||||||||||||