[open-ils-commits] r7520 - trunk/Open-ILS/src/extras/import

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jul 5 11:32:04 EDT 2007


Author: miker
Date: 2007-07-05 11:28:09 -0400 (Thu, 05 Jul 2007)
New Revision: 7520

Modified:
   trunk/Open-ILS/src/extras/import/pg_loader.pl
Log:
added BEGIN/COMMIT pair surround the output; protect against missing table output (no subject data, but mentions of msfe on the command line)

Modified: trunk/Open-ILS/src/extras/import/pg_loader.pl
===================================================================
--- trunk/Open-ILS/src/extras/import/pg_loader.pl	2007-07-05 14:33:27 UTC (rev 7519)
+++ trunk/Open-ILS/src/extras/import/pg_loader.pl	2007-07-05 15:28:09 UTC (rev 7520)
@@ -80,8 +80,12 @@
 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 @@
 	$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; 



More information about the open-ils-commits mailing list