line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pg::SQL::PrettyPrinter::Node::CommonTableExpr; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/ |
4
|
5
|
|
|
5
|
|
3179
|
use v5.26; |
|
5
|
|
|
|
|
35
|
|
5
|
5
|
|
|
5
|
|
37
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
109
|
|
6
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
152
|
|
7
|
5
|
|
|
5
|
|
27
|
use warnings qw( FATAL utf8 ); |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
164
|
|
8
|
5
|
|
|
5
|
|
31
|
use utf8; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
33
|
|
9
|
5
|
|
|
5
|
|
151
|
use open qw( :std :utf8 ); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
30
|
|
10
|
5
|
|
|
5
|
|
706
|
use Unicode::Normalize qw( NFC ); |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
318
|
|
11
|
5
|
|
|
5
|
|
44
|
use Unicode::Collate; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
159
|
|
12
|
5
|
|
|
5
|
|
28
|
use Encode qw( decode ); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
297
|
|
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
|
5
|
|
|
5
|
|
1102
|
use autodie; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
99
|
|
24
|
5
|
|
|
5
|
|
27660
|
use Carp qw( carp croak confess cluck ); |
|
5
|
|
|
|
|
31
|
|
|
5
|
|
|
|
|
424
|
|
25
|
5
|
|
|
5
|
|
38
|
use English qw( -no_match_vars ); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
32
|
|
26
|
5
|
|
|
5
|
|
1962
|
use Data::Dumper qw( Dumper ); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
1178
|
|
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
|
5
|
|
|
5
|
|
40
|
use parent qw( Pg::SQL::PrettyPrinter::Node ); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
35
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
7
|
|
|
7
|
1
|
147
|
my $class = shift; |
47
|
7
|
|
|
|
|
36
|
my $self = $class->SUPER::new( @_ ); |
48
|
7
|
|
|
|
|
18
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
7
|
|
|
|
|
36
|
$self->objectify( qw( ctequery aliascolnames ) ); |
51
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
19
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub as_text { |
56
|
7
|
|
|
7
|
1
|
14
|
my $self = shift; |
57
|
|
|
|
|
|
|
return join( |
58
|
|
|
|
|
|
|
' ', |
59
|
|
|
|
|
|
|
$self->header, |
60
|
7
|
|
|
|
|
19
|
$self->{ 'ctequery' }->as_text, |
61
|
|
|
|
|
|
|
')' |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub pretty_print { |
66
|
7
|
|
|
7
|
1
|
82
|
my $self = shift; |
67
|
|
|
|
|
|
|
return join( |
68
|
|
|
|
|
|
|
"\n", |
69
|
|
|
|
|
|
|
$self->header, |
70
|
7
|
|
|
|
|
22
|
$self->increase_indent( $self->{ 'ctequery' }->pretty_print ), |
71
|
|
|
|
|
|
|
')' |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub header { |
76
|
14
|
|
|
14
|
1
|
23
|
my $self = shift; |
77
|
14
|
100
|
|
|
|
55
|
return $self->{ '_header' } if $self->{ '_header' }; |
78
|
|
|
|
|
|
|
|
79
|
7
|
|
|
|
|
12
|
my @header = (); |
80
|
7
|
|
|
|
|
38
|
push @header, $self->quote_ident( $self->{ 'ctename' } ); |
81
|
7
|
100
|
|
|
|
21
|
if ( exists $self->{ 'aliascolnames' } ) { |
82
|
1
|
|
|
|
|
8
|
push @header, '('; |
83
|
1
|
|
|
|
|
2
|
push @header, join( ', ', map { $_->as_ident } @{ $self->{ 'aliascolnames' } } ); |
|
2
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
3
|
|
84
|
1
|
|
|
|
|
2
|
push @header, ')'; |
85
|
|
|
|
|
|
|
} |
86
|
7
|
|
|
|
|
16
|
push @header, 'AS'; |
87
|
7
|
100
|
|
|
|
25
|
push @header, 'MATERIALIZED' if $self->{ 'ctematerialized' } eq 'CTEMaterializeAlways'; |
88
|
7
|
|
|
|
|
20
|
push @header, '('; |
89
|
7
|
|
|
|
|
23
|
$self->{ '_header' } = join( ' ', @header ); |
90
|
7
|
|
|
|
|
29
|
return $self->{ '_header' }; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# vim: set ft=perl: |