| 1 | package DBIO::Oracle::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Oracle type mapping utilities | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 58 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 58 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 58 | ▶ | use DBIO::Exception (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 58 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 48 | ▶ | sub is_lob_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_lob_type: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 48 | my ($self, $dt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 48 | ▶ | $dt && ($dt =~ /lob|bfile|text|image|bytea|memo/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$dt && ($dt =~ /lob|bfile|text|image|bytea|memo/i || $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary
|varchar|character\s*varying|nvarchar
|national\s*character\s*varying))?\z/xi)
$dt =~ /lob|bfile|text|image|bytea|memo/i or $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary
|varchar|character\s*varying|nvarchar
|national\s*character\s*varying))?\z/xi
MC/DC33%1/3
$dt && ($dt =~ /lob|bfile|text|image|bytea|memo/i || $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary
|varchar|character\s*varying|nvarchar
|national\s*character\s*varying))?\z/xi)
$dt
$dt =~ /lob|bfile|text|image|bytea|memo/i
$dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary
|varchar|character\s*varying|nvarchar
|national\s*character\s*varying))?\z/xi
Truth table50%2/4
A && B or C
A= $dtB= $dt =~ /lob|bfile|text|image|bytea|memo/iC= $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary
|varchar|character\s*varying|nvarchar
|national\s*character\s*varying))?\z/xi
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | || $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |varchar|character\s*varying|nvarchar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |national\s*character\s*varying))?\z/xi); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | sub is_text_lob_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_text_lob_type: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | my ($self, $dt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | $dt && ($dt =~ /^(?:n?clob|memo)\z/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$dt && ($dt =~ /^(?:n?clob|memo)\z/i || $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar
|national\s*character\s*varying))\z/xi)
$dt =~ /^(?:n?clob|memo)\z/i or $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar
|national\s*character\s*varying))\z/xi
MC/DC33%1/3
$dt && ($dt =~ /^(?:n?clob|memo)\z/i || $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar
|national\s*character\s*varying))\z/xi)
$dt
$dt =~ /^(?:n?clob|memo)\z/i
$dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar
|national\s*character\s*varying))\z/xi
Truth table50%2/4
A && B or C
A= $dtB= $dt =~ /^(?:n?clob|memo)\z/iC= $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar
|national\s*character\s*varying))\z/xi
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | || $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |national\s*character\s*varying))\z/xi); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | sub oracle_lob_bind_attrs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oracle_lob_bind_attrs: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | my ($is_text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # DBD::Oracle is loaded lazily: this function only runs for real LOB binds, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # i.e. with a live database connection, where DBD::Oracle must be present. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # Loading it at compile time would make every offline user of this module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # (e.g. DBIO::Oracle::Diff::Column) fail on hosts without DBD::Oracle. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | require DBD::Oracle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | ora_type => $is_text ? DBD::Oracle::ORA_CLOB() : DBD::Oracle::ORA_BLOB(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 67 | ▶ | sub render_default_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_default_value: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 67 | my ($dv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 67 | ▶ | return undef unless defined $dv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 66 | ▶ | return $$dv if ref $dv eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 60 | ▶ | return "$dv" if $dv =~ /\A(?:0|-?[1-9][0-9]*(?:\.[0-9]*[1-9])?|-?0\.[0-9]*[1-9])\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 40 | (my $lit = $dv) =~ s/'/''/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 40 | return "'$lit'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub normalize_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_type: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my ($t) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $t //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$t //= ""
MC/DC0%0/1
$t //= ""
$t
Truth table0%0/2
A
A= $t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $t =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return uc $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 28 | ▶ | sub map_dbd_type_to_dbio { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_dbd_type_to_dbio: called CC=35 SCAR=36.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 28 | my ($data_type, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 28 | ▶ | my $nchar_size_factor = $args{nchar_size_factor} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"nchar_size_factor"} // 1
MC/DC100%1/1
$args{"nchar_size_factor"} // 1
$args{"nchar_size_factor"}
Truth table100%2/2
A
A= $args{"nchar_size_factor"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 28 | ▶ | $data_type //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data_type //= ""
MC/DC0%0/1
$data_type //= ""
$data_type
Truth table50%1/2
A
A= $data_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 28 | my $lc_dt = lc $data_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 28 | my %col = (data_type => $lc_dt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 28 | ▶ | if ($lc_dt =~ /^(?:n(?:var)?char2?|u?rowid|nclob)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | $col{data_type} = $data_type; # keep case for special types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | ▶ | $col{size} = length($data_type) if $lc_dt =~ /^u?rowid\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # NCHAR and NVARCHAR2 carry their size. ALL_TAB_COLUMNS.data_length holds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # it in bytes of the national character set (NVARCHAR2(20) is 40 in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # AL16UTF16); char_length holds the characters, which is what was | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # declared. Without char_length the bytes are divided by the factor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | if ($lc_dt =~ /^n(?:var)?char2?\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $col{size} = $args{char_length} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ? $args{char_length} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | : $args{data_length} ? $args{data_length} / $nchar_size_factor : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | delete $col{size} unless defined $col{size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | elsif ($lc_dt =~ /^(?:n?[cb]lob|long(?: raw)?|bfile|date|binary_(?:float|double)|rowid)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | delete $col{size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | elsif ($lc_dt =~ /^(?:var)?char2?\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # data_length is bytes (80 for VARCHAR2(20 CHAR) in AL32UTF8). A column | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # of character semantics (char_used 'C') is read as "N CHAR", which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # map_dbio_type_to_oracle writes back as it is; BYTE keeps the plain size. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $col{size} = ($args{char_used} // '') eq 'C' && $args{char_length} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ? "$args{char_length} CHAR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 5 | ▶ | : $args{data_length}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
($args{"char_used"} // "") eq "C" and $args{"char_length"}
$args{"char_used"} // ""
MC/DC50%1/2
($args{"char_used"} // "") eq "C" and $args{"char_length"}
$args{"char_used"}
$args{"char_length"}
Truth table66%2/3
A and B
A= $args{"char_used"}B= $args{"char_length"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif ($lc_dt =~ /^(number|decimal)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | $col{data_type} = 'numeric'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # INTEGER/SMALLINT, what integer is written as, have no precision and a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # scale of 0; a bare NUMBER has neither. NUMBER(38) and NUMBER(38,0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # (precision 38) are numeric like any other NUMBER(p,s). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 4 | ▶ | if (!defined $args{data_precision} && defined $args{data_scale} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition83%5/6
not defined $args{"data_precision"} and defined $args{"data_scale"} and $args{"data_scale"} == 0
not defined $args{"data_precision"} and defined $args{"data_scale"}
MC/DC66%2/3
not defined $args{"data_precision"} and defined $args{"data_scale"} and $args{"data_scale"} == 0
not defined $args{"data_precision"}
defined $args{"data_scale"}
$args{"data_scale"} == 0
Truth table75%3/4
not(A) and B and C
A= not defined $args{"data_precision"}B= defined $args{"data_scale"}C= $args{"data_scale"} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | && $args{data_scale} == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | $col{data_type} = 'integer'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ▶ | elsif (defined $args{data_precision} && defined $args{data_scale}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $args{"data_precision"} and defined $args{"data_scale"}
MC/DC50%1/2
defined $args{"data_precision"} and defined $args{"data_scale"}
defined $args{"data_precision"}
defined $args{"data_scale"}
Truth table66%2/3
A and B
A= defined $args{"data_precision"}B= defined $args{"data_scale"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $col{size} = [$args{data_precision}, $args{data_scale}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | elsif (defined $args{data_precision}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $col{size} = $args{data_precision}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | elsif (my ($precision) = $lc_dt =~ /^timestamp\((\d+)\)(?: with(?: local)? time zone)?\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | $col{data_type} = $data_type =~ /local time zone/i ? 'timestamp with local time zone' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | : $data_type =~ /time zone/i ? 'timestamp with time zone' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | : 'timestamp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | $col{size} = $precision unless $precision == 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | elsif (my ($year_p) = $lc_dt =~ /^interval year\((\d+)\) to month\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # the dictionary names the precision inside the type: INTERVAL YEAR(3) TO MONTH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | $col{data_type} = 'interval year to month'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | $col{size} = $year_p unless $year_p == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | elsif (my ($day_p, $sec_p) = $lc_dt =~ /^interval day\((\d+)\) to second\((\d+)\)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | $col{data_type} = 'interval day to second'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | $col{size} = [$day_p, $sec_p] unless ($day_p == 2 && $sec_p == 6); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$day_p == 2 and $sec_p == 6
MC/DC0%0/2
$day_p == 2 and $sec_p == 6
$day_p == 2
$sec_p == 6
Truth table33%1/3
A and B
A= $day_p == 2B= $sec_p == 6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | elsif ($lc_dt eq 'float') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # data_length is 22 for every FLOAT; the binary precision is in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # data_precision, and a FLOAT without one is FLOAT(126), which carries no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # size here (the dictionary cannot tell the two apart). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | $col{data_type} = 'float'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | $col{size} = $args{data_precision} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | if defined $args{data_precision} && $args{data_precision} != 126; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $args{"data_precision"} and $args{"data_precision"} != 126
MC/DC100%2/2
defined $args{"data_precision"} and $args{"data_precision"} != 126
defined $args{"data_precision"}
$args{"data_precision"} != 126
Truth table100%3/3
A and B
A= defined $args{"data_precision"}B= $args{"data_precision"} != 126
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | elsif ($lc_dt eq 'raw') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # data_length of a RAW is its length in bytes, which is what is declared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | $col{size} = $args{data_length} if $args{data_length}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 28 | return \%col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1052 | ▶ | sub map_dbio_type_to_oracle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_dbio_type_to_oracle: called CC=48 SCAR=38.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1052 | my ($type, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1052 | ▶ | $type //= 'varchar2'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$type //= "varchar2"
MC/DC0%0/1
$type //= "varchar2"
$type
Truth table50%1/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # compared as it means: letter case and blanks (double precision) are not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # part of the type; $type itself is what the fallback writes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1052 | (my $lc = lc $type) =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1052 | $lc =~ s/\A | \z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1052 | my $size = $args{size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # Render a base type with its optional size, e.g. VARCHAR2(128) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # NUMBER(10,2). When no size is given, fall back to $default (which may | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # itself be undef for an unsized base type). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 642 | ▶ | my $sized = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 642 | my ($base, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | my $spec = defined $size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 642 | ▶ | ? (ref $size eq 'ARRAY' ? join(',', grep { defined } @$size) : $size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | : $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # a length semantics is written the one way: "20 CHAR", "20 BYTE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 642 | ▶ | $spec = "$1 \U$2" if defined $spec && $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $spec and $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
MC/DC100%2/2
defined $spec and $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
defined $spec
$spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
Truth table100%3/3
A and B
A= defined $specB= $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 642 | ▶ | return defined $spec && length $spec ? "$base($spec)" : $base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $spec and length $spec
MC/DC50%1/2
defined $spec and length $spec
defined $spec
length $spec
Truth table66%2/3
A and B
A= defined $specB= length $spec
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1052 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # Numeric types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # INTEGER, not a bare NUMBER: the dictionary reports a bare NUMBER with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # neither precision nor scale, which is read as numeric, and NUMBER(38) with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # precision 38, which is numeric(38); INTEGER is precision NULL, scale 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # which only integer is (karr k38). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1052 | ▶ | return 'INTEGER' if $lc eq 'integer' || $lc eq 'bigint' || $lc eq 'smallint'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$lc eq "integer" or $lc eq "bigint" or $lc eq "smallint"
$lc eq "integer" or $lc eq "bigint"
MC/DC100%3/3
$lc eq "integer" or $lc eq "bigint" or $lc eq "smallint"
$lc eq "integer"
$lc eq "bigint"
$lc eq "smallint"
Truth table100%4/4
A or B or C
A= $lc eq "integer"B= $lc eq "bigint"C= $lc eq "smallint"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 683 | ▶ | return 'NUMBER(10)' if $lc eq 'serial'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 683 | ▶ | return 'NUMBER(20)' if $lc eq 'bigserial'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # Character types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 683 | ▶ | return $sized->('VARCHAR2', 255) if $lc eq 'varchar' || $lc eq 'varchar2'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$lc eq "varchar" or $lc eq "varchar2"
MC/DC100%2/2
$lc eq "varchar" or $lc eq "varchar2"
$lc eq "varchar"
$lc eq "varchar2"
Truth table100%3/3
A or B
A= $lc eq "varchar"B= $lc eq "varchar2"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # A national type is of character semantics always; Oracle refuses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # NCHAR(5 CHAR), so "5 CHAR" is written as 5. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 364 | ▶ | if ($lc eq 'nvarchar2' || $lc eq 'nvarchar' || $lc eq 'nchar') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$lc eq "nvarchar2" or $lc eq "nvarchar" or $lc eq "nchar"
$lc eq "nvarchar2" or $lc eq "nvarchar"
MC/DC100%3/3
$lc eq "nvarchar2" or $lc eq "nvarchar" or $lc eq "nchar"
$lc eq "nvarchar2"
$lc eq "nvarchar"
$lc eq "nchar"
Truth table100%4/4
A or B or C
A= $lc eq "nvarchar2"B= $lc eq "nvarchar"C= $lc eq "nchar"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 26 | ▶ | $size = $1 if defined $size && !ref $size && $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $size and not ref $size and $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
defined $size and not ref $size
MC/DC66%2/3
defined $size and not ref $size and $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
defined $size
not ref $size
$size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
Truth table75%3/4
A and not(B) and C
A= defined $sizeB= not ref $sizeC= $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 26 | ▶ | return $sized->($lc eq 'nchar' ? ('NCHAR', 1) : ('NVARCHAR2', 255)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 338 | ▶ | return $sized->('CHAR', 1) if $lc eq 'char'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 325 | ▶ | return 'CLOB' if $lc eq 'text' || $lc eq 'long'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lc eq "text" or $lc eq "long"
MC/DC50%1/2
$lc eq "text" or $lc eq "long"
$lc eq "text"
$lc eq "long"
Truth table66%2/3
A or B
A= $lc eq "text"B= $lc eq "long"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # Date/time types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 321 | ▶ | return 'DATE' if $lc eq 'date'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 313 | ▶ | return $sized->('TIMESTAMP') if $lc eq 'timestamp' || $lc eq 'datetime'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lc eq "timestamp" or $lc eq "datetime"
MC/DC50%1/2
$lc eq "timestamp" or $lc eq "datetime"
$lc eq "timestamp"
$lc eq "datetime"
Truth table66%2/3
A or B
A= $lc eq "timestamp"B= $lc eq "datetime"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 291 | ▶ | if ($lc eq 'timestamptz' || $lc eq 'timestamp with time zone') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$lc eq "timestamptz" or $lc eq "timestamp with time zone"
MC/DC100%2/2
$lc eq "timestamptz" or $lc eq "timestamp with time zone"
$lc eq "timestamptz"
$lc eq "timestamp with time zone"
Truth table100%3/3
A or B
A= $lc eq "timestamptz"B= $lc eq "timestamp with time zone"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | my $ts = $sized->('TIMESTAMP'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 4 | return "$ts WITH TIME ZONE"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 287 | ▶ | if ($lc eq 'timestamp with local time zone') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | my $ts = $sized->('TIMESTAMP'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | return "$ts WITH LOCAL TIME ZONE"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # Binary types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 284 | ▶ | return 'BLOB' if $lc eq 'bytea' || $lc eq 'blob'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lc eq "bytea" or $lc eq "blob"
MC/DC50%1/2
$lc eq "bytea" or $lc eq "blob"
$lc eq "bytea"
$lc eq "blob"
Truth table66%2/3
A or B
A= $lc eq "bytea"B= $lc eq "blob"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 282 | ▶ | return 'CLOB' if $lc eq 'clob'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 282 | ▶ | return 'NUMBER(1)' if $lc eq 'boolean'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # Float/double | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 281 | ▶ | return 'BINARY_FLOAT' if $lc eq 'real'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 279 | ▶ | return 'BINARY_DOUBLE' if $lc eq 'double precision' || $lc eq 'double'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$lc eq "double precision" or $lc eq "double"
MC/DC100%2/2
$lc eq "double precision" or $lc eq "double"
$lc eq "double precision"
$lc eq "double"
Truth table100%3/3
A or B
A= $lc eq "double precision"B= $lc eq "double"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 270 | ▶ | if ($lc eq 'float') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 19 | ▶ | DBIO::Exception->throw(sprintf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%12/12
defined $size and ref $size || !($size =~ /\A[0-9]+\z/) || $size < 1 || $size > 126
ref $size or not $size =~ /\A[0-9]+\z/ or $size < 1 or $size > 126
ref $size or not $size =~ /\A[0-9]+\z/ or $size < 1
ref $size or not $size =~ /\A[0-9]+\z/
MC/DC100%5/5
defined $size and ref $size || !($size =~ /\A[0-9]+\z/) || $size < 1 || $size > 126
defined $size
ref $size
not $size =~ /\A[0-9]+\z/
$size < 1
$size > 126
Truth table100%6/6
A and B or not(C) or D or E
A= defined $sizeB= ref $sizeC= not $size =~ /\A[0-9]+\z/D= $size < 1E= $size > 126
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 'float takes a binary precision, a whole number from 1 to 126, not %s; refused', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | ref $size ? 'a ' . ref($size) . ' reference' : "'$size'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | if defined $size && (ref $size || $size !~ /\A[0-9]+\z/ || $size < 1 || $size > 126); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 10 | return $sized->('FLOAT'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Numeric/decimal — size may be a scalar precision or [precision, scale] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 251 | ▶ | return $sized->('NUMBER') if $lc eq 'numeric' || $lc eq 'decimal'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lc eq "numeric" or $lc eq "decimal"
MC/DC50%1/2
$lc eq "numeric" or $lc eq "decimal"
$lc eq "numeric"
$lc eq "decimal"
Truth table66%2/3
A or B
A= $lc eq "numeric"B= $lc eq "decimal"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # Fallback — pass through uppercase, with the size it was given (RAW(16)). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # An interval carries its precision inside the name, not after it: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # INTERVAL YEAR(3) TO MONTH, INTERVAL DAY(3) TO SECOND(4). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 18 | ▶ | if ($lc eq 'interval year to month') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | return defined $size ? "INTERVAL YEAR($size) TO MONTH" : 'INTERVAL YEAR TO MONTH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 16 | ▶ | if ($lc eq 'interval day to second') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 4 | ▶ | my ($day, $sec) = ref $size eq 'ARRAY' ? @$size : ($size); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 4 | ▶ | return 'INTERVAL DAY' . (defined $day ? "($day)" : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | . ' TO SECOND' . (defined $sec ? "($sec)" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 12 | ▶ | return uc $type if $lc =~ /^interval\b/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 12 | return $sized->(uc $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 58 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||