| 1 | # Copyright (C) 2008 Ioannis Tambouras <ioannis@cpan.org>. All rights reserved. | ||||||||||||||||||||||||||||
| 2 | # LICENSE: GPLv3, eead licensing terms at http://www.fsf.org . | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package Pg::Loader::Misc_2; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use 5.010000; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | #use Config::Format::Ini; | ||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Log::Log4perl ':easy'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | #use Text::CSV; | ||||||||||||||||||||||||||||
| 13 | #use Pg::Loader::Columns; | ||||||||||||||||||||||||||||
| 14 | #use Pg::Loader::Query; | ||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use Pg::Loader::Log; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | #use List::MoreUtils qw( firstidx ); | ||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | #use Quantum::Superpositions ; | ||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use Text::Table; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 5 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 5 | our @EXPORT = qw( | |||||||||||||||||||||||||||
| 25 | sample_config show_sections add_defaults | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub sample_config { | ||||||||||||||||||||||||||
|
Subroutine
sample_config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 0 | (my $tmp = <<EOM ) =~ s/^\t//gmo ; | |||||||||||||||||||||||||||
| 30 | [pgsql] | ||||||||||||||||||||||||||||
| 31 | base = people | ||||||||||||||||||||||||||||
| 32 | pass = apple | ||||||||||||||||||||||||||||
| 33 | #host = localhost | ||||||||||||||||||||||||||||
| 34 | #pgsysconfdir=. | ||||||||||||||||||||||||||||
| 35 | #service= | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | [exam] | ||||||||||||||||||||||||||||
| 38 | filename = exam.dat | ||||||||||||||||||||||||||||
| 39 | table = public.exam | ||||||||||||||||||||||||||||
| 40 | #copy = * | ||||||||||||||||||||||||||||
| 41 | #copy_columns = id, name | ||||||||||||||||||||||||||||
| 42 | #only_cols = 1-2,4,5 | ||||||||||||||||||||||||||||
| 43 | #use_template = cvs1 | ||||||||||||||||||||||||||||
| 44 | #copy_every=10000 | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | [cvs1] | ||||||||||||||||||||||||||||
| 47 | #template=true | ||||||||||||||||||||||||||||
| 48 | #format=cvs | ||||||||||||||||||||||||||||
| 49 | #doublequote=false | ||||||||||||||||||||||||||||
| 50 | #escapechar=| | ||||||||||||||||||||||||||||
| 51 | #quotechar=" | ||||||||||||||||||||||||||||
| 52 | #skipinitialspace=true | ||||||||||||||||||||||||||||
| 53 | #reject_log=rej_log | ||||||||||||||||||||||||||||
| 54 | #reject_data=rej_data | ||||||||||||||||||||||||||||
| 55 | #reformat= fn:John::Util::jupper, score:John::Util::changed | ||||||||||||||||||||||||||||
| 56 | #null=\\NA | ||||||||||||||||||||||||||||
| 57 | #trailing_sep=true | ||||||||||||||||||||||||||||
| 58 | #datestyle=euro | ||||||||||||||||||||||||||||
| 59 | #client_encoding= | ||||||||||||||||||||||||||||
| 60 | #lc_messages=C | ||||||||||||||||||||||||||||
| 61 | #lc_numeric=C | ||||||||||||||||||||||||||||
| 62 | #lc_monetary=en_US | ||||||||||||||||||||||||||||
| 63 | #lc_type=C | ||||||||||||||||||||||||||||
| 64 | #lc_time=POSIX | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | EOM | ||||||||||||||||||||||||||||
| 67 | 0 | $tmp; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub _merge_with_template { | ||||||||||||||||||||||||||
|
Subroutine
_merge_with_template: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 74 | ## Output: add columns into $s | ||||||||||||||||||||||||||||
| 75 | 0 | my ( $s, $ini, $template) = @_; | |||||||||||||||||||||||||||
| 76 | 0 | ▶ | return unless $template; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | LOGEXIT "Missing template [$template]" unless $ini->{$template}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $s->{$_} //= $ini->{$template}{$_} for keys %{$ini->{$template}}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$s->{$_} //= $ini->{$template}{$_}
MC/DC0%0/2
$s->{$_} //= $ini->{$template}{$_}
$s->{$_}
$ini->{$template}{$_}
Truth table0%0/3
A //= B
A= $s->{$_}B= $ini->{$template}{$_}
| |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub add_defaults { | ||||||||||||||||||||||||||
|
Subroutine
add_defaults: not called CC=27 SCAR=66.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 0 | my ( $ini, $section) = @_ ; | |||||||||||||||||||||||||||
| 83 | 0 | ▶ | LOGEXIT "invalid section name" unless $section ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | my $s = $ini->{$section} ; | |||||||||||||||||||||||||||
| 85 | 0 | ▶ | LOGEXIT "Missing section [$section]" unless $s ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | _merge_with_template( $s, $ini, $s->{use_template} ) ; | |||||||||||||||||||||||||||
| 87 | 0 | _switch_2_update( $s ); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $s->{ format } //= 'text' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"format"} //= "text"
MC/DC0%0/1
$s->{"format"} //= "text"
$s->{"format"}
Truth table0%0/2
A
A= $s->{"format"}
| |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $s->{ copy } //= '*' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"copy"} //= "*"
MC/DC0%0/1
$s->{"copy"} //= "*"
$s->{"copy"}
Truth table0%0/2
A
A= $s->{"copy"}
| |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | $s->{ copy_every } //= 10_000 ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"copy_every"} //= 10000
MC/DC0%0/1
$s->{"copy_every"} //= 10000
$s->{"copy_every"}
Truth table0%0/2
A
A= $s->{"copy_every"}
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | $s->{ filename } //= 'STDIN' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"filename"} //= "STDIN"
MC/DC0%0/1
$s->{"filename"} //= "STDIN"
$s->{"filename"}
Truth table0%0/2
A
A= $s->{"filename"}
| |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $s->{ table } //= $section ; | ||||||||||||||||||||||||||
|
Condition0%0/3
$s->{"table"} //= $section
MC/DC0%0/2
$s->{"table"} //= $section
$s->{"table"}
$section
Truth table0%0/3
A //= B
A= $s->{"table"}B= $section
| |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | $s->{ quotechar } //= '"' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"quotechar"} //= "\""
MC/DC0%0/1
$s->{"quotechar"} //= "\""
$s->{"quotechar"}
Truth table0%0/2
A
A= $s->{"quotechar"}
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $s->{ reject_data } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"reject_data"} //= ""
MC/DC0%0/1
$s->{"reject_data"} //= ""
$s->{"reject_data"}
Truth table0%0/2
A
A= $s->{"reject_data"}
| |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $s->{ reject_log } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"reject_log"} //= ""
MC/DC0%0/1
$s->{"reject_log"} //= ""
$s->{"reject_log"}
Truth table0%0/2
A
A= $s->{"reject_log"}
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $s->{ lc_messages } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"lc_messages"} //= ""
MC/DC0%0/1
$s->{"lc_messages"} //= ""
$s->{"lc_messages"}
Truth table0%0/2
A
A= $s->{"lc_messages"}
| |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $s->{ lc_numeric } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"lc_numeric"} //= ""
MC/DC0%0/1
$s->{"lc_numeric"} //= ""
$s->{"lc_numeric"}
Truth table0%0/2
A
A= $s->{"lc_numeric"}
| |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $s->{ lc_monetary } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"lc_monetary"} //= ""
MC/DC0%0/1
$s->{"lc_monetary"} //= ""
$s->{"lc_monetary"}
Truth table0%0/2
A
A= $s->{"lc_monetary"}
| |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $s->{ lc_type } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"lc_type"} //= ""
MC/DC0%0/1
$s->{"lc_type"} //= ""
$s->{"lc_type"}
Truth table0%0/2
A
A= $s->{"lc_type"}
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $s->{ lc_time } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"lc_time"} //= ""
MC/DC0%0/1
$s->{"lc_time"} //= ""
$s->{"lc_time"}
Truth table0%0/2
A
A= $s->{"lc_time"}
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $s->{ datestyle } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"datestyle"} //= ""
MC/DC0%0/1
$s->{"datestyle"} //= ""
$s->{"datestyle"}
Truth table0%0/2
A
A= $s->{"datestyle"}
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $s->{ client_encoding } //= '' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"client_encoding"} //= ""
MC/DC0%0/1
$s->{"client_encoding"} //= ""
$s->{"client_encoding"}
Truth table0%0/2
A
A= $s->{"client_encoding"}
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | $s->{copy_columns} = $s->{copy} | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | unless ($s->{only_cols}||$s->{copy_columns}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$s->{"only_cols"} or $s->{"copy_columns"}
MC/DC0%0/2
$s->{"only_cols"} or $s->{"copy_columns"}
$s->{"only_cols"}
$s->{"copy_columns"}
Truth table0%0/3
A or B
A= $s->{"only_cols"}B= $s->{"copy_columns"}
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ( $s->{ format } =~ /^ '? text '?$/ox ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | # format is 'text' | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $s->{null} //= '$$\NA$$' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"null"} //= "\$\$\\NA\$\$"
MC/DC0%0/1
$s->{"null"} //= "\$\$\\NA\$\$"
$s->{"null"}
Truth table0%0/2
A
A= $s->{"null"}
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $s->{null} = '$$'.$s->{null}.'$$' if $s->{null} ne '$$\NA$$'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $s->{ field_sep } //= "\t" ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"field_sep"} //= "\t"
MC/DC0%0/1
$s->{"field_sep"} //= "\t"
$s->{"field_sep"}
Truth table0%0/2
A
A= $s->{"field_sep"}
| |||||||||||||||||||||||||||||
| 113 | }else{ | ||||||||||||||||||||||||||||
| 114 | # format is 'csv' | ||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $s->{null} //= '$$$$' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"null"} //= "\$\$\$\$"
MC/DC0%0/1
$s->{"null"} //= "\$\$\$\$"
$s->{"null"}
Truth table0%0/2
A
A= $s->{"null"}
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $s->{null} = '$$'.$s->{null}.'$$' if $s->{null} ne '$$$$'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $s->{ field_sep } //= ',' ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"field_sep"} //= ","
MC/DC0%0/1
$s->{"field_sep"} //= ","
$s->{"field_sep"}
Truth table0%0/2
A
A= $s->{"field_sep"}
| |||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 17 | ▶ | sub _switch_2_update { | ||||||||||||||||||||||||||
|
Subroutine
_switch_2_update: called CC=28 SCAR=33.4
| |||||||||||||||||||||||||||||
| 124 | 17 | my $s = shift;; | |||||||||||||||||||||||||||
| 125 | # First, some error checking | ||||||||||||||||||||||||||||
| 126 | 17 | ▶ | eval { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 17 | ▶ | $s->{ copy } && $s->{ update } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$s->{"copy"} and $s->{"update"}
MC/DC100%2/2
$s->{"copy"} and $s->{"update"}
$s->{"copy"}
$s->{"update"}
Truth table100%3/3
A and B
A= $s->{"copy"}B= $s->{"update"}
| |||||||||||||||||||||||||||||
| 128 | 16 | ▶ | $s->{ copy } && $s->{ update_columns } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$s->{"copy"} and $s->{"update_columns"}
MC/DC100%2/2
$s->{"copy"} and $s->{"update_columns"}
$s->{"copy"}
$s->{"update_columns"}
Truth table100%3/3
A and B
A= $s->{"copy"}B= $s->{"update_columns"}
| |||||||||||||||||||||||||||||
| 129 | 15 | ▶ | $s->{ copy } && $s->{ update_only } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$s->{"copy"} and $s->{"update_only"}
MC/DC100%2/2
$s->{"copy"} and $s->{"update_only"}
$s->{"copy"}
$s->{"update_only"}
Truth table100%3/3
A and B
A= $s->{"copy"}B= $s->{"update_only"}
| |||||||||||||||||||||||||||||
| 130 | 14 | ▶ | $s->{ copy_columns } && $s->{ update } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$s->{"copy_columns"} and $s->{"update"}
MC/DC100%2/2
$s->{"copy_columns"} and $s->{"update"}
$s->{"copy_columns"}
$s->{"update"}
Truth table100%3/3
A and B
A= $s->{"copy_columns"}B= $s->{"update"}
| |||||||||||||||||||||||||||||
| 131 | 13 | ▶ | $s->{ copy_columns } && $s->{ update_columns } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$s->{"copy_columns"} and $s->{"update_columns"}
MC/DC100%2/2
$s->{"copy_columns"} and $s->{"update_columns"}
$s->{"copy_columns"}
$s->{"update_columns"}
Truth table100%3/3
A and B
A= $s->{"copy_columns"}B= $s->{"update_columns"}
| |||||||||||||||||||||||||||||
| 132 | 12 | ▶ | $s->{ copy_columns } && $s->{ update_only } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$s->{"copy_columns"} and $s->{"update_only"}
MC/DC50%1/2
$s->{"copy_columns"} and $s->{"update_only"}
$s->{"copy_columns"}
$s->{"update_only"}
Truth table66%2/3
A and B
A= $s->{"copy_columns"}B= $s->{"update_only"}
| |||||||||||||||||||||||||||||
| 133 | 11 | ▶ | $s->{ copy_only } && $s->{ update } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$s->{"copy_only"} and $s->{"update"}
MC/DC100%2/2
$s->{"copy_only"} and $s->{"update"}
$s->{"copy_only"}
$s->{"update"}
Truth table100%3/3
A and B
A= $s->{"copy_only"}B= $s->{"update"}
| |||||||||||||||||||||||||||||
| 134 | 10 | ▶ | $s->{ copy_only } && $s->{ update_columns } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$s->{"copy_only"} and $s->{"update_columns"}
MC/DC100%2/2
$s->{"copy_only"} and $s->{"update_columns"}
$s->{"copy_only"}
$s->{"update_columns"}
Truth table100%3/3
A and B
A= $s->{"copy_only"}B= $s->{"update_columns"}
| |||||||||||||||||||||||||||||
| 135 | 9 | ▶ | $s->{ copy_only } && $s->{ update_only } and die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$s->{"copy_only"} and $s->{"update_only"}
MC/DC50%1/2
$s->{"copy_only"} and $s->{"update_only"}
$s->{"copy_only"}
$s->{"update_only"}
Truth table66%2/3
A and B
A= $s->{"copy_only"}B= $s->{"update_only"}
| |||||||||||||||||||||||||||||
| 136 | 8 | 1; | |||||||||||||||||||||||||||
| 137 | } or LOGDIE qq(\tCannot mix "copy" with "update" columns) ; | ||||||||||||||||||||||||||||
| 138 | #TODO "update_only" should populate "update_columns" | ||||||||||||||||||||||||||||
| 139 | 8 | ▶ | $s->{ update_only } and LOGDIE qq(\t"update_only" not implemeted"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | # Should we switch to update mode? | ||||||||||||||||||||||||||||
| 141 | 8 | ▶ | exists $s->{ update_columns } and $s->{mode}='update'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 8 | ▶ | exists $s->{ update_only } and $s->{mode}='update'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 8 | ▶ | exists $s->{ update } and $s->{mode}='update'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | ## key statement | ||||||||||||||||||||||||||||
| 145 | 8 | ▶ | $s->{mode} //= 'copy' ; | ||||||||||||||||||||||||||
|
Condition100%2/2
$s->{"mode"} //= "copy"
MC/DC100%1/1
$s->{"mode"} //= "copy"
$s->{"mode"}
Truth table100%2/2
A
A= $s->{"mode"}
| |||||||||||||||||||||||||||||
| 146 | 8 | ▶ | if ($s->{mode} eq 'update') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 5 | ▶ | $s->{copy_columns} = $s->{update_columns}//$s->{update}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$s->{"update_columns"} // $s->{"update"}
MC/DC0%0/2
$s->{"update_columns"} // $s->{"update"}
$s->{"update_columns"}
$s->{"update"}
Truth table66%2/3
A // B
A= $s->{"update_columns"}B= $s->{"update"}
| |||||||||||||||||||||||||||||
| 148 | 5 | ▶ | $s->{copy_only} = $s->{update_columns}//''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$s->{"update_columns"} // ""
MC/DC100%1/1
$s->{"update_columns"} // ""
$s->{"update_columns"}
Truth table100%2/2
A
A= $s->{"update_columns"}
| |||||||||||||||||||||||||||||
| 149 | 5 | $s->{copy} = $s->{update}; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | 8 | $s->{mode}; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub show_sections { | ||||||||||||||||||||||||||
|
Subroutine
show_sections: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 154 | 0 | my ($conf, $ini) = @_; | |||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $port = ':'. ($ini->{port}||5432) ; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ini->{'port'} || 5432
MC/DC0%0/1
$ini->{'port'} || 5432
$ini->{'port'}
Truth table0%0/2
A
A= $ini->{'port'}
| |||||||||||||||||||||||||||||
| 156 | 0 | my $t = new Text::Table 'SECTION ' , 'TABLE ', | |||||||||||||||||||||||||||
| 157 | 'FILE ' , 'OPERATION' ; | ||||||||||||||||||||||||||||
| 158 | 0 | DEBUG "$ini->{pgsql}{base}\@$ini->{pgsql}{host}$port" ; | |||||||||||||||||||||||||||
| 159 | 0 | ▶ | while (my ($k,$v) = each %$ini) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 0 | my $s = $ini->{$k}; | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | next if $k eq 'pgsql'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | next if exists $s->{template}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | next if $s->{template}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | 0 | add_defaults $ini, $k ; | |||||||||||||||||||||||||||
| 165 | 0 | _switch_2_update $s ; | |||||||||||||||||||||||||||
| 166 | 0 | ▶ | my $file = $s->{filename}||'STDIN'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$s->{'filename'} || 'STDIN'
MC/DC0%0/1
$s->{'filename'} || 'STDIN'
$s->{'filename'}
Truth table0%0/2
A
A= $s->{'filename'}
| |||||||||||||||||||||||||||||
| 167 | #say sprintf '%-18s %-20s', "[$k]", $file ; | ||||||||||||||||||||||||||||
| 168 | 0 | $t->load( [ "[$k]", $s->{table}, $file, $s->{mode} ] ); | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | 0 | print $t; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 5 | 1; | |||||||||||||||||||||||||||
| 174 | __END__ | ||||||||||||||||||||||||||||