| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SQL::Statement::Util; |
|
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
|
|
|
|
|
|
|
# See below for help and copyright information (search for SYNOPSIS). |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
###################################################################### |
|
13
|
|
|
|
|
|
|
|
|
14
|
16
|
|
|
16
|
|
114
|
use strict; |
|
|
16
|
|
|
|
|
31
|
|
|
|
16
|
|
|
|
|
564
|
|
|
15
|
16
|
|
|
16
|
|
84
|
use warnings FATAL => "all"; |
|
|
16
|
|
|
|
|
30
|
|
|
|
16
|
|
|
|
|
714
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
16
|
|
|
16
|
|
105
|
use vars qw($VERSION); |
|
|
16
|
|
|
|
|
29
|
|
|
|
16
|
|
|
|
|
1788
|
|
|
18
|
|
|
|
|
|
|
$VERSION = '1.414'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub type |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
2
|
|
|
2
|
1
|
17
|
my ($self) = @_; |
|
23
|
2
|
100
|
|
|
|
14
|
return 'function' if $self->isa('SQL::Statement::Util::Function'); |
|
24
|
1
|
50
|
|
|
|
8
|
return 'column' if $self->isa('SQL::Statement::Util::Column'); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package SQL::Statement::Util::Column; |
|
28
|
|
|
|
|
|
|
|
|
29
|
16
|
|
|
16
|
|
121
|
use vars qw(@ISA); |
|
|
16
|
|
|
|
|
30
|
|
|
|
16
|
|
|
|
|
868
|
|
|
30
|
|
|
|
|
|
|
@ISA = qw(SQL::Statement::Util); |
|
31
|
|
|
|
|
|
|
|
|
32
|
16
|
|
|
16
|
|
92
|
use Params::Util qw(_ARRAY _HASH0 _STRING); |
|
|
16
|
|
|
|
|
29
|
|
|
|
16
|
|
|
|
|
6468
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
1127
|
|
|
1127
|
|
2689
|
my ( $class, $col_name, $table_name, $term, $display_name, $full_orig_name, $coldef ) = @_; |
|
37
|
1127
|
|
66
|
|
|
2071
|
$display_name ||= $col_name; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1127
|
100
|
66
|
|
|
5693
|
if ( $col_name && ( $col_name =~ m/^((?:"[^"]+")|(?:[^.]*))\.(.*)$/ ) ) |
|
|
|
50
|
33
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
|
41
|
20
|
|
|
|
|
57
|
$table_name = $1; |
|
42
|
20
|
|
|
|
|
49
|
$col_name = $2; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
0
|
|
|
|
|
0
|
elsif ( defined( _ARRAY($table_name) ) && ( scalar( @{$table_name} ) == 1 ) ) |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
0
|
|
|
|
|
0
|
$table_name = $table_name->[0]; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
1127
|
|
|
|
|
4675
|
my %instance = ( |
|
50
|
|
|
|
|
|
|
name => $col_name, |
|
51
|
|
|
|
|
|
|
table => $table_name, |
|
52
|
|
|
|
|
|
|
display_name => $display_name, |
|
53
|
|
|
|
|
|
|
term => $term, |
|
54
|
|
|
|
|
|
|
full_orig_name => $full_orig_name, |
|
55
|
|
|
|
|
|
|
coldef => $coldef, |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
1127
|
|
|
|
|
2016
|
my $self = bless( \%instance, $class ); |
|
59
|
|
|
|
|
|
|
|
|
60
|
1127
|
|
|
|
|
2743
|
return $self; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
21262
|
|
|
21262
|
|
42631
|
sub value($) { $_[0]->{term}->value( $_[1] ); } |
|
64
|
0
|
|
|
0
|
|
0
|
sub term() { $_[0]->{term} } |
|
65
|
13748
|
|
|
13748
|
|
38898
|
sub display_name() { $_[0]->{display_name} } |
|
66
|
0
|
|
|
0
|
|
0
|
sub full_orig_name() { $_[0]->{full_orig_name} } |
|
67
|
13283
|
|
|
13283
|
|
32567
|
sub name() { $_[0]->{name} } |
|
68
|
496
|
|
|
496
|
|
1267
|
sub table() { $_[0]->{table} } |
|
69
|
0
|
|
|
0
|
|
0
|
sub coldef() { $_[0]->{coldef} } |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
package SQL::Statement::Util::Function; |
|
72
|
|
|
|
|
|
|
|
|
73
|
16
|
|
|
16
|
|
137
|
use vars qw(@ISA); |
|
|
16
|
|
|
|
|
38
|
|
|
|
16
|
|
|
|
|
6491
|
|
|
74
|
|
|
|
|
|
|
@ISA = qw(SQL::Statement::Util); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub new |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
2
|
|
|
2
|
|
495
|
my ( $class, $name, $sub_name, $args ) = @_; |
|
79
|
2
|
|
|
|
|
11
|
my ( $pkg, $sub ) = $sub_name =~ /^(.*::)([^:]+$)/; |
|
80
|
2
|
100
|
|
|
|
6
|
if ( !$sub ) |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
1
|
|
|
|
|
2
|
$pkg = 'main'; |
|
83
|
1
|
|
|
|
|
2
|
$sub = $sub_name; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
2
|
50
|
|
|
|
5
|
$pkg = 'main' if $pkg eq '::'; |
|
86
|
2
|
|
|
|
|
6
|
$pkg =~ s/::$//; |
|
87
|
2
|
|
|
|
|
10
|
my %newfunc = ( |
|
88
|
|
|
|
|
|
|
name => $name, |
|
89
|
|
|
|
|
|
|
sub_name => $sub, |
|
90
|
|
|
|
|
|
|
pkg_name => $pkg, |
|
91
|
|
|
|
|
|
|
args => $args, |
|
92
|
|
|
|
|
|
|
type => 'function', |
|
93
|
|
|
|
|
|
|
); |
|
94
|
2
|
|
|
|
|
11
|
return bless \%newfunc, $class; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
1
|
|
|
1
|
|
8
|
sub name { shift->{name} } |
|
97
|
2
|
|
|
2
|
|
5
|
sub pkg_name { shift->{pkg_name} } |
|
98
|
2
|
|
|
2
|
|
3
|
sub sub_name { shift->{sub_name} } |
|
99
|
0
|
|
|
0
|
|
0
|
sub args { shift->{args} } |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub validate |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
2
|
|
|
2
|
|
5
|
my ($self) = @_; |
|
104
|
2
|
|
|
|
|
5
|
my $pkg = $self->pkg_name; |
|
105
|
2
|
|
|
|
|
4
|
my $sub = $self->sub_name; |
|
106
|
2
|
|
|
|
|
6
|
$pkg =~ s,::,/,g; |
|
107
|
2
|
100
|
66
|
|
|
12
|
eval { require "$pkg.pm" } |
|
|
1
|
|
|
|
|
8
|
|
|
108
|
|
|
|
|
|
|
unless $pkg eq 'SQL/Statement/Functions' |
|
109
|
|
|
|
|
|
|
or $pkg eq 'main'; |
|
110
|
2
|
50
|
|
|
|
6
|
die $@ if $@; |
|
111
|
2
|
|
|
|
|
5
|
$pkg =~ s,/,::,g; |
|
112
|
2
|
100
|
|
|
|
24
|
die "Can't find subroutine $pkg" . "::$sub\n" unless $pkg->can($sub); |
|
113
|
1
|
|
|
|
|
4
|
return 1; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub run |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
16
|
|
|
16
|
|
124
|
use SQL::Statement::Functions; |
|
|
16
|
|
|
|
|
33
|
|
|
|
16
|
|
|
|
|
1356
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
0
|
|
|
my ($self) = shift; |
|
121
|
0
|
|
|
|
|
|
my $sub = $self->sub_name; |
|
122
|
0
|
|
|
|
|
|
my $pkg = $self->pkg_name; |
|
123
|
0
|
|
|
|
|
|
return $pkg->$sub(@_); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=pod |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 NAME |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
SQL::Statement::Util |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
SQL::Statement::Util::Column->new($col_name, $table_name, $term, $display_name) |
|
137
|
|
|
|
|
|
|
SQL::Statement::Util::AggregatedColumns($col_name, $table_name, $term, $display_name) |
|
138
|
|
|
|
|
|
|
SQL::Statement::Util::Function($name, $sub_name, $args) |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This package contains three utility classes to handle deliverable columns. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 INHERITANCE |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
SQL::Statement::Util::Column |
|
147
|
|
|
|
|
|
|
ISA SQL::Statement::Util |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
SQL::Statement::Util::AggregatedColumns |
|
150
|
|
|
|
|
|
|
ISA SQL::Statement::Util::Column |
|
151
|
|
|
|
|
|
|
ISA SQL::Statement::Util |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
SQL::Statement::Util::Function |
|
154
|
|
|
|
|
|
|
ISA SQL::Statement::Util |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=begin undocumented |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 METHODS |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 type |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns the type of the SQL::Statement::Util instance. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=end undocumented |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 AUTHOR & COPYRIGHT |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This module is |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
copyright (c) 2001,2005 by Jeff Zucker and |
|
171
|
|
|
|
|
|
|
copyright (c) 2007-2020 by Jens Rehsack. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
All rights reserved. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
The module may be freely distributed under the same terms as |
|
176
|
|
|
|
|
|
|
Perl itself using either the "GPL License" or the "Artistic |
|
177
|
|
|
|
|
|
|
License" as specified in the Perl README file. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Jeff can be reached at: jzuckerATcpan.org |
|
180
|
|
|
|
|
|
|
Jens can be reached at: rehsackATcpan.org or via dbi-devATperl.org |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |