LP 1768715: Only connect to the database when needed in pingest.pl.
authorJason Stephenson <jstephenson@mvlcstaff.org>
Fri, 1 Apr 2016 14:02:45 +0000 (10:02 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 23 Aug 2018 16:27:54 +0000 (12:27 -0400)
We chagne where we connect and disconnect the database in the parent
process in pingest.pl.  There's no point connecting at all if the
--pipe option is used.

Signed-off-by: Jason Stephenson <jstephenson@mvlcstaff.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>

Open-ILS/src/support-scripts/pingest.pl

index 73efaab..9c92528 100755 (executable)
@@ -140,7 +140,6 @@ sub duration_expired {
 #
 # 2) edit the DBI->connect() calls in this program so that it can
 # connect to your database.
-my $dbh = DBI->connect('DBI:Pg:');
 
 # Get the input records from either standard input or the database.
 my @input;
@@ -152,7 +151,9 @@ if ($opt_pipe) {
         }
     }
 } else {
+    my $dbh = DBI->connect('DBI:Pg:');
     @input = @{$dbh->selectall_arrayref($q)};
+    $dbh->disconnect();
 }
 
 foreach my $r (@input) {
@@ -167,7 +168,6 @@ foreach my $r (@input) {
 }
 $lol[$lists++] = $records if ($count); # Last batch is likely to be
                                        # small.
-$dbh->disconnect();
 
 # We're going to reuse $count to keep track of the total number of
 # batches processed.