line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::Database::PostgreSQL::Backend::CopyData; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.000'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use parent qw(Protocol::Database::PostgreSQL::Backend); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Protocol::Database::PostgreSQL::Backend::CopyData |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
50
|
use Log::Any qw($log); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
0
|
|
sub type { 'copy_data' } |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
0
|
|
sub rows { shift->{rows}->@* } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %_charmap = reverse( |
25
|
|
|
|
|
|
|
"\\" => "\\\\", |
26
|
|
|
|
|
|
|
"\x08" => "\\b", |
27
|
|
|
|
|
|
|
"\x09" => "\\t", |
28
|
|
|
|
|
|
|
"\x0A" => "\\r", |
29
|
|
|
|
|
|
|
"\x0C" => "\\f", |
30
|
|
|
|
|
|
|
"\x0D" => "\\n", |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new_from_message { |
34
|
0
|
|
|
0
|
1
|
|
my ($class, $msg) = @_; |
35
|
0
|
|
|
|
|
|
my $data = substr $msg, 5; |
36
|
0
|
|
|
|
|
|
$log->tracef('COPY data is %s', $data); |
37
|
|
|
|
|
|
|
my @rows = map { |
38
|
0
|
|
|
|
|
|
[ |
39
|
|
|
|
|
|
|
map { |
40
|
0
|
0
|
|
|
|
|
$_ eq '\N' |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
? undef |
42
|
0
|
|
|
|
|
|
: s/(\\[\\btrfn])/$_charmap{$1}/ger |
43
|
|
|
|
|
|
|
} split /\t/ |
44
|
|
|
|
|
|
|
] |
45
|
|
|
|
|
|
|
} split /\n/, $data; |
46
|
0
|
|
|
|
|
|
return $class->new( |
47
|
|
|
|
|
|
|
rows => \@rows, |
48
|
|
|
|
|
|
|
# data_format => $data_format, |
49
|
|
|
|
|
|
|
# count => $count, |
50
|
|
|
|
|
|
|
# formats => \@formats |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHOR |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Tom Molesworth |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 LICENSE |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Copyright Tom Molesworth 2010-2019. Licensed under the same terms as Perl itself. |
63
|
|
|
|
|
|
|
|