Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated or_replace functionality to use File::Find (the directory tes…

…t on the glob was failing when schema_subdir was set). Patch from h34th3r.
  • Loading branch information...
commit cfd9d00950d803210c92ec434f4a50919c786de1 1 parent 5a96a75
@keithf4 keithf4 authored
Showing with 15 additions and 17 deletions.
  1. +15 −17 pg_extractor.pl
View
32 pg_extractor.pl
@@ -8,7 +8,7 @@
# https://github.com/omniti-labs/pg_extractor
# POD Documentation also available by issuing pod2text pg_extractor.pl
-# Version 1.2.0
+# Version 1.2.1
use Cwd;
use English qw( -no_match_vars);
@@ -27,7 +27,6 @@
};
my $argvfile_load = can_load(modules => $optional_modules);
-
my ($excludeschema_dump, $includeschema_dump, $excludetable_dump, $includetable_dump) = ("","","","");
my (@includeview, @excludeview);
my (@includefunction, @excludefunction);
@@ -36,6 +35,7 @@
my (@schemalist, @tablelist, @viewlist, @functionlist, @aggregatelist, @typelist, @acl_list, @commentlist);
my (%createdfiles);
++my %ignoredirs = ('.svn' => 1, '.git' => 1);
################ Run main program subroutines
#my $start_time = time();
@@ -1021,24 +1021,22 @@ sub svn_commit {
}
}
-sub or_replace {
- my $replace_cmd = "/usr/bin/env perl -pi -e 's/CREATE (FUNCTION|VIEW)/CREATE OR REPLACE \$1/'";
- my $prefix = $O->{'schemasubdir'} ? '*/' : '';
- chdir $O->{'basedir'};
- unless ($O->{'getfuncs'} || $O->{'getviews'}) {
- print "no functions or views\n";
- return;
- }
- if ($O->{'getfuncs'} && (-d "${prefix}function") ) {
- $replace_cmd .= " ${prefix}function/*";
- }
- if ($O->{'getviews'} && (-d "${prefix}view") ) {
- $replace_cmd .= " ${prefix}view/*";
- }
- print "$replace_cmd\n" if !$O->{'quiet'};
+sub or_replace_action {
+ if ($ignoredirs{$_}) {
+ $File::Find::prune = 1;
+ return;
+ }
+ return unless -f;
+ return unless $File::Find::name =~ /function|view/;
+ my $replace_cmd = "/usr/bin/env perl -pi -e 's/CREATE (FUNCTION|VIEW)/CREATE OR REPLACE \$1/' $_";
+ print "$replace_cmd\n" unless $O->{'quiet'};
system $replace_cmd;
}
+sub or_replace {
+ find (\&or_replace_action,$O->{'basedir'});
+}
+
sub die_cleanup {
my $message = shift @_;
cleanup();
Please sign in to comment.
Something went wrong with that request. Please try again.