| 1 | package SQL::Eval; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | ######################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # This module is copyright (c), 2001,2005 by Jeff Zucker. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # This module is copyright (c), 2007-2020 by Jens Rehsack. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # It may be freely distributed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # See below for help (search for SYNOPSIS) | ||||||||||||||||||||||||||||||||||||||||||
| 12 | ######################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | require 5.008; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 16 | ▶ | use warnings FATAL => "all"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 16 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 16 | $VERSION = '1.414'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 16 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | sub new($) | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 4643 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 4643 | my ( $proto, $attr ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 4643 | my ($self) = {%$attr}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 4643 | ▶ | bless( $self, ( ref($proto) || $proto ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | sub param($;$) | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 12242 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
param: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 12242 | ▶ | $_[1] < 0 and croak "Illegal parameter number: $_[1]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 12242 | ▶ | @_ == 3 and return $_[0]->{params}->[ $_[1] ] = $_[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 12242 | $_[0]->{params}->[ $_[1] ]; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | sub params(;$) | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 4443 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
params: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 4443 | ▶ | @_ == 2 and return $_[0]->{params} = $_[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | $_[0]->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4808 | ▶ | sub table($) { $_[0]->{tables}->{ $_[1] } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | sub column($$) { $_[0]->table( $_[1] )->column( $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
column: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 224 | ▶ | sub _gen_access_fastpath($) { $_[0]->table( $_[1] )->_gen_access_fastpath() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen_access_fastpath: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | package SQL::Eval::Table; | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 16 | ▶ | use warnings FATAL => "all"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 16 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 16 | ▶ | use Params::Util qw(_ARRAY0 _HASH0); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | sub new($) | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 83 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=23.4
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 83 | my ( $proto, $attr ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 83 | my ($self) = {%$attr}; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 83 | ▶ | defined( $self->{col_names} ) and defined( _ARRAY0( $self->{col_names} ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"col_names"} and defined &_ARRAY0($self->{"col_names"})
MC/DC0%0/2
defined $self->{"col_names"} and defined &_ARRAY0($self->{"col_names"})
defined $self->{"col_names"}
defined &_ARRAY0($self->{"col_names"})
Truth table33%1/3
A and B
A= defined $self->{"col_names"}B= defined &_ARRAY0($self->{"col_names"})
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | or croak("attribute 'col_names' must be defined as an array"); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 83 | ▶ | exists( $self->{col_nums} ) or $self->{col_nums} = _map_colnums( $self->{col_names} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 83 | ▶ | defined( $self->{col_nums} ) and defined( _HASH0( $self->{col_nums} ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"col_nums"} and defined &_HASH0($self->{"col_nums"})
MC/DC0%0/2
defined $self->{"col_nums"} and defined &_HASH0($self->{"col_nums"})
defined $self->{"col_nums"}
defined &_HASH0($self->{"col_nums"})
Truth table33%1/3
A and B
A= defined $self->{"col_nums"}B= defined &_HASH0($self->{"col_nums"})
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | or croak("attribute 'col_nums' must be defined as a hash"); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 83 | ▶ | $self->{capabilities} = {} unless ( defined( $self->{capabilities} ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 83 | ▶ | bless( $self, ( ref($proto) || $proto ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub _map_colnums | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 73 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_colnums: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 73 | my $col_names = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 73 | my %col_nums; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 73 | $col_nums{ $col_names->[$_] } = $_ for ( 0 .. scalar @$col_names - 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 73 | \%col_nums; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub row() { $_[0]->{row} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | sub column($) { $_[0]->{row}->[ $_[0]->column_num( $_[1] ) ] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
column: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 12994 | ▶ | sub column_num($) { $_[0]->{col_nums}->{ $_[1] }; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
column_num: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub col_nums() { $_[0]->{col_nums} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
col_nums: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 4711 | ▶ | sub col_names() { $_[0]->{col_names}; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
col_names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | sub _gen_access_fastpath($) | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 394 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen_access_fastpath: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 394 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | $self->can("column") == SQL::Eval::Table->can("column") | ||||||||||||||||||||||||||||||||||||||||||
| 91 | && $self->can("column_num") == SQL::Eval::Table->can("column_num") | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 16951 | ▶ | ? sub { $self->{row}->[ $self->{col_nums}->{ $_[0] } ] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 394 | ▶ | : sub { $self->column( $_[0] ) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition66%2/3
$self->can("column") == "SQL::Eval::Table"->can("column") and $self->can("column_num") == "SQL::Eval::Table"->can("column_num")
MC/DC50%1/2
$self->can("column") == "SQL::Eval::Table"->can("column") and $self->can("column_num") == "SQL::Eval::Table"->can("column_num")
$self->can("column") == "SQL::Eval::Table"->can("column")
$self->can("column_num") == "SQL::Eval::Table"->can("column_num")
Truth table66%2/3
A and B
A= $self->can("column") == "SQL::Eval::Table"->can("column")B= $self->can("column_num") == "SQL::Eval::Table"->can("column_num")
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | sub capability($) | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 8709 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capability: called CC=15 SCAR=28.7
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 8709 | my ( $self, $capname ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 8709 | ▶ | exists $self->{capabilities}->{$capname} and return $self->{capabilities}->{$capname}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | $capname eq "insert_new_row" | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 57 | ▶ | and $self->{capabilities}->{insert_new_row} = $self->can("insert_new_row"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | $capname eq "delete_one_row" | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 57 | ▶ | and $self->{capabilities}->{delete_one_row} = $self->can("delete_one_row"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | $capname eq "delete_current_row" | ||||||||||||||||||||||||||||||||||||||||||
| 106 | and $self->{capabilities}->{delete_current_row} = | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 57 | ▶ | ( $self->can("delete_current_row") and $self->capability("inplace_delete") ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->can('delete_current_row') && $self->capability('inplace_delete')
MC/DC0%0/2
$self->can('delete_current_row') && $self->capability('inplace_delete')
$self->can('delete_current_row')
$self->capability('inplace_delete')
Truth table33%1/3
A && B
A= $self->can('delete_current_row')B= $self->capability('inplace_delete')
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | $capname eq "update_one_row" | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 57 | ▶ | and $self->{capabilities}->{update_one_row} = $self->can("update_one_row"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | $capname eq "update_current_row" | ||||||||||||||||||||||||||||||||||||||||||
| 111 | and $self->{capabilities}->{update_current_row} = | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 57 | ▶ | ( $self->can("update_current_row") and $self->capability("inplace_update") ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->can('update_current_row') && $self->capability('inplace_update')
MC/DC0%0/2
$self->can('update_current_row') && $self->capability('inplace_update')
$self->can('update_current_row')
$self->capability('inplace_update')
Truth table33%1/3
A && B
A= $self->can('update_current_row')B= $self->capability('inplace_update')
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | $capname eq "update_specific_row" | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 57 | ▶ | and $self->{capabilities}->{update_specific_row} = $self->can("update_specific_row"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | $capname eq "rowwise_update" | ||||||||||||||||||||||||||||||||||||||||||
| 117 | and $self->{capabilities}->{rowwise_update} = ( | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 57 | ▶ | $self->capability("update_one_row") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->capability('update_one_row') || $self->capability('update_current_row') || $self->capability('update_specific_row')
$self->capability("update_one_row") or $self->capability("update_current_row")
MC/DC0%0/3
$self->capability('update_one_row') || $self->capability('update_current_row') || $self->capability('update_specific_row')
$self->capability("update_one_row")
$self->capability("update_current_row")
$self->capability('update_specific_row')
Truth table0%0/4
A or B || C
A= $self->capability("update_one_row")B= $self->capability("update_current_row")C= $self->capability('update_specific_row')
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | or $self->capability("update_current_row") | ||||||||||||||||||||||||||||||||||||||||||
| 120 | or $self->capability("update_specific_row") | ||||||||||||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 122 | $capname eq "rowwise_delete" | ||||||||||||||||||||||||||||||||||||||||||
| 123 | and $self->{capabilities}->{rowwise_delete} = ( | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 57 | ▶ | $self->capability("delete_one_row") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->capability('delete_one_row') || $self->capability('delete_current_row')
MC/DC0%0/2
$self->capability('delete_one_row') || $self->capability('delete_current_row')
$self->capability('delete_one_row')
$self->capability('delete_current_row')
Truth table33%1/3
A || B
A= $self->capability('delete_one_row')B= $self->capability('delete_current_row')
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | or $self->capability("delete_current_row") | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 57 | $self->{capabilities}->{$capname}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub drop ($$) { croak "Abstract method " . ref( $_[0] ) . "::drop called" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
drop: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub fetch_row ($$) { croak "Abstract method " . ref( $_[0] ) . "::fetch_row called" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_row: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub push_row ($$$) { croak "Abstract method " . ref( $_[0] ) . "::push_row called" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push_row: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub push_names ($$$) { croak "Abstract method " . ref( $_[0] ) . "::push_names called" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push_names: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub truncate ($$) { croak "Abstract method " . ref( $_[0] ) . "::truncate called" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
truncate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub seek ($$$$) { croak "Abstract method " . ref( $_[0] ) . "::seek called" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seek: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | __END__ | ||||||||||||||||||||||||||||||||||||||||||