From 10df2364539356cd49ba96c3ccbf1977e2b467b4 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 5 Jul 2007 15:28:09 +0000 Subject: [PATCH] added BEGIN/COMMIT pair surround the output; protect against missing table output (no subject data, but mentions of msfe on the command line) git-svn-id: svn://svn.open-ils.org/ILS/trunk@7520 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/import/pg_loader.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Open-ILS/src/extras/import/pg_loader.pl b/Open-ILS/src/extras/import/pg_loader.pl index afc12738bb..eed76316eb 100755 --- a/Open-ILS/src/extras/import/pg_loader.pl +++ b/Open-ILS/src/extras/import/pg_loader.pl @@ -80,8 +80,12 @@ $output = FileHandle->new(">$output") if ($output); binmode($output,'utf8'); $output->print("SET CLIENT_ENCODING TO 'UNICODE';\n\n"); +$output->print("BEGIN;\n\n"); for my $h (@order) { + # continue if there was no data for this table + next unless ($fieldcache{$h}); + my $fields = join(',', @{ $fieldcache{$h}{fields} }); $output->print( "DELETE FROM $fieldcache{$h}{table};\n" ) if (grep {$_ eq $h } @wipe); $output->print( "COPY $fieldcache{$h}{table} ($fields) FROM STDIN;\n" ); @@ -113,3 +117,6 @@ for my $h (@order) { $output->print("SELECT setval('$fieldcache{$h}{sequence}'::TEXT, (SELECT MAX($fieldcache{$h}{pkey}) FROM $fieldcache{$h}{table}), TRUE);\n\n") if (!grep { $_ eq $h} @auto); } + +$output->print("COMMIT;\n\n"); +$output->close; -- 2.11.0