Anonymize CTE names, per gripe from Brian Dunavant

Version 0.69
parent 4f5b3c39
Revision history for Pg-Explain
0.69 2014/06/08
- Anonymize CTE names, per gripe from Brian Dunavant
0.68 2013/10/01
- Fix extracting of table/index info from "Index Only Scan" nodes from
YAML/XML/JSON explains.
......
......@@ -112,6 +112,7 @@ t/21-perltidy.t
t/22-anonymization-of-non-select-plans.t
t/23-anonymization-of-one-time-filters.t
t/24-anonymization-of-index-only-scans.t
t/25-anonymization-of-cte-names.t
t/99-manifest.t
t/perlcriticrc
t/perltidyrc
......
......@@ -4,7 +4,7 @@
"hubert depesz lubaczewski <depesz@depesz.com>"
],
"dynamic_config" : 1,
"generated_by" : "Module::Build version 0.4005, CPAN::Meta::Converter version 2.120921",
"generated_by" : "Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921",
"license" : [
"perl_5"
],
......@@ -41,35 +41,35 @@
"provides" : {
"Pg::Explain" : {
"file" : "lib/Pg/Explain.pm",
"version" : "0.68"
"version" : "0.69"
},
"Pg::Explain::From" : {
"file" : "lib/Pg/Explain/From.pm",
"version" : "0.68"
"version" : "0.69"
},
"Pg::Explain::FromJSON" : {
"file" : "lib/Pg/Explain/FromJSON.pm",
"version" : "0.68"
"version" : "0.69"
},
"Pg::Explain::FromText" : {
"file" : "lib/Pg/Explain/FromText.pm",
"version" : "0.68"
"version" : "0.69"
},
"Pg::Explain::FromXML" : {
"file" : "lib/Pg/Explain/FromXML.pm",
"version" : "0.68"
"version" : "0.69"
},
"Pg::Explain::FromYAML" : {
"file" : "lib/Pg/Explain/FromYAML.pm",
"version" : "0.68"
"version" : "0.69"
},
"Pg::Explain::Node" : {
"file" : "lib/Pg/Explain/Node.pm",
"version" : "0.68"
"version" : "0.69"
},
"Pg::Explain::StringAnonymizer" : {
"file" : "lib/Pg/Explain/StringAnonymizer.pm",
"version" : "0.68"
"version" : "0.69"
}
},
"release_status" : "stable",
......@@ -78,5 +78,5 @@
"http://dev.perl.org/licenses/"
]
},
"version" : "0.68"
"version" : "0.69"
}
......@@ -10,7 +10,7 @@ build_requires:
configure_requires:
Module::Build: 0.38
dynamic_config: 1
generated_by: 'Module::Build version 0.4005, CPAN::Meta::Converter version 2.120921'
generated_by: 'Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
......@@ -19,28 +19,28 @@ name: Pg-Explain
provides:
Pg::Explain:
file: lib/Pg/Explain.pm
version: 0.68
version: 0.69
Pg::Explain::From:
file: lib/Pg/Explain/From.pm
version: 0.68
version: 0.69
Pg::Explain::FromJSON:
file: lib/Pg/Explain/FromJSON.pm
version: 0.68
version: 0.69
Pg::Explain::FromText:
file: lib/Pg/Explain/FromText.pm
version: 0.68
version: 0.69
Pg::Explain::FromXML:
file: lib/Pg/Explain/FromXML.pm
version: 0.68
version: 0.69
Pg::Explain::FromYAML:
file: lib/Pg/Explain/FromYAML.pm
version: 0.68
version: 0.69
Pg::Explain::Node:
file: lib/Pg/Explain/Node.pm
version: 0.68
version: 0.69
Pg::Explain::StringAnonymizer:
file: lib/Pg/Explain/StringAnonymizer.pm
version: 0.68
version: 0.69
requires:
Clone: 0
Digest::SHA1: 0
......@@ -50,4 +50,4 @@ requires:
YAML: 0
resources:
license: http://dev.perl.org/licenses/
version: 0.68
version: 0.69
......@@ -11,11 +11,11 @@ Pg::Explain - Object approach at reading explain analyze output
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......
......@@ -9,11 +9,11 @@ Pg::Explain::From - Base class for parsers of non-text explain formats.
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......
......@@ -10,11 +10,11 @@ Pg::Explain::FromJSON - Parser for explains in JSON format
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......
......@@ -9,11 +9,11 @@ Pg::Explain::FromText - Parser for text based explains
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......
......@@ -10,11 +10,11 @@ Pg::Explain::FromXML - Parser for explains in XML format
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......
......@@ -10,11 +10,11 @@ Pg::Explain::FromYAML - Parser for explains in YAML format
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......
......@@ -12,11 +12,11 @@ Pg::Explain::Node - Class representing single node from query plan
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......@@ -600,6 +600,10 @@ sub anonymize_gathering {
$anonymizer->add( values %{ $self->scan_on } );
}
if ( $self->cte_order ) {
$anonymizer->add( $self->{ 'cte_order' } );
}
if ( $self->extra_info ) {
for my $line ( @{ $self->extra_info } ) {
my $copy = $line;
......@@ -779,6 +783,17 @@ sub anonymize_substitute {
$self->scan_on->{ $key } = $anonymizer->anonymized( $value );
}
}
if ( $self->cte_order ) {
my @new_order = ();
for my $cte_name ( @{ $self->cte_order } ) {
my $new_name = $anonymizer->anonymized( $cte_name );
push @new_order, $new_name;
$self->ctes->{ $new_name } = delete $self->{ 'ctes' }->{ $cte_name };
}
$self->cte_order( \@new_order );
}
if ( $self->extra_info ) {
my @new_extra_info = ();
for my $line ( @{ $self->extra_info } ) {
......
......@@ -11,11 +11,11 @@ Pg::Explain::StringAnonymizer - Class to anonymize sets of strings
=head1 VERSION
Version 0.68
Version 0.69
=cut
our $VERSION = '0.68';
our $VERSION = '0.69';
=head1 SYNOPSIS
......
#!perl
use Test::More;
use Test::Deep;
use Test::Exception;
use Data::Dumper;
use autodie;
use Pg::Explain;
my @plans = (
q{
CTE Scan on some_name (cost=0.01..0.03 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=1)
CTE some_name
-> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.003..0.003 rows=1 loops=1)
Planning time: 0.032 ms
Execution time: 0.030 ms
},
);
plan 'tests' => 4 * scalar @plans;
for my $plan_source ( @plans ) {
my $explain = Pg::Explain->new( 'source' => $plan_source );
isa_ok( $explain, 'Pg::Explain' );
isa_ok( $explain->top_node, 'Pg::Explain::Node' );
lives_ok(
sub {
$explain->anonymize();
},
'Anonymization works',
);
my $textual = $explain->as_text();
ok( $textual !~ /some_name/, 'anonymize() hides cte names' );
}
exit;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment