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
|
|
5952
|
use v5.26; |
|
10
|
|
|
|
|
42
|
|
5
|
10
|
|
|
10
|
|
99
|
use strict; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
216
|
|
6
|
10
|
|
|
10
|
|
54
|
use warnings; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
709
|
|
7
|
10
|
|
|
10
|
|
60
|
use warnings qw( FATAL utf8 ); |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
378
|
|
8
|
10
|
|
|
10
|
|
67
|
use utf8; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
54
|
|
9
|
10
|
|
|
10
|
|
295
|
use open qw( :std :utf8 ); |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
60
|
|
10
|
10
|
|
|
10
|
|
1454
|
use Unicode::Normalize qw( NFC ); |
|
10
|
|
|
|
|
34
|
|
|
10
|
|
|
|
|
607
|
|
11
|
10
|
|
|
10
|
|
72
|
use Unicode::Collate; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
354
|
|
12
|
10
|
|
|
10
|
|
67
|
use Encode qw( decode ); |
|
10
|
|
|
|
|
42
|
|
|
10
|
|
|
|
|
617
|
|
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
|
|
2293
|
use autodie; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
63
|
|
24
|
10
|
|
|
10
|
|
54712
|
use Carp qw( carp croak confess cluck ); |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
766
|
|
25
|
10
|
|
|
10
|
|
69
|
use English qw( -no_match_vars ); |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
82
|
|
26
|
10
|
|
|
10
|
|
3814
|
use Data::Dumper qw( Dumper ); |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
2186
|
|
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
|
|
76
|
use parent qw( Pg::SQL::PrettyPrinter::Node ); |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
65
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
323
|
|
|
323
|
1
|
9907
|
my $class = shift; |
47
|
323
|
|
|
|
|
1035
|
my $self = $class->SUPER::new( @_ ); |
48
|
323
|
|
|
|
|
593
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
323
|
|
|
|
|
1115
|
$self->objectify( 'val' ); |
51
|
323
|
|
|
|
|
700
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub as_text { |
55
|
342
|
|
|
342
|
1
|
546
|
my $self = shift; |
56
|
342
|
|
50
|
|
|
1130
|
my $mode = shift || 'select'; |
57
|
|
|
|
|
|
|
|
58
|
342
|
|
|
|
|
516
|
my $val; |
59
|
342
|
50
|
|
|
|
694
|
if ( $mode eq 'assignment' ) { |
60
|
0
|
|
|
|
|
0
|
$val = $self->quote_ident( $self->{ 'name' } ) . ' = ' . $self->{ 'val' }->as_text; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
342
|
100
|
|
|
|
682
|
if ( exists $self->{ 'val' } ) { |
64
|
262
|
|
|
|
|
741
|
$val = $self->{ 'val' }->as_text(); |
65
|
262
|
100
|
|
|
|
711
|
if ( exists( $self->{ 'name' } ) ) { |
66
|
18
|
|
|
|
|
75
|
$val .= ' AS ' . $self->quote_ident( $self->{ 'name' } ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
80
|
|
|
|
|
203
|
$val = $self->quote_ident( $self->{ 'name' } ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
342
|
|
|
|
|
1170
|
return $val; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub pretty_print { |
77
|
245
|
|
|
245
|
1
|
387
|
my $self = shift; |
78
|
245
|
|
50
|
|
|
796
|
my $mode = shift || 'select'; |
79
|
|
|
|
|
|
|
|
80
|
245
|
|
|
|
|
384
|
my $val; |
81
|
245
|
50
|
|
|
|
532
|
if ( $mode eq 'assignment' ) { |
82
|
0
|
|
|
|
|
0
|
$val = $self->quote_ident( $self->{ 'name' } ) . ' = ' . $self->{ 'val' }->pretty_print; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
245
|
50
|
|
|
|
518
|
if ( exists $self->{ 'val' } ) { |
86
|
245
|
|
|
|
|
762
|
$val = $self->{ 'val' }->pretty_print(); |
87
|
245
|
100
|
|
|
|
670
|
if ( exists( $self->{ 'name' } ) ) { |
88
|
18
|
|
|
|
|
67
|
$val .= ' AS ' . $self->quote_ident( $self->{ 'name' } ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
0
|
|
|
|
|
0
|
$val = $self->quote_ident( $self->{ 'name' } ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
245
|
|
|
|
|
819
|
return $val; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |