line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pg::SQL::PrettyPrinter::Node::JoinExpr; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/ |
4
|
3
|
|
|
3
|
|
2143
|
use v5.26; |
|
3
|
|
|
|
|
17
|
|
5
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
80
|
|
6
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
93
|
|
7
|
3
|
|
|
3
|
|
16
|
use warnings qw( FATAL utf8 ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
107
|
|
8
|
3
|
|
|
3
|
|
18
|
use utf8; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
16
|
|
9
|
3
|
|
|
3
|
|
107
|
use open qw( :std :utf8 ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
20
|
|
10
|
3
|
|
|
3
|
|
439
|
use Unicode::Normalize qw( NFC ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
189
|
|
11
|
3
|
|
|
3
|
|
26
|
use Unicode::Collate; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
82
|
|
12
|
3
|
|
|
3
|
|
16
|
use Encode qw( decode ); |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
186
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
if ( grep /\P{ASCII}/ => @ARGV ) { |
15
|
|
|
|
|
|
|
@ARGV = map { decode( 'UTF-8', $_ ) } @ARGV; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# If there is __DATA__,then uncomment next line: |
19
|
|
|
|
|
|
|
# binmode( DATA, ':encoding(UTF-8)' ); |
20
|
|
|
|
|
|
|
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Useful common code |
23
|
3
|
|
|
3
|
|
619
|
use autodie; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
19
|
|
24
|
3
|
|
|
3
|
|
16565
|
use Carp qw( carp croak confess cluck ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
234
|
|
25
|
3
|
|
|
3
|
|
22
|
use English qw( -no_match_vars ); |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
21
|
|
26
|
3
|
|
|
3
|
|
1159
|
use Data::Dumper qw( Dumper ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
643
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# give a full stack dump on any untrapped exceptions |
29
|
|
|
|
|
|
|
local $SIG{ __DIE__ } = sub { |
30
|
|
|
|
|
|
|
confess "Uncaught exception: @_" unless $^S; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# now promote run-time warnings into stackdumped exceptions |
34
|
|
|
|
|
|
|
# *unless* we're in an try block, in which |
35
|
|
|
|
|
|
|
# case just generate a clucking stackdump instead |
36
|
|
|
|
|
|
|
local $SIG{ __WARN__ } = sub { |
37
|
|
|
|
|
|
|
if ( $^S ) { cluck "Trapped warning: @_" } |
38
|
|
|
|
|
|
|
else { confess "Deadly warning: @_" } |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Useful common code |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
3
|
|
30
|
use parent qw( Pg::SQL::PrettyPrinter::Node ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
21
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
5
|
|
|
5
|
1
|
125
|
my $class = shift; |
47
|
5
|
|
|
|
|
23
|
my $self = $class->SUPER::new( @_ ); |
48
|
5
|
|
|
|
|
11
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
23
|
$self->objectify( 'larg' ); |
51
|
5
|
|
|
|
|
14
|
$self->objectify( 'rarg' ); |
52
|
5
|
100
|
|
|
|
17
|
if ( $self->{ 'quals' } ) { |
53
|
4
|
|
|
|
|
12
|
$self->objectify( 'quals' ); |
54
|
|
|
|
|
|
|
} |
55
|
5
|
100
|
|
|
|
14
|
if ( $self->{ 'usingClause' } ) { |
56
|
1
|
|
|
|
|
4
|
$self->objectify( 'usingClause' ); |
57
|
|
|
|
|
|
|
} |
58
|
5
|
|
|
|
|
117
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub join_type { |
62
|
10
|
|
|
10
|
1
|
20
|
my $self = shift; |
63
|
10
|
100
|
|
|
|
24
|
if ( !exists $self->{ '_join_type' } ) { |
64
|
5
|
|
|
|
|
12
|
my $join_type = $self->{ 'jointype' }; |
65
|
5
|
|
|
|
|
38
|
$join_type =~ s/^JOIN_(.*)$/$1 JOIN/; |
66
|
5
|
100
|
|
|
|
16
|
$join_type = 'JOIN' if $join_type eq 'INNER JOIN'; |
67
|
5
|
50
|
66
|
|
|
19
|
$join_type = "CROSS ${join_type}" if ( !exists $self->{ 'quals' } ) && ( !exists $self->{ 'usingClause' } ); |
68
|
5
|
|
|
|
|
14
|
$self->{ '_join_type' } = $join_type; |
69
|
|
|
|
|
|
|
} |
70
|
10
|
|
|
|
|
31
|
return $self->{ '_join_type' }; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub as_text { |
74
|
5
|
|
|
5
|
1
|
10
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
5
|
|
|
|
|
11
|
my $join_cond = ''; |
77
|
5
|
100
|
|
|
|
91
|
if ( $self->{ 'usingClause' } ) { |
|
|
50
|
|
|
|
|
|
78
|
1
|
|
|
|
|
3
|
$join_cond = 'USING ( ' . join( ', ', map { $_->as_ident } @{ $self->{ 'usingClause' } } ) . ' )'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif ( $self->{ 'quals' } ) { |
81
|
4
|
|
|
|
|
18
|
$join_cond = 'ON ' . $self->{ 'quals' }->as_text; |
82
|
|
|
|
|
|
|
} |
83
|
5
|
|
|
|
|
22
|
return sprintf '%s %s %s %s', $self->{ 'larg' }->as_text, $self->join_type, $self->{ 'rarg' }->as_text, $join_cond; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub pretty_print { |
87
|
5
|
|
|
5
|
1
|
12
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
5
|
|
|
|
|
9
|
my $join_cond = ''; |
90
|
5
|
100
|
|
|
|
24
|
if ( $self->{ 'usingClause' } ) { |
|
|
50
|
|
|
|
|
|
91
|
1
|
|
|
|
|
2
|
$join_cond = 'USING ( ' . join( ', ', map { $_->as_ident } @{ $self->{ 'usingClause' } } ) . ' )'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
elsif ( $self->{ 'quals' } ) { |
94
|
4
|
|
|
|
|
14
|
$join_cond = 'ON ' . $self->{ 'quals' }->pretty_print; |
95
|
|
|
|
|
|
|
} |
96
|
5
|
|
|
|
|
20
|
return sprintf "%s\n%s %s %s", $self->{ 'larg' }->pretty_print, $self->join_type, $self->{ 'rarg' }->pretty_print, $join_cond; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |