| 1 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Name: CMDS.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Purpose: HDB::CMDS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Author: Graciliano M. P. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Modified by: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created: 14/01/2003 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## RCS-ID: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## Copyright: (c) 2002 Graciliano M. P. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## Licence: This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## modify it under the same terms as Perl itself | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package HDB::CMDS ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use HDB::Parser ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use strict qw(vars); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | no warnings ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our $VERSION = '1.0' ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ######## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # VARS # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ######## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | my %args_select = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | table => [qw(table)] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | where => [qw(where w)] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | limit => [qw(limit limite)] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | sort => [qw(sort order)] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | group => [qw(group grop)] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | return => [qw(return ret r)] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | col => [qw(col cols)] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | cache => [[qw(cache)],1] , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | my %DEFAULT_COLS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 'address' => 200 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 'age' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 'bairro' => 30 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'cep' => 9 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 'cidade' => 40 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 'city' => 40 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 'country' => 4 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'data' => 'int(9999999999)' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'date' => 'int(9999999999)' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'descricao' => 'TEXT' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 'email' => 50 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'endereco' => 200 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'estado' => 3 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'fax' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'hits' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'hora' => 8 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'id' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'idade' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'mail' => 50 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 'message' => 'TEXT' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 'msg' => 'TEXT' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'mensagem' => 'TEXT' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 'name' => 40 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 'nick' => 16 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'nome' => 40 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 'pais' => 4 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 'pass' => 16 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 'password' => 16 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 'phone' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 'preco' => 15 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 'price' => 15 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 'senha' => 16 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 'sex' => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 'sexo' => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 'size' => 5 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 'state' => 3 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'tamanho' => 5 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'tel' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'telefone' => 'INTEGER' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'temperatura' => 4 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'time' => 10 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'titulo' => 250 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'title' => 250 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'uf' => 3 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 'uid' => 8 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 'url' => 250 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 'username' => 16 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'user' => 16 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 'zip' => 9 , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | my @DEFAULT_TYPES = qw(* TEXT INT FLOAT BOOL) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | my %DEFAULT_MOD = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 'MySQL' => 'mysql' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 'SQLite' => 'sqlite' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 'Oracle' => 'Oracle' , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # PREDEFINED_COLS # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub predefined_columns { return( %DEFAULT_COLS ) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
predefined_columns: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # DEFAULT_TYPES # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub default_types { return( @DEFAULT_TYPES ) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_types: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # DEFAULT_MOD # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub default_mod { return( %DEFAULT_MOD ) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_mod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ########### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # ALIASES # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ########### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub sel { &select ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sel: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub cols { &names ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cols: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub creat { &create ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
creat: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub create_table { &create ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_table: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub predefined_cols { &predefined_columns ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
predefined_cols: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub sql { $_[0]->{sql} ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sql: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # SELECT # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub select { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select: not called CC=32 SCAR=69.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my (undef , $where , @args) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ($_[0] =~ /^table$/i) { @args = @_ ; $where = undef ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ▶ | elsif ($#_ >= 2 && $#_ <= 3 && ( ref $_[2] || $_[2] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$#_ >= 2 and $#_ <= 3 and ref $_[2] || $_[2] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
$#_ >= 2 and $#_ <= 3
ref $_[2] or $_[2] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
MC/DC0%0/4
$#_ >= 2 and $#_ <= 3 and ref $_[2] || $_[2] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
$#_ >= 2
$#_ <= 3
ref $_[2]
$_[2] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
Truth table0%0/5
A and B and C or D
A= $#_ >= 2B= $#_ <= 3C= ref $_[2]D= $_[2] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (ref $_[2]) { @args = HDB::CORE::parse_ref($_[2]) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | elsif ($#_ == 2) { @args = ('return' , $_[2]) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ▶ | elsif ($#_ == 1 && $_[1] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$#_ == 1 and $_[1] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
MC/DC0%0/2
$#_ == 1 and $_[1] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
$#_ == 1
$_[1] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
Truth table0%0/3
A and B
A= $#_ == 1B= $_[1] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | @args = ('return' , $_[1]) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $where = undef ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($#_ >= 2 && $where =~ /^(?:cache|col|cols|grop|group|limit|limite|order|r|ret|return|sort|table|w|where)$/si) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$#_ >= 2 and $where =~ /^(?:cache|col|cols|grop|group|limit|limite|order|r|ret|return|sort|table|w|where)$/is
MC/DC0%0/2
$#_ >= 2 and $where =~ /^(?:cache|col|cols|grop|group|limit|limite|order|r|ret|return|sort|table|w|where)$/is
$#_ >= 2
$where =~ /^(?:cache|col|cols|grop|group|limit|limite|order|r|ret|return|sort|table|w|where)$/is
Truth table0%0/3
A and B
A= $#_ >= 2B= $where =~ /^(?:cache|col|cols|grop|group|limit|limite|order|r|ret|return|sort|table|w|where)$/is
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | unshift (@args, $where) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $where = undef ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my %args ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | &HDB::CORE::parse_args(\%args , \%args_select , @args) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $args{table} = $_[0] if !defined $args{table} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $args{where} = $where if !defined $args{where} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $args{table} = _format_table_name($args{table}) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if (! defined $args{return}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ( $_[-1] =~ /^(?:(?:n|names?|c|cols?|columns?)\s*[,;]*\s*)?(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/i ) { $args{return} = $_[-1] ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $this->{return} = $args{return} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $this->{sql} = undef ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my ($cols , $db_max) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ($args{col} =~ /^\s*([<>])\s*([\w\.]+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $db_max = $1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $cols = $2 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | else { $cols = $args{col} ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ($db_max) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ($db_max eq '>') { $db_max = 'max' ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | elsif ($db_max eq '<') { $db_max = 'min' ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($cols eq '') { $cols = "$db_max(ID) as ID" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | else { $cols = "$db_max($cols) as $cols" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | elsif ($cols eq "") { $cols = '*' ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $cols =~ s/^\s*,//s ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $cols =~ s/,\s*$//s ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $where = &HDB::Parser::Parse_Where($args{where},$this) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $group ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ( $args{group} ) { $group = "GROUP BY $args{group}" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $sort ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( $args{sort} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ($sort) = ( $args{sort} =~ /([\w\.]+)/gs ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $sort = "ORDER BY $sort" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ($args{sort} =~ /</s) { $sort .= ' DESC' ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | #elsif (! defined $args{sort} ) { $sort = "ORDER BY ID" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $limit ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($args{limit} ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my ($sz,$init) = ( $args{limit} =~ /(\d+)(?:\D+(\d+)|)/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $into_where ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ($limit , $into_where) = $this->LIMIT($sz,$init) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ( $into_where ) { $where = "$where AND ($into_where)" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $this->{sql} = "SELECT $cols FROM $args{table}" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | $this->{sql} .= " $where" if $where ne '' ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $this->{sql} .= " $group" if $group ne '' ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | $this->{sql} .= " $sort" if $sort ne '' ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | $this->{sql} .= " $limit" if $limit ne '' ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | eval{ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $this->{sth} = $this->dbh->prepare( $this->{sql} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $this->{sth}->{ShowErrorStatement} = 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $this->{sth}->execute ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $this->{sth}->err ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | return $this->Error("SQL error: $this->{sql}") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return $this->Return( $args{return} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # INSERT # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub insert { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my ($table , @up) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ($#_ == 1) { @up = HDB::CORE::parse_ref($_[1]) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | return $this->Error('Invalid table!') if !$table ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return $this->Error('Nothing to insert!') if !@up ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my @names = $this->names($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my @cols ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if (ref($_[1]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my %up = @up ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | @up = () ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | foreach my $names_i ( @names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (defined $up{$names_i}) { push(@up , $up{$names_i}) ; push(@cols , $names_i) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | elsif (defined $up{uc($names_i)}) { push(@up , $up{uc($names_i)}) ; push(@cols , $names_i) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | elsif (defined $up{lc($names_i)}) { push(@up , $up{lc($names_i)}) ; push(@cols , $names_i) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | elsif (defined $up{"\u\L$names_i\E"}) { push(@up , $up{"\u\L$names_i\E"}) ; push(@cols , $names_i) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | else { @cols = @names ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | foreach my $up_i ( @up ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if (ref($up_i) eq 'HASH') { $up_i = &HDB::Encode::Pack_HASH($up_i) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | elsif (ref($up_i) eq 'ARRAY') { $up_i = &HDB::Encode::Pack_ARRAY($up_i) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | &HDB::Parser::filter_null_bytes($up_i) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my @ins_pnt = ('?') x @up ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $this->{sql} = "INSERT INTO $table (". join(',',@cols) .") VALUES (". join(',',@ins_pnt) .")" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | eval { $this->{sth} = $this->dbh->prepare( $this->{sql} ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $this->{sth}->{ShowErrorStatement} = 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $this->lock_table($table) if $this->{SQL}{LOCK_TABLE} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $this->{sth}->execute(@up) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $this->unlock_table($table) if $this->{SQL}{LOCK_TABLE} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $this->{sth}->err ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | return $this->Error("SQL error: $this->{sql}\nERROR MSG:\n$@") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | $this->ON_INSERT(\@cols,\@up) if $this->can('ON_INSERT') ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # UPDATE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my ($table , $where , %up) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ($#_ == 2) { %up = HDB::CORE::parse_ref($_[2]) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if (! $table) { $this->Error('Invalid table!') ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if (! %up) { $this->Error('Nothing to update!') ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $where = &HDB::Parser::Parse_Where($where,$this) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my ($set_cols,@up) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my @names = $this->names($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | foreach my $names_i ( @names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if (defined $up{$names_i}) { push(@up , $up{$names_i}) ; $set_cols .= "$names_i = ? , " ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | elsif (defined $up{uc($names_i)}) { push(@up , $up{uc($names_i)}) ; $set_cols .= "\U$names_i\E = ? , " ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | elsif (defined $up{lc($names_i)}) { push(@up , $up{lc($names_i)}) ; $set_cols .= "\L$names_i\E = ? , " ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | elsif (defined $up{"\u\L$names_i\E"}) { push(@up , $up{"\u\L$names_i\E"}) ; $set_cols .= "\u\L$names_i\E = ? , " ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | return if !@up ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | foreach my $up_i ( @up ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if (ref($up_i) eq 'HASH') { $up_i = &HDB::Encode::Pack_HASH($up_i) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | elsif (ref($up_i) eq 'ARRAY') { $up_i = &HDB::Encode::Pack_ARRAY($up_i) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | &HDB::Parser::filter_null_bytes($up_i) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $set_cols =~ s/ , $// ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $this->{sql} = "UPDATE $table SET $set_cols $where" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | eval { $this->{sth} = $this->dbh->prepare( $this->{sql} ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $this->lock_table($table) if $this->{SQL}{LOCK_TABLE} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $this->{sth}->execute(@up) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $this->unlock_table($table) if $this->{SQL}{LOCK_TABLE} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | return $this->Error("SQL error: $this->{sql}\nERROR MSG:\n$@") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # DELETE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my ($table , $where) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if (! $table) { $this->Error('Invalid table!') ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $where = &HDB::Parser::Parse_Where($where,$this) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $this->{sql} = "DELETE FROM $table $where" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | $this->lock_table($table) if $this->{SQL}{LOCK_TABLE} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $this->dbh->do( $this->{sql} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $this->unlock_table($table) if $this->{SQL}{LOCK_TABLE} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | return $this->Error("SQL error: $this->{sql}\nERROR MSG:\n$@") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # CREATE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my ($table , @cols) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ($#_ == 1) { @cols = HDB::CORE::parse_ref($_[1]) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | if (! $table) { $this->Error('Invalid table!') ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | if (! @cols) { $this->Error('Cols not paste!') ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my %tables = map { ("\L$_\E") => 1 } ($this->tables) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if ( $tables{"\L$table\E"} ) { return ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my (%cols,@order) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | for (my $i = 0 ; $i <= $#cols ; $i+=1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $name = $cols[$i] ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $type ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if (ref($name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $name = HDB::CORE::parse_ref($name) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $type = 'DEFAULT' ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | else { $type = $cols[$i+1] ; $i++ ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $is_primary ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if ($name =~ /^\s*\*/) { $name =~ s/^\s*\*\s*//gs ; $is_primary = 1 ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $name =~ s/^\s+//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $name =~ s/\s+$//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $type = $this->get_type( $type , $name ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if ($is_primary) { $type = $this->Set_PRIMARYKEY($type) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | push(@order , $name) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $cols{$name} = $type ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if (ref($_[1]) eq 'HASH') { @order = sort @order ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if (! $cols{id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | push(@order , 'id') ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $cols{id} = $this->AUTOINCREMENT() ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if ($cols{id} !~ /PRIMARY[\s_-]*KEY/si) { $cols{id} .= ' PRIMARY KEY' ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $this->{sql} = "CREATE TABLE $table (" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $c ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | foreach my $order_i ( @order ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (++$c > 1) { $this->{sql} .= " , " ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $this->{sql} .= "$order_i $cols{$order_i}" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $this->{sql} .= ")" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | eval { $this->dbh->do( $this->{sql} ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | return $this->Error("SQL error: $this->{sql}\nERROR MSG:\n$@") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | $this->ON_CREATE($table,\%cols,\@order) if $this->can('ON_CREATE') ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ####### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # CMD # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ####### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | sub cmd { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $this->{sql} = $_[0] ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $return = $_[1] ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | eval{ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $this->{sth} = $this->dbh->prepare( $this->{sql} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $this->{sth}->execute ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | return $this->Error("SQL error: $this->{sql}") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | return $this->Return( $return ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ######### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # NAMES # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | ######### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | sub names { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my ( $table ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if (! $table) { return $this->Error('Invalid table!') ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | elsif ( $this->{CACHE}{names}{$table} ) { return @{ $this->{CACHE}{names}{$table} } ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if ( $this->{SQL}{SHOW} ) { $this->{sql} = "SHOW COLUMNS FROM $table" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | elsif ( $this->{SQL}{LIMIT} ) { $this->{sql} = "SELECT * FROM $table LIMIT 1" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | else { $this->{sql} = "SELECT * FROM $table" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | eval{ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $this->{sth} = $this->dbh->prepare( $this->{sql} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $this->{sth}->execute ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | return $this->Error("SQL error: $this->{sql}") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my @names ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if ( $this->{SQL}{SHOW} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | while (my $ref = $this->{sth}->fetchrow_arrayref) { push(@names , @$ref[0]) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ## substr() to make a copy of the value and avoid DBI bug! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | eval { @names = map { substr($_ , 0) } @{ $this->{sth}->{'NAME'} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | #eval { @names = @{ $this->{sth}->{'NAME'} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | return () if !@names ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | if ( $this->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $this->{CACHE}{names}{$table} = \@names ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | return @names ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | # TABLES # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | sub tables { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tables: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | my @tables = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $_ =~ s/.*\.//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $_ =~ s/(['"`])(.*)\1/$2/gs; ## some DB return quoted. | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $_ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } $this->dbh->tables() ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | return( sort @tables ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # TABLES_HASH # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | sub tables_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tables_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | return map { $_ => 1 } $_[0]->tables ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # TABLE_EXISTS # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | sub table_exists { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_exists: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my %tables = $_[0]->tables ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | return 1 if $tables{$_[1]} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # TABLE_COLUMNS # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | sub table_columns { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_columns: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my ( $table ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if (! $table) { $this->Error('Invalid table!') ; return ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | return $this->dbh->table_info($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | ######## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # DROP # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ######## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | sub drop { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
drop: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my ( $table ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | if (! $table) { $this->Error('Invalid table!') ; return ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my %tables = map { ("\L$_\E") => 1 } ($this->tables) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if (! $tables{"\L$table\E"} ) { return ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $this->flush_table_cache($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | eval{ $this->dbh->do("DROP TABLE $table") }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | return $this->Error("DROP ERROR: table $table") if $@ ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | $this->ON_DROP($table) if $this->can('ON_DROP') ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | return 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | ############## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # DUMP_TABLE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | ############## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | sub dump_table { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_table: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my ( $table ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | if (!$table) { $this->Error('Invalid table!') ; return ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my $dump ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $dump .= "TABLE $table:\n\n" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my %cols = $this->table_columns($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my @cols = $this->names($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | foreach my $Key (@cols) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $dump .= " $Key = $cols{$Key}\n" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $dump .= "\nROWS:\n\n" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my @sel = $this->select( $table , '@$' ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | foreach my $sel_i ( @sel ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | $dump .= "$sel_i\n" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | return $dump ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # FLUSH_CACHE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | sub flush_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush_cache: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | if ( !$_[0]->{CACHE} ) { return ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my @sth = $_[0]->_get_cache_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | delete $_[0]->{CACHE} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | foreach my $sth_i ( @sth ) { $sth_i->finish if $sth_i ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | return 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | ##################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | # FLUSH_TABLE_CACHE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ##################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | sub flush_table_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush_table_cache: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | my ( $table ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $table = _format_table_name($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | if ( !$this->{CACHE} ) { return ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my @sth = $this->_get_cache_table_sth($table) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | delete $this->{CACHE}{names}{$table} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | delete $this->{CACHE}{insert}{$table} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | delete $this->{CACHE}{update}{$table} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | foreach my $sth_i ( @sth ) { $sth_i->finish if $sth_i ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | return 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | ###################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # _FORMAT_TABLE_NAME # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | ###################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | sub _format_table_name { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_table_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my ( $table ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $table =~ s/(?:\.|::)/_/gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $table =~ s/[^\w\.]//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | return $table ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | ####################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # _FORMAT_COLUMN_NAME # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | ####################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | sub _format_column_name { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_column_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my ( $col ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | $col =~ s/(?:\.|::)/_/gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | $col =~ s/[^\w\.]//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | return $col ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | ################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # _GET_CACHE_STH # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | ################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | sub _get_cache_sth { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_cache_sth: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $cache = $_[0]->{CACHE} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my @types = qw(insert update) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my @sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | foreach my $types_i ( @types ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | foreach my $Key ( keys %{$$cache{$types_i}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | push(@sth , $$cache{$types_i}{$Key}{sth} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | return @sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | ######################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # _GET_CACHE_TABLE_STH # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | ######################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | sub _get_cache_table_sth { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_cache_table_sth: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | my $cache = $_[0]->{CACHE} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my $table = $_[1] ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my @types = qw(insert update) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | my @sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | foreach my $types_i ( @types ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | push(@sth , $$cache{$types_i}{$table}{sth} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | return @sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | ############## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # _UNDEF_STH # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | ############## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | sub _undef_sth { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_undef_sth: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | if ( $_[0]->{sth} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | $_[0]->{sth}->finish ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | $_[0]->{sth} = undef ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # RETURN # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | sub Return { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Return: not called CC=26 SCAR=65.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my ( $return ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my $ret_names ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $return =~ s/\s//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | if ($return =~ /^(?:n|c)/si ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $ret_names = 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | $return =~ s/[^\$\@\%<>]//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | if ($return !~ /^(?:\$?[\$\@\%]{1,2}|<[\$\@\%]>)$/ ) { $return = '$' ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | $return =~ s/^\$\$\%$/\$\$\@/ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $return =~ s/^\%\%$/\$\%/ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | my $sth = $_[1] || $this->{sth} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[1] || $this->{'sth'}
MC/DC0%0/2
$_[1] || $this->{'sth'}
$_[1]
$this->{'sth'}
Truth table0%0/3
A || B
A= $_[1]B= $this->{'sth'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | return undef if !$sth ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | if ($return =~ /<\s*([\$\@\%])\s*>\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | my $type = $1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | local(*HANDLE); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | tie(*HANDLE, 'HDB::CMDS::TieHandle',$sth,$type) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | return( \*HANDLE ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | my $ret_type ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | if ($return =~ /\@$/) { $ret_type = 1 ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | elsif ($return =~ /\%$/) { $ret_type = 2 ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | my @names ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | eval{ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | my $names = $sth->{'NAME'} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | @names = @{$names} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | if (! @names) { $this->_undef_sth ; return undef ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | my @rows ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | while (my $ref = $sth->fetchrow_arrayref) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | foreach my $ref_i ( @$ref ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | &HDB::Parser::unfilter_null_bytes($ref_i) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | ▶ | if ( &HDB::Encode::Is_Packed_HASH($ref_i) ) { $ref_i = &HDB::Encode::UnPack_HASH($ref_i) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | elsif ( &HDB::Encode::Is_Packed_ARRAY($ref_i) ) { $ref_i = &HDB::Encode::UnPack_ARRAY($ref_i) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | if ($ret_type == 1) { push(@rows , [@$ref]) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | elsif ($ret_type == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | my %hash ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | for my $i (0..$#names) { $hash{ $names[$i] } = $$ref[$i] ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | push(@rows , \%hash) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | else { push(@rows , join("::" , @$ref ) ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | $this->_undef_sth ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | my @ret_names ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | if ($ret_names) { @ret_names = \@names ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | if ($return =~ /^[\@\%\$]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | if (wantarray) { return( @ret_names , @rows ) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | else { return( $rows[0] ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | elsif ($return =~ /^\$\$$/) { return( @ret_names , $rows[0] ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | elsif ($return =~ /^\$\@$/) { return( @ret_names , @{ $rows[0] } ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | elsif ($return =~ /^\$\%$/) { return( @ret_names , %{ $rows[0] } ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | elsif ($return =~ /^\$\$\@$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | if ( ref( @{$rows[0]}[0] ) eq 'HASH' ) { return( @ret_names , %{@{$rows[0]}[0]} ) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | elsif ( ref( @{$rows[0]}[0] ) eq 'ARRAY' ) { return( @ret_names , @{@{$rows[0]}[0]} ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | else { return( @ret_names , @{ $rows[0] } ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | elsif ($return =~ /^\@[\@\%\$]$/) { return( @ret_names , @rows ) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | # $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # @ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | # % | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | # @% | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | # %% | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ############ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | # GET_TYPE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | ############ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | sub get_type { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_type: not called CC=40 SCAR=74.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my ( $type , $name ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $type =~ s/^\s+//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | $type =~ s/\s+$//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | ## * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | if ($type =~ /^(?:\*|)$/s) { $type = 'TEXT' ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | ## TEXT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | if ($type eq 'TEXT' || $type =~ /^(?:TEXT\s*)?(\d+|\(\s*\d+\s*\))$/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type eq "TEXT" or $type =~ /^(?:TEXT\s*)?(\d+|\(\s*\d+\s*\))$/s
MC/DC0%0/2
$type eq "TEXT" or $type =~ /^(?:TEXT\s*)?(\d+|\(\s*\d+\s*\))$/s
$type eq "TEXT"
$type =~ /^(?:TEXT\s*)?(\d+|\(\s*\d+\s*\))$/s
Truth table0%0/3
A or B
A= $type eq "TEXT"B= $type =~ /^(?:TEXT\s*)?(\d+|\(\s*\d+\s*\))$/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | my $sz = $1 ; $sz =~ s/\D//gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | $sz = 65535 if $sz eq '' ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | if ( !$this->Accept_Type('TEXT') ) { $type = $this->Type_TEXT($sz) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | if ($sz == 0) { $type = "INTEGER" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | elsif ($sz <= 255) { $type = "VARCHAR($sz)" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | elsif ($sz <= 65535 ) { $type = 'TEXT' ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | elsif ($sz <= 16777215 ) { $type = 'MEDIUMTEXT' ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | elsif ($sz <= 4294967295 ) { $type = 'LONGTEXT ' ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | if ( !$this->Accept_Type($type) ) { $type = $this->Type_TEXT($sz) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | ## INTEGER | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | if ($type =~ /^(?:INTEGER|INT)\s*(?:\(?([\+\-]?\d+|\w+)\)?|)$/si) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | my $sz = $1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | if ( !$this->Accept_Type('INTEGER') ) { $type = $this->Type_INTEGER($sz) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | if (!$sz) { $type = "INTEGER" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | elsif ($sz =~ /^(?:t|tin|shor)/i) { $type = "TINYINT" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | elsif ($sz =~ /^(?:s|sma)/i) { $type = "SMALLINT" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | elsif ($sz =~ /^(?:m|med)/i) { $type = "MEDIUMINT" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | elsif ($sz =~ /^(?:b|big)/i) { $type = "BIGINT" ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | elsif ($sz =~ /^[\+\-]?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if ($sz >= -127 && $sz <= 127) { $type = "TINYINT" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/3
$sz >= -127 and $sz <= 127
MC/DC0%0/2
$sz >= -127 and $sz <= 127
$sz >= -127
$sz <= 127
Truth table0%0/3
A and B
A= $sz >= -127B= $sz <= 127
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | elsif ($sz >= -32768 && $sz <= 32767) { $type = "SMALLINT" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sz >= -32768 and $sz <= 32767
MC/DC0%0/2
$sz >= -32768 and $sz <= 32767
$sz >= -32768
$sz <= 32767
Truth table0%0/3
A and B
A= $sz >= -32768B= $sz <= 32767
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | elsif ($sz >= -8388608 && $sz <= 8388607) { $type = "MEDIUMINT" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sz >= -8388608 and $sz <= 8388607
MC/DC0%0/2
$sz >= -8388608 and $sz <= 8388607
$sz >= -8388608
$sz <= 8388607
Truth table0%0/3
A and B
A= $sz >= -8388608B= $sz <= 8388607
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | elsif ($sz >= -2147483648 && $sz <= 2147483647) { $type = "INTEGER" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sz >= '-2147483648' and $sz <= 2147483647
MC/DC0%0/2
$sz >= '-2147483648' and $sz <= 2147483647
$sz >= '-2147483648'
$sz <= 2147483647
Truth table0%0/3
A and B
A= $sz >= '-2147483648'B= $sz <= 2147483647
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | elsif ($sz < -2147483648 || $sz > 2147483647) { $type = "BIGINT" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sz < '-2147483648' or $sz > 2147483647
MC/DC0%0/2
$sz < '-2147483648' or $sz > 2147483647
$sz < '-2147483648'
$sz > 2147483647
Truth table0%0/3
A or B
A= $sz < '-2147483648'B= $sz > 2147483647
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | if (! $this->Accept_Type($type)) { $type = $this->Type_INTEGER($sz) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | ## FLOAT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | elsif ($type =~ /^(\s*[\+\-]\s*(?:FLOATING|FLOAT|DOUBLE))\s*(?:\((.*?)\)|())$/si) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | $type = $this->Type_FLOAT($1,$2) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | ## INT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | elsif ($type =~ /\w+INT$/si) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | if (! $this->Accept_Type($type)) { $type = 'INTEGER' ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ## BOOLEAN | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | elsif ($type =~ /^(?:boolean|boo?l)$/si) { $type = 'BOOLEAN' ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | ## AUTO | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | elsif ($type =~ /^(?:AUTOINCREMENT|AUTO)$/si) { $type = $this->AUTOINCREMENT() ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | ## DEF | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | elsif ($type =~ /^(?:DEFAULT|DEF)$/si) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | $type = $DEFAULT_COLS{$name} || 'TEXT' ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$DEFAULT_COLS{$name} || 'TEXT'
MC/DC0%0/1
$DEFAULT_COLS{$name} || 'TEXT'
$DEFAULT_COLS{$name}
Truth table0%0/2
A
A= $DEFAULT_COLS{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | $type = $this->get_type($type) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | ## TYPE MASK: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | if ( $this->{SQL}{TYPES_MASK} && $this->{SQL}{TYPES_MASK}{$type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$this->{"SQL"}{"TYPES_MASK"} and $this->{"SQL"}{"TYPES_MASK"}{$type}
MC/DC0%0/2
$this->{"SQL"}{"TYPES_MASK"} and $this->{"SQL"}{"TYPES_MASK"}{$type}
$this->{"SQL"}{"TYPES_MASK"}
$this->{"SQL"}{"TYPES_MASK"}{$type}
Truth table0%0/3
A and B
A= $this->{"SQL"}{"TYPES_MASK"}B= $this->{"SQL"}{"TYPES_MASK"}{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $type = $this->{SQL}{TYPES_MASK}{$type} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | return( $type ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | ################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | # SET_PRIMARYKEY # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | ################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | ▶ | sub Set_PRIMARYKEY { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Set_PRIMARYKEY: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | my ( $type ) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | my $primarykey = $this->PRIMARYKEY() ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my $primarykey_re = $primarykey ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | $primarykey_re =~ s/\s+/\\s\+/gs ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | if ($type !~ /$primarykey_re/si) { $type .= " $primarykey" ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | return( $type ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | # ACCEPT_TYPE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | ############### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | sub Accept_Type { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Accept_Type: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my $type = "\L$_[0]\E" ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | ▶ | if (ref($this->{SQL}{TYPES}) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | my %types = map { ("\L$_\E") => 1 } @{ $this->{SQL}{TYPES} } ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | $this->{SQL}{TYPES} = \%types ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | if ( $this->{SQL}{TYPES}{$type} || $this->{SQL}{TYPES}{'*'} ) { return( 1 ) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$this->{"SQL"}{"TYPES"}{$type} or $this->{"SQL"}{"TYPES"}{"*"}
MC/DC0%0/2
$this->{"SQL"}{"TYPES"}{$type} or $this->{"SQL"}{"TYPES"}{"*"}
$this->{"SQL"}{"TYPES"}{$type}
$this->{"SQL"}{"TYPES"}{"*"}
Truth table0%0/3
A or B
A= $this->{"SQL"}{"TYPES"}{$type}B= $this->{"SQL"}{"TYPES"}{"*"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | return( undef ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | ######################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | # HDB::CMDS::TIEHANDLE # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | ######################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | package HDB::CMDS::TieHandle ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | sub TIEHANDLE { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | my $class = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my $this = { sth => $_[0] , type => $_[1] } ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | bless($this , $class) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | ▶ | sub READLINE { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
READLINE: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | my $this = shift ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | my $sth = $this->{sth} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | if ($this->{type} eq "\$") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | my $ref = $sth->fetchrow_arrayref ; return if !$ref ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | return( join("::" , @$ref ) ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | elsif ($this->{type} eq "\@") { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | my $ref = $sth->fetchrow_arrayref ; return if !$ref ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | foreach my $ref_i ( @$ref ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | &HDB::Parser::unfilter_null_bytes($ref_i) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | if ( &HDB::Encode::Is_Packed_HASH($ref_i) ) { $ref_i = &HDB::Encode::UnPack_HASH($ref_i) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | elsif ( &HDB::Encode::Is_Packed_ARRAY($ref_i) ) { $ref_i = &HDB::Encode::UnPack_ARRAY($ref_i) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | return( @$ref ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | elsif ($this->{type} eq "\%") { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | ▶ | my $ref = $sth->fetchrow_hashref ; return if !$ref ; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | foreach my $Key ( keys %$ref ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | &HDB::Parser::unfilter_null_bytes($$ref{$Key}) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | if ( &HDB::Encode::Is_Packed_HASH($$ref{$Key}) ) { $$ref{$Key} = &HDB::Encode::UnPack_HASH($$ref{$Key}) ;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | elsif ( &HDB::Encode::Is_Packed_ARRAY($$ref{$Key}) ) { $$ref{$Key} = &HDB::Encode::UnPack_ARRAY($$ref{$Key}) ;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | return( %$ref ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | return ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | ####### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | # END # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | ####### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||