line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pg::SQL::PrettyPrinter::Node::ResTarget; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/ |
4
|
10
|
|
|
10
|
|
5805
|
use v5.26; |
|
10
|
|
|
|
|
40
|
|
5
|
10
|
|
|
10
|
|
60
|
use strict; |
|
10
|
|
|
|
|
58
|
|
|
10
|
|
|
|
|
222
|
|
6
|
10
|
|
|
10
|
|
52
|
use warnings; |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
328
|
|
7
|
10
|
|
|
10
|
|
51
|
use warnings qw( FATAL utf8 ); |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
363
|
|
8
|
10
|
|
|
10
|
|
70
|
use utf8; |
|
10
|
|
|
|
|
38
|
|
|
10
|
|
|
|
|
64
|
|
9
|
10
|
|
|
10
|
|
352
|
use open qw( :std :utf8 ); |
|
10
|
|
|
|
|
30
|
|
|
10
|
|
|
|
|
52
|
|
10
|
10
|
|
|
10
|
|
1411
|
use Unicode::Normalize qw( NFC ); |
|
10
|
|
|
|
|
39
|
|
|
10
|
|
|
|
|
628
|
|
11
|
10
|
|
|
10
|
|
72
|
use Unicode::Collate; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
357
|
|
12
|
10
|
|
|
10
|
|
58
|
use Encode qw( decode ); |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
633
|
|
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
|
10
|
|
|
10
|
|
2518
|
use autodie; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
60
|
|
24
|
10
|
|
|
10
|
|
55334
|
use Carp qw( carp croak confess cluck ); |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
770
|
|
25
|
10
|
|
|
10
|
|
77
|
use English qw( -no_match_vars ); |
|
10
|
|
|
|
|
33
|
|
|
10
|
|
|
|
|
62
|
|
26
|
10
|
|
|
10
|
|
3714
|
use Data::Dumper qw( Dumper ); |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
2170
|
|
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
|
10
|
|
|
10
|
|
79
|
use parent qw( Pg::SQL::PrettyPrinter::Node ); |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
59
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
323
|
|
|
323
|
1
|
9814
|
my $class = shift; |
47
|
323
|
|
|
|
|
1008
|
my $self = $class->SUPER::new( @_ ); |
48
|
323
|
|
|
|
|
606
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
323
|
|
|
|
|
1082
|
$self->objectify( 'val' ); |
51
|
323
|
|
|
|
|
716
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub as_text { |
55
|
342
|
|
|
342
|
1
|
537
|
my $self = shift; |
56
|
342
|
|
50
|
|
|
1105
|
my $mode = shift || 'select'; |
57
|
|
|
|
|
|
|
|
58
|
342
|
|
|
|
|
526
|
my $val; |
59
|
342
|
50
|
|
|
|
720
|
if ( $mode eq 'assignment' ) { |
60
|
0
|
|
|
|
|
0
|
$val = $self->quote_ident( $self->{ 'name' } ) . ' = ' . $self->{ 'val' }->as_text; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
342
|
100
|
|
|
|
713
|
if ( exists $self->{ 'val' } ) { |
64
|
262
|
|
|
|
|
727
|
$val = $self->{ 'val' }->as_text(); |
65
|
262
|
100
|
|
|
|
766
|
if ( exists( $self->{ 'name' } ) ) { |
66
|
18
|
|
|
|
|
79
|
$val .= ' AS ' . $self->quote_ident( $self->{ 'name' } ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
80
|
|
|
|
|
194
|
$val = $self->quote_ident( $self->{ 'name' } ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
342
|
|
|
|
|
1132
|
return $val; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub pretty_print { |
77
|
245
|
|
|
245
|
1
|
395
|
my $self = shift; |
78
|
245
|
|
50
|
|
|
800
|
my $mode = shift || 'select'; |
79
|
|
|
|
|
|
|
|
80
|
245
|
|
|
|
|
353
|
my $val; |
81
|
245
|
50
|
|
|
|
592
|
if ( $mode eq 'assignment' ) { |
82
|
0
|
|
|
|
|
0
|
$val = $self->quote_ident( $self->{ 'name' } ) . ' = ' . $self->{ 'val' }->pretty_print; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
245
|
50
|
|
|
|
504
|
if ( exists $self->{ 'val' } ) { |
86
|
245
|
|
|
|
|
801
|
$val = $self->{ 'val' }->pretty_print(); |
87
|
245
|
100
|
|
|
|
668
|
if ( exists( $self->{ 'name' } ) ) { |
88
|
18
|
|
|
|
|
63
|
$val .= ' AS ' . $self->quote_ident( $self->{ 'name' } ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
0
|
|
|
|
|
0
|
$val = $self->quote_ident( $self->{ 'name' } ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
245
|
|
|
|
|
799
|
return $val; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |