Branch Coverage

blib/lib/DBIx/BulkUtil.pm
Criterion Covered Total %
branch 0 910 0.0


line true false branch
51 0 0 unless $is_valid{$opt}
61 0 0 !$args->{'Server'} && $args->{'Database'} ? :
62 0 0 if ($args->{'Type'} eq 'SybaseIQ')
83 0 0 if (@_ and ref $_[-1])
88 0 0 if $bad_opt
93 0 0 if $args{'Silent'}
94 0 0 $args{'Silent'} ? :
103 0 0 ref $args{'Dsl'} ? :
0 0 $args{'Dsl'} ? :
109 0 0 unless (@dsl_args)
110 0 0 if ($type eq 'Sybase') { }
0 0 elsif ($type eq 'Oracle') { }
114 0 0 unless $args{'NoServer'}
115 0 0 unless $args{'NoCharset'}
116 0 0 if $args{'BulkLogin'}
118 0 0 unless $args{'NoServer'}
127 0 0 ref $args{'DslOptions'} ? :
0 0 if $args{'DslOptions'}
139 0 0 if $retry_seconds < 0
141 0 0 $type eq 'Sybase' ? :
147 0 0 unless ($dbh)
148 0 0 unless $retry-- > 0
156 0 0 if ($type eq 'Sybase') { }
0 0 elsif ($type eq 'Oracle') { }
159 0 0 if ($database)
163 0 0 unless ($result)
164 0 0 unless $retry-- > 0
173 0 0 if $args{'IsIQ'} and not $args{'NoBlankNull'}
191 0 0 unless wantarray
244 0 0 if (@args % 2 == 0)
248 0 0 unless $dbi_opts and ref $dbi_opts
262 0 0 if ($type eq 'Sybase')
264 0 0 if $version =~ /IQ/
266 0 0 unless $class =~ s/::Obj$//
275 0 0 if 'DBIx::BulkUtil::Obj' eq $class
278 0 0 if ($args and ref $args)
279 0 0 if $args->{'NoBlankNull'}
284 0 0 if $dbh_pid != $$
295 0 0 if @result == 1
308 0 0 if (ref $_[-1])
316 0 0 if $opts->{'EscapeChar'}
319 0 0 $opts->{'QuoteFields'} ? :
323 0 0 if (length $delimiter == 1)
334 0 0 $opts->{'Columns'} ? :
341 0 0 if ($db_type eq 'Oracle')
343 0 0 $table =~ s/:(\w+)$// ? :
345 0 0 if ($nls_lang =~ /utf8/i)
348 0 0 if ($col_list eq '*')
355 0 0 if ($col_map->{$col}{'TYPE_NAME'} eq 'XMLTYPE')
362 0 0 if ($xml_cnt)
366 0 0 if $partition
368 0 0 $enc_opt ? :
370 0 0 unless open my $fh, ">$enc", $file
372 0 0 if $opts->{'Filter'}
376 0 0 unless $opts->{'TrimBlanks'}
378 0 0 if ($opts->{'Header'})
379 0 0 if ($csv) { }
389 0 0 if ($csv) { }
408 0 0 if (ref $_[-1])
415 0 0 $opts->{'QuoteFields'} ? :
425 0 0 unless open my $in_fh, '<', $file_in
426 0 0 unless open my $out_fh, '>', $file_out
429 0 0 $opts->{'DropCols'} ? :
434 0 0 @drop_cols ? :
0 0 $opts->{'KeepCols'} ? :
438 0 0 if $opts->{'Header'}
451 0 0 if ($opts->{'Header'} or $opts->{'Columns'})
457 0 0 ref $opts->{'Columns'} ? :
0 0 $opts->{'Columns'} ? :
464 0 0 if $opts->{'QuoteFields'}
473 0 0 unless open my $fh, '>', "$file.bak"
482 0 0 unless File::Copy::copy($file, $fh)
498 0 0 if not $done++ and $opts->{'Header'}
500 0 0 if ($opts->{'QuoteFields'})
602 0 0 if (%chg_field)
607 0 0 if $col_map->{$c}
618 0 0 if $pk
621 0 0 unless $idx
625 0 0 if $pk_name
636 0 0 unless $key_cols
647 0 0 if $where
660 0 0 unless ref $sth
665 0 0 if $status
666 0 0 unless $@ =~ /deadlock/i
668 0 0 if $_ < $retry
685 0 0 unless $fmt
715 0 0 unless my $col_info = $self->column_info($table)
722 0 0 $type eq 'Sybase' ? :
732 0 0 if ($con) { }
746 0 0 if $type eq 'Oracle'
748 0 0 if ($type eq 'Sybase') { }
756 0 0 unless (defined $t)
758 0 0 unless ref $status[$i]
759 0 0 ref $ex_arg_list[$_] ? :
766 0 0 if $cnt > 0
769 0 0 if ($type eq 'Sybase') { }
772 0 0 $cnt > 0 ? :
777 0 0 unless (defined $t)
779 0 0 unless ref $status[$i]
787 0 0 $cnt > 0 ? :
811 0 0 $self->type eq 'Sybase' ? :
0 0 !($href || $aref) ? :
0 0 defined $opt{'ByName'} ? :
814 0 0 if $href and $aref
815 0 0 if $href || $aref and not $by_name
817 0 0 unless $table or $sql
818 0 0 if $table and $sql
821 0 0 if $table
824 0 0 unless $dflt_col
826 0 0 if ($columns and @$columns)
829 0 0 @$columns > 5 ? :
831 0 0 $cnt++ ? :
0 0 @$columns > 5 ? :
834 0 0 $h_cnt++ ? :
0 0 @$columns > 5 ? :
836 0 0 @$columns > 5 ? :
0 0 $by_name ? :
837 0 0 $by_name ? :
847 0 0 if ($href) { }
0 0 elsif ($aref) { }
889 0 0 unless (@_)
907 0 0 unless (@_ == $self->{'ARG_LEN'})
914 0 0 if (++$$cnt >= $self->{'COMMIT_SIZE'})
940 0 0 unless @_
983 0 0 ref $_[-1] ? :
987 0 0 $table =~ s/(:\d+)$// ? :
994 0 0 unless $db =~ /server=(\w+)/
1003 0 0 $table =~ /^\w*\.\w+$/ ? :
0 0 $table =~ /^\w+$/ ? :
0 0 !$database || $table =~ /^\w+\.\w*\.\w+$/ ? :
1013 0 0 if ($dir eq 'in')
1015 0 0 if ($mode eq 'T') { }
0 0 elsif ($mode eq 'R') { }
1022 0 0 unless -f $file
1026 0 0 unless (-s _)
1037 0 0 unless ($opts{'GenerateId'})
1040 0 0 if ($col_map)
1042 0 0 if $c->{'TYPE_NAME'} =~ /identity/
1048 0 0 $dir eq 'in' ? :
1053 0 0 if ($dir eq 'in')
1056 0 0 if $opts{'Header'}
1057 0 0 if $id_cnt
1063 0 0 if $in_temp_dir
1066 0 0 $in_temp_dir ? :
1067 0 0 $keep_temp ? :
1076 0 0 $opts{'PacketSize'} ? :
1077 0 0 $opts{'PassThru'} ? :
1080 0 0 if ($opts{'FormatFile'}) { }
0 0 elsif ($opts{'ColumnList'} and $opts{'ColumnList'} or $opts{'Filler'} and @{$opts{'Filler'};}) { }
1094 0 0 $fmt_file ? :
1117 0 0 unless open my $fh, '-|', @cmd
1125 0 0 if (/^(Server|C[TS]LIB) Message/)
1127 0 0 if ($msg_type eq 'CSLIB') { }
0 0 elsif ($msg_type eq 'CTLIB') { }
1128 0 0 if (m[/N(\d+)])
1131 0 0 unless ($1 == 36)
1141 0 0 if (/\s(\d+)/) { }
1143 0 0 unless ($1 == 4852)
1153 0 0 if /^(\d+) rows copied/
1156 0 0 if (/^bcp copy in ((?:partially )?)failed/)
1157 0 0 if $1
1170 0 0 unless open my $err_h, '<', $error_file->filename
1172 0 0 if /^#@ Row \d+: Not transferred/
1176 0 0 if ($err_file_cnt > $c_lib_err_cnt)
1184 0 0 unless ($close_success)
1191 0 0 if ($exit_stat != 0)
1192 0 0 if ($dir eq 'in') { }
1198 0 0 if $err_cnt > $max_err_cnt
1202 0 0 unless defined $rows or $failed
1207 0 0 if $failed and not $partially_failed
1215 0 0 if $exit_sig > 0
1216 0 0 if $exit_core
1222 0 0 unless defined $rows
1225 0 0 if $err_cnt > $max_err_cnt
1245 0 0 if ($opts{'Filler'})
1250 0 0 if ($opts{'FormatFileName'}) { }
1258 0 0 if $in_temp_dir
1259 0 0 $in_temp_dir ? :
1260 0 0 $keep_temp || !defined(wantarray) ? :
1283 0 0 $opts{'ColumnList'} && @{$opts{'ColumnList'};} ? :
1286 0 0 unless open my $fh, '>', $fmt_file
1293 0 0 $i == $ncols ? :
1295 0 0 if ($is_filler{lc $name}) { }
0 0 elsif ($is_db_column{lc $name}) { }
1305 0 0 $info->{'TYPE_NAME'} =~ /char|text/ ? :
0 0 $info->{'TYPE_NAME'} =~ /date/ ? :
1316 0 0 $tmp_fmt_file ? :
0 0 wantarray ? :
1325 0 0 if (ref $_[-1])
1331 0 0 @opts ? :
1342 0 0 unless (defined $rows)
1344 0 0 if ($view)
1347 0 0 unless $result
1348 0 0 if not $self->is_iq and $curr_db
1353 0 0 if ($view)
1356 0 0 if not $self->is_iq and $curr_db
1358 0 0 unless (@opts and $opts[0]{'NoFix'})
1360 0 0 if ($bak) { }
1367 0 0 if (@opts and $opts[0]{'Header'} || $opts[0]{'QuoteFields'})
1369 0 0 if ($bak) { }
1383 0 0 if ref $_[-1]
1384 0 0 @opts ? :
1396 0 0 @opts && $opts[0]{'Columns'} ? :
1404 0 0 if (ref $col_list) { }
1407 0 0 if (my $info = $col_map->{$name})
1410 0 0 if ($type =~ /money/)
1412 0 0 $type =~ /small/ ? :
1423 0 0 if $money_cnt == 0 and not $opts[0]{'Filter'} and not $opts[0]{'Columns'}
1428 0 0 if (not $curr_db and $table =~ /^(\w+)\.\w*\.\w+$/)
1431 0 0 unless $curr_db
1433 0 0 $table =~ /^\w*\.\w+$/ ? :
0 0 $table =~ /^\w+$/ ? :
0 0 !$curr_db || $table =~ /^\w+\.\w*\.\w+$/ ? :
1440 0 0 if length $tmp_view > 19
1442 0 0 unless $self->is_iq
1450 0 0 $self->is_iq ? :
1457 0 0 if @opts and $opts[0]{'Filter'}
1461 0 0 if $result
1462 0 0 unless $@ =~ /already an object/
1464 0 0 if $cnt > 20
1480 0 0 if (ref $_[-1])
1493 0 0 $9 eq 'A' && $5 == 12 ? :
0 0 $9 eq 'P' && $5 < 12 ? :
1505 0 0 $7 eq 'A' && $5 == 12 ? :
0 0 $7 eq 'P' && $5 < 12 ? :
1533 0 0 unless $type
1568 0 0 if ($table =~ /^(?:(\w+)\.)?(\w*)\.(\w+)$/)
1573 0 0 if (defined $tmp_db and $tmp_db ne $curr_db)
1579 0 0 unless $all_indexes
1587 0 0 if ($row{'col_name'})
1592 0 0 if defined $tmp_db and $tmp_db ne $curr_db
1594 0 0 unless %ind
1608 0 0 if ($table =~ /^(?:(\w+)\.)?(\w*)\.(\w+)$/)
1613 0 0 if defined $tmp_db and $tmp_db ne $curr_db
1618 0 0 if defined $tmp_db and $tmp_db ne $curr_db
1620 0 0 unless @pk
1654 0 0 $args{'KeyCols'} && @{$args{'KeyCols'};} ? :
1655 0 0 $args{'UpdCols'} && @{$args{'UpdCols'};} ? :
1665 0 0 if $args{'ColMap'}
1673 0 0 $tmp_col_map{lc $_} ? :
1685 0 0 $stg_has{$tmp_col_map{$_}} ? :
0 0 $stg_has{$_} ? :
0 0 $stg_map->{$_} ? :
0 0 $is_key_col{$_} || $is_upd_col{$_} ? :
0 0 $tmp_col_map{$_} ? :
0 0 $_ eq 'last_chg_date' && !$stg_has{'last_chg_date'} ? :
0 0 $_ eq 'last_chg_user' && !$stg_has{'last_chg_user'} ? :
1698 0 0 unless ($args{'NoExec'})
1709 0 0 if $args{'NoExec'}
1711 0 0 $args{'NoBCP'} || $stg_table =~ /^#/ ? :
1757 0 0 $args{'KeyCols'} && @{$args{'KeyCols'};} ? :
1758 0 0 $args{'UpdCols'} && @{$args{'UpdCols'};} ? :
1768 0 0 if $args{'ColMap'}
1776 0 0 $tmp_col_map{lc $_} ? :
1788 0 0 $stg_map->{$_} ? :
0 0 $is_key_col{$_} || $is_upd_col{$_} ? :
0 0 $tmp_col_map{$_} ? :
0 0 $_ eq 'last_chg_date' && !$stg_has{'last_chg_date'} ? :
0 0 $_ eq 'last_chg_user' && !$stg_has{'last_chg_user'} ? :
1798 0 0 $col eq 'last_chg_user' ? :
1801 0 0 unless ($args{'InsertOnly'})
1810 0 0 unless ($args{'NoExec'})
1823 0 0 unless ($args{'NoExec'})
1834 0 0 if $args{'NoExec'}
1849 0 0 unless $db =~ /server=(\w+)/
1854 0 0 $table =~ /^\w*\.\w+$/ ? :
0 0 $table =~ /^\w+$/ ? :
0 0 !$database || $table =~ /^\w+\.\w*\.\w+$/ ? :
1862 0 0 unless defined $pid
1863 0 0 unless ($pid)
1874 0 0 unless (open $sqsh_fh, '|-', @cmd)
1882 0 0 $status ? :
1888 0 0 if (/^Batch successfully bulk-copied/)
1890 0 0 unless $cnt % 10000
1894 0 0 if /^\s*(\d+) rows copied/
1897 0 0 unless defined $rows
1898 0 0 unless $close_status
1941 0 0 if $where
1950 0 0 unless ($rows)
1957 0 0 if $rows > 0
1963 0 0 if $err
1994 0 0 ref $_[-1] ? :
1998 0 0 unless @files
2007 0 0 if ($mode eq 'T') { }
0 0 elsif ($mode eq 'R') { }
2019 0 0 unless -f $file
2020 0 0 unless (-s _)
2027 0 0 unless (@bcp_list)
2036 0 0 $opts->{'ColumnList'} && @{$opts->{'ColumnList'};} ? :
2037 0 0 $opts->{'Filler'} ? :
2043 0 0 $self->{'NoBlankNull'} ? :
2064 0 0 $is_filler{$_} ? :
0 0 $is_filler{$_} ? :
0 0 $is_filler{$_} ? :
0 0 $opts->{'TrailingDelimiter'} ? :
0 0 $_ ne $last_col ? :
0 0 defined $constant->{$_} ? :
2069 0 0 if $opts->{'Header'}
2073 0 0 if $opts->{'MaxErrors'}
2076 0 0 unless $db =~ /server=(\w+)/
2120 0 0 if not $all_indexes and $row{'unique_index'} ne 'Y'
2124 0 0 unless %ind
2161 0 0 if (my $str = $intervals{$unit})
2205 0 0 /^:cursor$/ ? :
2220 0 0 if (ref $_[-1])
2227 0 0 $table =~ s/:(\w+)$// ? :
2232 0 0 unless @files or $stdin
2236 0 0 if ($file eq '-')
2240 0 0 unless -f $file
2243 0 0 if ($has_stdin and not $stdin) { }
0 0 elsif ($stdin and not $has_stdin) { }
2252 0 0 unless $_ eq '-'
2254 0 0 unless (@bcp_files)
2255 0 0 if ($action_opt eq 'A')
2277 0 0 if $in_temp_dir
2279 0 0 $in_temp_dir ? :
2280 0 0 $keep_temp ? :
2299 0 0 $stdin ? :
2312 0 0 unless ($tbl_name)
2321 0 0 if $opts->{'Debug'}
2322 0 0 if $opts->{'Debug'}
2325 0 0 if $opts->{'Debug'}
2326 0 0 exists $char_sizes{$row{'COLUMN_NAME'}} ? :
0 0 if $row{'TYPE_NAME'} =~ /CHAR/
2327 0 0 exists $char_sizes{$row{'COLUMN_NAME'}} ? :
0 0 if $row{'TYPE_NAME'} =~ /TEXT|LOB|XML/
2328 0 0 if $row{'TYPE_NAME'} =~ /(DATE|TIMESTAMP)/
2330 0 0 unless @columns
2335 0 0 $opts->{'ColumnList'} && @{$opts->{'ColumnList'};} ? :
2336 0 0 if (%is_date)
2340 0 0 $opts->{'RowDelimiter'} ? :
2350 0 0 if $opts->{'Header'}
2352 0 0 if ($opts->{'DirectPath'}) { }
2353 0 0 uc $opts->{'DirectPath'} eq 'P' ? :
2363 0 0 $opts->{'DateFormat'} ? :
0 0 $opts->{'SybaseDateFmt'} ? :
2367 0 0 if $date_fmt{$_} =~ /FF|TZ[DHMR]/
2370 0 0 $opts->{'QuoteFields'} ? :
2373 0 0 if ($opts->{'LoadWhen'})
2378 0 0 if $opts->{'NLSLang'}
2379 0 0 if $opts->{'Semantics'}
2380 0 0 if $nls_str
2383 0 0 if $opts->{'SybaseTypes'}
2388 0 0 if $opts->{'PreserveBlanks'} or $size == 1
2389 0 0 if ($opts->{'SybaseTypes'}) { }
2391 0 0 if $is_lob{$_}
2392 0 0 if $sybase_type{$_} eq 'char'
2394 0 0 if $is_lob{$_}
2395 0 0 if $opts->{'TrimBlanks'}
2408 0 0 if $field_ref{$_} =~ /:$_\b/i
2412 0 0 $opts->{'ColumnList'} && @{$opts->{'ColumnList'};} ? :
2416 0 0 if ($opts->{'Filler'})
2424 0 0 if ($partition)
2452 0 0 $char_sz{$_} ? :
0 0 $is_date{$_} ? :
0 0 exists $field_ref{$_} ? :
0 0 exists $is_filler{$_} ? :
0 0 exists $const{$_} ? :
2456 0 0 if ($prm_fh)
2467 0 0 $prm_fh ? :
2468 0 0 if ($keep_temp)
2478 0 0 if $prm_file
2487 0 0 if $opts->{'Debug'} or $opts->{'NoExec'}
2488 0 0 if $opts->{'NoExec'}
2494 0 0 if ($stdin) { }
2500 0 0 unless open my $cmd_fh, '|-', @cmd
2519 0 0 if (-s $bad_file)
2520 0 0 if ($max_errors > 0) { }
2523 0 0 unless open my $fh, '<', $bad_file
2531 0 0 unless open my $fh, '<', $log_file
2537 0 0 if (/^\s*(\d+)/)
2539 0 0 if /successfully loaded/
2540 0 0 if /not loaded due to data errors/
2541 0 0 if /not loaded because all WHEN clauses/
2542 0 0 if /not loaded because all fields were null/
2545 0 0 if (/^Record \d+: Rejected/)
2549 0 0 if (/^(?:SQL\*Loader|ORA)-\d+:/)
2551 0 0 if /discontinued|aborted/
2556 0 0 if (/was not re-(?:enabled|validated)/)
2562 0 0 if (/^index \S+ was made unusable/)
2571 0 0 if (not $close_success or $dp_errors)
2573 0 0 if ($exit_stat != 0 or $dp_errors)
2574 0 0 if ($exit_stat == 2 or $dp_errors) { }
2579 0 0 $max_errors > 0 ? :
2580 0 0 if $dp_errors
2581 0 0 if $error_rows > $max_errors
2582 0 0 if $discontinued
2587 0 0 if $exit_sig > 0
2588 0 0 if $exit_core
2601 0 0 unless $is_date and %$is_date
2611 0 0 if $rd
2619 0 0 if $opts->{'Header'} and $. <= $opts->{'Header'}
2621 0 0 $opts->{'QuoteFields'} ? :
2623 0 0 if ($row{$_})
2626 0 0 unless %remaining
2631 0 0 if ++$row_cnt >= $sample_rows
2647 0 0 if $q
2649 0 0 if length $got_d == 0
2668 0 0 unless $str
2675 0 0 if (s/^\d{4}(\D?)\d\d(\D?)\d\d//)
2679 0 0 if length $_
2684 0 0 if s/^$day_re\s+//
2687 0 0 if (s/^$mon_re\s+\d+//)
2690 0 0 if (s/^\s\d{4}//) { }
0 0 elsif (s/\s+\d{4}$//) { }
2701 0 0 if length $_
2702 0 0 if $end_year
2707 0 0 if (s/^$month_re\s+\d+//)
2710 0 0 if (s/^(\W?)\s\d{4}//) { }
0 0 elsif (s/\s+\d{4}$//) { }
2722 0 0 if length $_
2723 0 0 if $end_year
2728 0 0 if (s/^\d\d?(\D?)$mon_re(\D?)\d{4}//)
2732 0 0 if length $_
2737 0 0 if (s/^\d\d?(\D?)$mon_re(\D?)\d\d?//)
2741 0 0 if length $_
2746 0 0 if (s/^\d\d?(\D)\d\d?(\D)\d{4}//)
2750 0 0 if length $_
2762 0 0 if (s/^(\D?)[\s\d]\d//)
2764 0 0 if $sep =~ /\S/
2766 0 0 /[AP]M\b/i ? :
2767 0 0 if (s/^(\D)\d\d//)
2769 0 0 if (s/^(\D)\d\d//)
2771 0 0 if (s/^(\D)(\d+)//)
2776 0 0 if (s/^(\s?)[AP]M//)
2779 0 0 if (s/^(\s*)\w{2,3}T//i)
2782 0 0 if (s/^\s[+-]\d\d(\D)\d\d//)
2796 0 0 if ($name =~ /^([^.]+)\.(.+)/) { }
2811 0 0 unless $type
2839 0 0 unless ($tbl)
2844 0 0 unless $all_indexes
2854 0 0 unless %ind
2863 0 0 unless ($tbl)
2868 0 0 unless @pk
2895 0 0 $args{'KeyCols'} && @{$args{'KeyCols'};} ? :
2896 0 0 $args{'UpdCols'} && @{$args{'UpdCols'};} ? :
2903 0 0 $args{'ColMap'} ? :
2908 0 0 $stg_has{$col_map{$_}} ? :
0 0 $stg_has{$_} ? :
0 0 $col_map{$_} ? :
2918 0 0 $col eq 'last_chg_user' ? :
2923 0 0 $args{'Parallel'} ? :
2933 0 0 $args{'MergeFilter'} ? :
2934 0 0 $stg_has{$col_map{$_}} ? :
0 0 $stg_has{$_} ? :
0 0 $col_map{$_} ? :
2939 0 0 unless @upd_cols
2941 0 0 if $args{'NoExec'}
2943 0 0 if $args{'Parallel'}
2978 0 0 unless my $table = $args{'Table'}
2981 0 0 unless my $dir = $args{'Dir'}
2982 0 0 unless my $file = $args{'File'}
2999 0 0 defined $dec ? :
0 0 /NUMBER/ ? :
0 0 /CHAR/ ? :