line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pg::SQL::PrettyPrinter::Node::LockingClause; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/ |
4
|
2
|
|
|
2
|
|
1498
|
use v5.26; |
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
47
|
|
6
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
67
|
|
7
|
2
|
|
|
2
|
|
12
|
use warnings qw( FATAL utf8 ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
8
|
2
|
|
|
2
|
|
11
|
use utf8; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
10
|
|
9
|
2
|
|
|
2
|
|
69
|
use open qw( :std :utf8 ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
10
|
2
|
|
|
2
|
|
264
|
use Unicode::Normalize qw( NFC ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
124
|
|
11
|
2
|
|
|
2
|
|
15
|
use Unicode::Collate; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
12
|
2
|
|
|
2
|
|
13
|
use Encode qw( decode ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
118
|
|
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
|
2
|
|
|
2
|
|
419
|
use autodie; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
24
|
|
24
|
2
|
|
|
2
|
|
10906
|
use Carp qw( carp croak confess cluck ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
177
|
|
25
|
2
|
|
|
2
|
|
15
|
use English qw( -no_match_vars ); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
11
|
|
26
|
2
|
|
|
2
|
|
771
|
use Data::Dumper qw( Dumper ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
503
|
|
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
|
2
|
|
|
2
|
|
22
|
use parent qw( Pg::SQL::PrettyPrinter::Node ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
10
|
|
|
10
|
1
|
302
|
my $class = shift; |
47
|
10
|
|
|
|
|
33
|
my $self = $class->SUPER::new( @_ ); |
48
|
10
|
|
|
|
|
20
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
10
|
50
|
|
|
|
56
|
croak( 'Unknown strength of LockingClause ' . $self->{ 'strength' } ) unless $self->{ 'strength' } =~ m{\ALCS_FOR(?:KEYSHARE|NOKEYUPDATE|SHARE|UPDATE)\z}; |
51
|
10
|
50
|
|
|
|
36
|
croak( 'Unknown wait policy of LockingClause ' . $self->{ 'waitPolicy' } ) unless $self->{ 'waitPolicy' } =~ m{\ALockWait(?:Block|Error|Skip)\z}; |
52
|
|
|
|
|
|
|
|
53
|
10
|
|
|
|
|
38
|
$self->objectify( 'lockedRels' ); |
54
|
|
|
|
|
|
|
|
55
|
10
|
|
|
|
|
23
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub as_text { |
59
|
20
|
|
|
20
|
1
|
33
|
my $self = shift; |
60
|
20
|
|
|
|
|
39
|
my @parts = ( 'FOR' ); |
61
|
|
|
|
|
|
|
push @parts, { |
62
|
|
|
|
|
|
|
LCS_FORUPDATE => 'UPDATE', |
63
|
|
|
|
|
|
|
LCS_FORNOKEYUPDATE => 'NO KEY UPDATE', |
64
|
|
|
|
|
|
|
LCS_FORSHARE => 'SHARE', |
65
|
|
|
|
|
|
|
LCS_FORKEYSHARE => 'KEY SHARE' |
66
|
20
|
|
|
|
|
114
|
}->{ $self->{ 'strength' } }; |
67
|
|
|
|
|
|
|
|
68
|
20
|
100
|
|
|
|
68
|
if ( exists $self->{ 'lockedRels' } ) { |
69
|
8
|
|
|
|
|
12
|
push @parts, 'OF ' . join( ', ', map { $_->as_text } @{ $self->{ 'lockedRels' } } ); |
|
10
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
16
|
|
70
|
|
|
|
|
|
|
} |
71
|
20
|
100
|
|
|
|
66
|
if ( $self->{ 'waitPolicy' } eq 'LockWaitError' ) { |
|
|
100
|
|
|
|
|
|
72
|
4
|
|
|
|
|
8
|
push @parts, 'NOWAIT'; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif ( $self->{ 'waitPolicy' } eq 'LockWaitSkip' ) { |
75
|
4
|
|
|
|
|
8
|
push @parts, 'SKIP LOCKED'; |
76
|
|
|
|
|
|
|
} |
77
|
20
|
|
|
|
|
92
|
return join( ' ', @parts ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# vim: set ft=perl: |