From 7204bba0b1780d0f0e9e3a4c92e4512e621ed870 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 25 Mar 2010 20:30:12 +0000 Subject: [PATCH] move the sequence update to after the commit to support parallel ingest git-svn-id: svn://svn.open-ils.org/ILS/trunk@15995 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/import/parallel_pg_loader.pl | 4 +++- Open-ILS/src/extras/import/pg_loader.pl | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/extras/import/parallel_pg_loader.pl b/Open-ILS/src/extras/import/parallel_pg_loader.pl index 3cc8fd6b3d..23e0405f4b 100755 --- a/Open-ILS/src/extras/import/parallel_pg_loader.pl +++ b/Open-ILS/src/extras/import/parallel_pg_loader.pl @@ -52,6 +52,7 @@ for my $h (@order) { my $count = 0; my $starttime = time; +my $after_commit = ''; while ( my $rec = <> ) { next unless ($rec); @@ -123,7 +124,7 @@ while ( my $rec = <> ) { for my $hint (@order) { next if (grep { $_ eq $hint} @auto); next unless ($fieldcache{$hint}{sequence}); - $main_out->print("SELECT setval('$fieldcache{$hint}{sequence}'::TEXT, (SELECT MAX($fieldcache{$hint}{pkey}) FROM $fieldcache{$hint}{table}), TRUE);\n\n"); + $after_commit .= "SELECT setval('$fieldcache{$hint}{sequence}'::TEXT, (SELECT MAX($fieldcache{$hint}{pkey}) FROM $fieldcache{$hint}{table}), TRUE);\n"; } if (grep /^mfr$/, %out_files) { @@ -132,5 +133,6 @@ if (grep /^mfr$/, %out_files) { } $main_out->print("COMMIT;\n\n") unless $nocommit; +$main_out->print($after_commit); $main_out->close; diff --git a/Open-ILS/src/extras/import/pg_loader.pl b/Open-ILS/src/extras/import/pg_loader.pl index 611bb747b8..45b3f00ff7 100755 --- a/Open-ILS/src/extras/import/pg_loader.pl +++ b/Open-ILS/src/extras/import/pg_loader.pl @@ -87,6 +87,7 @@ binmode($output,'utf8'); $output->print("SET CLIENT_ENCODING TO 'UNICODE';\n\n"); $output->print("BEGIN;\n\n"); +my $after_commit = ''; for my $h (@order) { # continue if there was no data for this table next unless ($fieldcache{$h}); @@ -125,9 +126,10 @@ for my $h (@order) { $output->print("SELECT reporter.disable_materialized_simple_record_trigger();\n"); } - $output->print("SELECT setval('$fieldcache{$h}{sequence}'::TEXT, (SELECT MAX($fieldcache{$h}{pkey}) FROM $fieldcache{$h}{table}), TRUE);\n\n") + $after_commit .= "SELECT setval('$fieldcache{$h}{sequence}'::TEXT, (SELECT MAX($fieldcache{$h}{pkey}) FROM $fieldcache{$h}{table}), TRUE);\n"; if (!grep { $_ eq $h} @auto); } $output->print("COMMIT;\n\n") unless $nocommit; +$output->print($after_commit); $output->close; -- 2.11.0