| 1 | package DBIO::DB2::Diff::Column; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Diff operations for DB2 columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 47 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 47 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 47 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 47 | ▶ | use base 'DBIO::Diff::Op'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 47 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 47 | ▶ | use DBIO::DB2::Type qw(_db2_column_type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 47 | ▶ | use DBIO::DB2::DDL qw(_db2_quote_ident _db2_quote_table); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 47 | ▶ | use DBIO::Diff::Compare qw(changed_fields column_change_lossy); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 47 | __PACKAGE__->mk_diff_accessors(qw/table_name column_name old_info new_info/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 190 | ▶ | sub diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diff: called CC=18 SCAR=29.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 190 | my ($class, $source_cols, $target_cols, $source_tables, $target_tables) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 190 | my @ops; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 190 | for my $table_name (sort keys %$target_cols) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | next unless exists $source_tables->{$table_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 224 | ▶ | && exists $target_tables->{$table_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $source_tables->{$table_name} and exists $target_tables->{$table_name}
MC/DC50%1/2
exists $source_tables->{$table_name} and exists $target_tables->{$table_name}
exists $source_tables->{$table_name}
exists $target_tables->{$table_name}
Truth table66%2/3
A and B
A= exists $source_tables->{$table_name}B= exists $target_tables->{$table_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # A view has no columns to ALTER: DBIO::DB2::Diff::View creates and drops | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # it, and its columns follow its definition (karr k45, ADR 0011). kind may | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # be marked on either side; a missing kind is 'table'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | next if ($target_tables->{$table_name}{kind} // 'table') eq 'view' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 206 | ▶ | || ($source_tables->{$table_name}{kind} // 'table') eq 'view'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition85%6/7
($target_tables->{$table_name}{"kind"} // "table") eq "view" or ($source_tables->{$table_name}{"kind"} // "table") eq "view"
$target_tables->{$table_name}{"kind"} // "table"
$source_tables->{$table_name}{"kind"} // "table"
MC/DC50%1/2
($target_tables->{$table_name}{"kind"} // "table") eq "view" or ($source_tables->{$table_name}{"kind"} // "table") eq "view"
$target_tables->{$table_name}{"kind"}
$source_tables->{$table_name}{"kind"}
Truth table66%2/3
A or B
A= $target_tables->{$table_name}{"kind"}B= $source_tables->{$table_name}{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 190 | ▶ | my %src_by_name = map { $_->{column_name} => $_ } @{ $source_cols->{$table_name} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$source_cols->{$table_name} // []
MC/DC0%0/1
$source_cols->{$table_name} // []
$source_cols->{$table_name}
Truth table50%1/2
A
A= $source_cols->{$table_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 190 | ▶ | my %tgt_by_name = map { $_->{column_name} => $_ } @{ $target_cols->{$table_name} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$target_cols->{$table_name} // []
MC/DC0%0/1
$target_cols->{$table_name} // []
$target_cols->{$table_name}
Truth table50%1/2
A
A= $target_cols->{$table_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 190 | my @table_ops; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 190 | for my $col_name (sort keys %tgt_by_name) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 305 | my $tgt = $tgt_by_name{$col_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 305 | ▶ | if (!exists $src_by_name{$col_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 53 | _check_identity($table_name, $col_name, undef, $tgt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 49 | push @table_ops, $class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | action => 'add', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | table_name => $table_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | column_name => $col_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | new_info => $tgt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 49 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 252 | my $src = $src_by_name{$col_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | my $identity_changed = ($src->{is_auto_increment} ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 252 | ▶ | != ($tgt->{is_auto_increment} ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 252 | ▶ | if ($identity_changed || scalar _changed_catalog_fields($src, $tgt)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$identity_changed or scalar _changed_catalog_fields($src, $tgt)
MC/DC100%1/1
$identity_changed or scalar _changed_catalog_fields($src, $tgt)
$identity_changed
Truth table100%2/2
A
A= $identity_changed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 93 | _check_identity($table_name, $col_name, $src, $tgt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 82 | push @table_ops, $class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | action => 'alter', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | table_name => $table_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | column_name => $col_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | old_info => $src, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | new_info => $tgt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 175 | for my $col_name (sort keys %src_by_name) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 246 | ▶ | next if exists $tgt_by_name{$col_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | push @table_ops, $class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | action => 'drop', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | table_name => $table_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | column_name => $col_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 12 | old_info => $src_by_name{$col_name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # A table has one identity column (SQL0372N): whatever lets go of its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # identity goes first, or the SET GENERATED of another column fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 143 | push @ops, (grep { $_->_releases_identity } @table_ops), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 175 | (grep { !$_->_releases_identity } @table_ops); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 175 | return @ops; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # The comparison core's changed_column_fields, on the catalog fields: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # models hold the normalized column for the generator and the catalog's own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # TYPENAME, LENGTH and DEFAULT for this diff (ADR 0013). Same rules as there: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # a field the target leaves undef is not compared. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 225 | ▶ | sub _changed_catalog_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_changed_catalog_fields: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 225 | my ($old, $new) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 225 | my @changed = changed_fields($old, $new, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | type => ['catalog_type'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | scalar => ['not_null', 'catalog_default'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | dim => ['catalog_size'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # A default the target no longer declares is a change, as core's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # changed_column_fields has it since karr k367: the live column carries one (a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # live DEFAULT NULL is none), the target leaves it undef. The pass above skips | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # a field the target leaves undef, so the removal would never be written | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # (conformance case diff-default-removed, karr k57). Placed after not_null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # where the scalar pass puts catalog_default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 225 | ▶ | if (!defined $new->{catalog_default} && defined $old->{catalog_default} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
not defined $new->{"catalog_default"} and defined $old->{"catalog_default"} and uc $old->{"catalog_default"} ne "NULL" and not grep({$_ eq "catalog_default";} @changed)
not defined $new->{"catalog_default"} and defined $old->{"catalog_default"} and uc $old->{"catalog_default"} ne "NULL"
not defined $new->{"catalog_default"} and defined $old->{"catalog_default"}
MC/DC75%3/4
not defined $new->{"catalog_default"} and defined $old->{"catalog_default"} and uc $old->{"catalog_default"} ne "NULL" and not grep({$_ eq "catalog_default";} @changed)
not defined $new->{"catalog_default"}
defined $old->{"catalog_default"}
uc $old->{"catalog_default"} ne "NULL"
not grep({$_ eq "catalog_default";} @changed)
Truth table80%4/5
not(A) and B and C and not(D)
A= not defined $new->{"catalog_default"}B= defined $old->{"catalog_default"}C= uc $old->{"catalog_default"} ne "NULL"D= not grep({$_ eq "catalog_default";} @changed)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | && uc($old->{catalog_default}) ne 'NULL' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | && !grep { $_ eq 'catalog_default' } @changed) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my ($at) = grep { $changed[$_] eq 'not_null' } 0 .. $#changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | splice @changed, defined $at ? $at + 1 : scalar(@changed), 0, 'catalog_default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 225 | return @changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 47 | my %LOSSLESS_PAIRS = map { ($_ => 1) } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 'smallint->integer', 'smallint->bigint', 'integer->bigint', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 42 | ▶ | sub lossy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lossy: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 42 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 42 | ▶ | return 0 unless $self->action eq 'alter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 20 | my ($old, $new) = ($self->old_info, $self->new_info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | return column_change_lossy( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | { data_type => $old->{catalog_type}, size => $old->{catalog_size} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | { data_type => $new->{catalog_type}, size => $new->{catalog_size} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 20 | ▶ | \%LOSSLESS_PAIRS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 29 | ▶ | sub adds_identity { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adds_identity: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 29 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 29 | ▶ | return ($self->action eq 'add' && $self->new_info->{is_auto_increment}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->action eq "add" and $self->new_info->{"is_auto_increment"}
MC/DC100%2/2
$self->action eq "add" and $self->new_info->{"is_auto_increment"}
$self->action eq "add"
$self->new_info->{"is_auto_increment"}
Truth table100%3/3
A and B
A= $self->action eq "add"B= $self->new_info->{"is_auto_increment"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 20 | ▶ | sub adds_not_null_without_default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adds_not_null_without_default: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 20 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 20 | ▶ | return 0 unless $self->action eq 'add'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 14 | my $info = $self->new_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 14 | ▶ | return 0 if $info->{is_auto_increment} || !$info->{not_null}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$info->{"is_auto_increment"} or not $info->{"not_null"}
MC/DC100%2/2
$info->{"is_auto_increment"} or not $info->{"not_null"}
$info->{"is_auto_increment"}
not $info->{"not_null"}
Truth table100%3/3
A or not(B)
A= $info->{"is_auto_increment"}B= not $info->{"not_null"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | my $default = $info->{catalog_default}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 7 | ▶ | return (defined $default && uc($default) ne 'NULL') ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $default and uc $default ne "NULL"
MC/DC100%2/2
defined $default and uc $default ne "NULL"
defined $default
uc $default ne "NULL"
Truth table100%3/3
A and B
A= defined $defaultB= uc $default ne "NULL"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 17 | ▶ | sub sets_not_null { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sets_not_null: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | return ($self->action eq 'alter' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 17 | ▶ | && !($self->old_info->{not_null} // 0) && ($self->new_info->{not_null} // 0)) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition70%7/10
$self->action eq "alter" and not $self->old_info->{"not_null"} // 0 and $self->new_info->{"not_null"} // 0
$self->action eq "alter" and not $self->old_info->{"not_null"} // 0
$self->old_info->{"not_null"} // 0
$self->new_info->{"not_null"} // 0
MC/DC0%0/3
$self->action eq "alter" and not $self->old_info->{"not_null"} // 0 and $self->new_info->{"not_null"} // 0
$self->action eq "alter"
$self->old_info->{"not_null"}
$self->new_info->{"not_null"}
Truth table50%2/4
A and not(B) and C
A= $self->action eq "alter"B= $self->old_info->{"not_null"}C= $self->new_info->{"not_null"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 286 | ▶ | sub _releases_identity { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_releases_identity: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 286 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 286 | ▶ | my $old = $self->old_info or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 188 | ▶ | return 0 unless $old->{is_auto_increment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 14 | ▶ | return 1 if $self->action eq 'drop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 12 | ▶ | return $self->new_info->{is_auto_increment} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # The identity cases the server refuses (ADR 0012), refused here with table and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # column named instead of SQL0846N / SQL0270N from the middle of an upgrade. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # $old is undef for an added column. Nothing to check when the column is no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # identity afterwards. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 146 | ▶ | sub _check_identity { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_identity: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 146 | my ($table, $column, $old, $new) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 146 | ▶ | return unless $new->{is_auto_increment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 44 | my $where = "table $table, column $column"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 44 | my $type = _db2_column_type($new->{catalog_type}, $new->{catalog_size}, $column); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 44 | ▶ | Carp::croak("Cannot make an identity column ($where): Db2 takes an identity only over " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type =~ /\A(?:SMALLINT|INTEGER|BIGINT)\z/ or $type =~ /\A(?:DECIMAL|NUMERIC)(?:\(\s*\d+\s*(?:,\s*0\s*)?\))?\z/
MC/DC100%2/2
$type =~ /\A(?:SMALLINT|INTEGER|BIGINT)\z/ or $type =~ /\A(?:DECIMAL|NUMERIC)(?:\(\s*\d+\s*(?:,\s*0\s*)?\))?\z/
$type =~ /\A(?:SMALLINT|INTEGER|BIGINT)\z/
$type =~ /\A(?:DECIMAL|NUMERIC)(?:\(\s*\d+\s*(?:,\s*0\s*)?\))?\z/
Truth table100%3/3
A or B
A= $type =~ /\A(?:SMALLINT|INTEGER|BIGINT)\z/B= $type =~ /\A(?:DECIMAL|NUMERIC)(?:\(\s*\d+\s*(?:,\s*0\s*)?\))?\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | . "SMALLINT, INTEGER, BIGINT or a DECIMAL without scale, not $type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | unless $type =~ /\A(?:SMALLINT|INTEGER|BIGINT)\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | || $type =~ /\A(?:DECIMAL|NUMERIC)(?:\(\s*\d+\s*(?:,\s*0\s*)?\))?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | Carp::croak("Cannot make an identity column ($where): an identity column must be NOT NULL") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 32 | ▶ | unless $new->{not_null}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 31 | ▶ | if ($old && $old->{is_auto_increment} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$old and $old->{"is_auto_increment"} and $type ne _db2_column_type($old->{"catalog_type"}, $old->{"catalog_size"}, $column)
$old and $old->{"is_auto_increment"}
MC/DC66%2/3
$old and $old->{"is_auto_increment"} and $type ne _db2_column_type($old->{"catalog_type"}, $old->{"catalog_size"}, $column)
$old
$old->{"is_auto_increment"}
$type ne _db2_column_type($old->{"catalog_type"}, $old->{"catalog_size"}, $column)
Truth table75%3/4
A and B and C
A= $oldB= $old->{"is_auto_increment"}C= $type ne _db2_column_type($old->{"catalog_type"}, $old->{"catalog_size"}, $column)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | && $type ne _db2_column_type($old->{catalog_type}, $old->{catalog_size}, $column)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | Carp::croak("Cannot change the type of an identity column ($where) to $type: " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | . "Db2 refuses SET DATA TYPE on an identity column (SQL0270N)"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 29 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 81 | ▶ | sub as_sql { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_sql: called CC=21 SCAR=30.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 81 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 81 | my $tbl = _db2_quote_table($self->table_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 81 | my $col = _db2_quote_ident($self->column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 81 | ▶ | if ($self->action eq 'add') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 39 | my $info = $self->new_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 39 | my $type = _db2_column_type($info->{catalog_type}, $info->{catalog_size}, $self->column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 39 | my $sql = sprintf 'ALTER TABLE %s ADD COLUMN %s %s', $tbl, $col, $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 39 | ▶ | $sql .= ' NOT NULL' if $info->{not_null}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 39 | ▶ | if ($info->{is_auto_increment}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # The only form the server takes (ADR 0012); existing rows stay at 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 10 | return join "\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | "$sql DEFAULT 0;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | sprintf('ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT;', $tbl, $col), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | sprintf('ALTER TABLE %s ALTER COLUMN %s SET GENERATED ALWAYS AS IDENTITY;', $tbl, $col); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 29 | ▶ | if (defined $info->{catalog_default}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # As it is -- the catalog's DEFAULT is SQL text already (see DESCRIPTION). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 16 | $sql .= ' DEFAULT ' . $info->{catalog_default}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 29 | return "$sql;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 42 | ▶ | if ($self->action eq 'drop') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 8 | return sprintf 'ALTER TABLE %s DROP COLUMN %s;', $tbl, $col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 34 | ▶ | if ($self->action eq 'alter') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 34 | my $old = $self->old_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 34 | my $new = $self->new_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 34 | my @stmts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # An identity is let go of before anything else, and taken after the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # NOT NULL and the missing default it needs (ADR 0012). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | push @stmts, sprintf 'ALTER TABLE %s ALTER COLUMN %s DROP IDENTITY;', $tbl, $col | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 34 | ▶ | if $old->{is_auto_increment} && !$new->{is_auto_increment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$old->{"is_auto_increment"} and not $new->{"is_auto_increment"}
MC/DC50%1/2
$old->{"is_auto_increment"} and not $new->{"is_auto_increment"}
$old->{"is_auto_increment"}
not $new->{"is_auto_increment"}
Truth table66%2/3
A and not(B)
A= $old->{"is_auto_increment"}B= not $new->{"is_auto_increment"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 34 | ▶ | if (_db2_column_type($old->{catalog_type}, $old->{catalog_size}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ne _db2_column_type($new->{catalog_type}, $new->{catalog_size})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | push @stmts, sprintf 'ALTER TABLE %s ALTER COLUMN %s SET DATA TYPE %s;', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 8 | $tbl, $col, _db2_column_type($new->{catalog_type}, $new->{catalog_size}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 34 | ▶ | if (($old->{not_null} // 0) != ($new->{not_null} // 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%4/4
$old->{"not_null"} // 0
$new->{"not_null"} // 0
MC/DC100%1/1
$old->{"not_null"} // 0
$old->{"not_null"}
MC/DC100%1/1
$new->{"not_null"} // 0
$new->{"not_null"}
Truth table100%2/2
A
A= $old->{"not_null"}
Truth table100%2/2
A
A= $new->{"not_null"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | push @stmts, $new->{not_null} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 9 | ▶ | ? sprintf('ALTER TABLE %s ALTER COLUMN %s SET NOT NULL;', $tbl, $col) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | : sprintf('ALTER TABLE %s ALTER COLUMN %s DROP NOT NULL;', $tbl, $col); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 34 | ▶ | my $old_d = defined $old->{catalog_default} ? $old->{catalog_default} : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | my $new_d = defined $new->{catalog_default} && !$new->{is_auto_increment} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 34 | ▶ | ? $new->{catalog_default} : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $new->{"catalog_default"} and not $new->{"is_auto_increment"}
MC/DC50%1/2
defined $new->{"catalog_default"} and not $new->{"is_auto_increment"}
defined $new->{"catalog_default"}
not $new->{"is_auto_increment"}
Truth table66%2/3
A and not(B)
A= defined $new->{"catalog_default"}B= not $new->{"is_auto_increment"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 34 | ▶ | if ($old_d ne $new_d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 16 | ▶ | push @stmts, length $new_d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ? sprintf('ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s;', $tbl, $col, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $new_d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | : sprintf('ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT;', $tbl, $col); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | push @stmts, sprintf 'ALTER TABLE %s ALTER COLUMN %s SET GENERATED ALWAYS AS IDENTITY;', $tbl, $col | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 34 | ▶ | if $new->{is_auto_increment} && !$old->{is_auto_increment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$new->{"is_auto_increment"} and not $old->{"is_auto_increment"}
MC/DC50%1/2
$new->{"is_auto_increment"} and not $old->{"is_auto_increment"}
$new->{"is_auto_increment"}
not $old->{"is_auto_increment"}
Truth table66%2/3
A and not(B)
A= $new->{"is_auto_increment"}B= not $old->{"is_auto_increment"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 34 | return join "\n", @stmts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # The types within which SET DATA TYPE to another length is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # reorg-recommended, by the name _db2_column_type renders -- which is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # catalog's TYPENAME for all three. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 47 | my %LENGTH_CHANGE_WITHOUT_REORG = map { $_ => 1 } qw(VARCHAR VARGRAPHIC VARBINARY); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 140 | ▶ | sub reorg_recommended { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reorg_recommended: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 140 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 140 | ▶ | return 1 if $self->action eq 'drop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 128 | ▶ | return 0 unless $self->action eq 'alter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 94 | my $old = $self->old_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 94 | my $new = $self->new_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 94 | ▶ | return 1 if ($old->{not_null} // 0) != ($new->{not_null} // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$old->{"not_null"} // 0
$new->{"not_null"} // 0
MC/DC0%0/1
$old->{"not_null"} // 0
$old->{"not_null"}
MC/DC0%0/1
$new->{"not_null"} // 0
$new->{"not_null"}
Truth table50%1/2
A
A= $old->{"not_null"}
Truth table50%1/2
A
A= $new->{"not_null"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 79 | my $old_type = _db2_column_type($old->{catalog_type}, $old->{catalog_size}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 79 | my $new_type = _db2_column_type($new->{catalog_type}, $new->{catalog_size}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 79 | ▶ | return 0 if $old_type eq $new_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 60 | (my $old_name = $old_type) =~ s/\(.*\)\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 60 | (my $new_name = $new_type) =~ s/\(.*\)\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 60 | ▶ | return 0 if $old_name eq $new_name && $LENGTH_CHANGE_WITHOUT_REORG{$new_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$old_name eq $new_name and $LENGTH_CHANGE_WITHOUT_REORG{$new_name}
MC/DC100%2/2
$old_name eq $new_name and $LENGTH_CHANGE_WITHOUT_REORG{$new_name}
$old_name eq $new_name
$LENGTH_CHANGE_WITHOUT_REORG{$new_name}
Truth table100%3/3
A and B
A= $old_name eq $new_nameB= $LENGTH_CHANGE_WITHOUT_REORG{$new_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 46 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 14 | ▶ | sub summary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
summary: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 14 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 14 | ▶ | my $type = $self->new_info ? " ($self->{new_info}{catalog_type})" : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 14 | return sprintf ' %scolumn: %s.%s%s', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | $self->summary_prefix, $self->table_name, $self->column_name, $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 47 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||