From b57c146b261cf20e9685fcac300bb310739cd6ec Mon Sep 17 00:00:00 2001 From: Mason James Date: Thu, 21 Feb 2008 13:45:26 +1300 Subject: [PATCH] setting $dbh->{AutoCommit} = 0, and adding a new --commit arg. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- misc/migration_tools/rebuild_nozebra.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/misc/migration_tools/rebuild_nozebra.pl b/misc/migration_tools/rebuild_nozebra.pl index 114d87fe26..414105a4f4 100755 --- a/misc/migration_tools/rebuild_nozebra.pl +++ b/misc/migration_tools/rebuild_nozebra.pl @@ -22,6 +22,8 @@ my $reset; my $biblios; my $authorities; my $sysprefs; +my $commit; + GetOptions( 'd:s' => \$directory, 'reset' => \$reset, @@ -30,8 +32,12 @@ GetOptions( 'b' => \$biblios, 'a' => \$authorities, 's' => \$sysprefs, # rebuild 'NoZebraIndexes' syspref + 'commit:f' => \$commit, ); +my $commitnum = 1000; +$commitnum = $commit if ($commit) ; + $directory = "export" unless $directory; my $dbh=C4::Context->dbh; $dbh->do("update systempreferences set value=1 where variable='NoZebra'"); @@ -83,9 +89,12 @@ if (!%index || $sysprefs ) { } $|=1; +$dbh->{AutoCommit} = 0; + print "***********************************\n"; print "***** building BIBLIO indexes *****\n"; print "***********************************\n"; + my $sth; $sth=$dbh->prepare("select biblionumber from biblioitems order by biblionumber $limit"); $sth->execute(); @@ -162,7 +171,11 @@ while (my ($biblionumber) = $sth->fetchrow) { } } } + $dbh->commit() if (0 == $i % $commitnum); } +$dbh->commit; + + print "\nInserting records...\n"; $i=0; @@ -180,7 +193,11 @@ foreach my $key (keys %result) { $sth->execute($key,$index,$result{$key}->{$index}); $dbh->commit() if (0 == $i % $commitnum); } + $dbh->commit() if (0 == $i % $commitnum); } +$dbh->commit; + + print "\nbiblios done\n"; print "\n***********************************\n"; @@ -268,7 +285,12 @@ while (my ($authid) = $sth->fetchrow) { } } } + $dbh->commit() if (0 == $i % $commitnum); } +$dbh->commit; + + + print "\nInserting...\n"; $i=0; @@ -285,5 +307,7 @@ foreach my $key (keys %result) { $sth->execute($key,$index,$result{$key}->{$index}); $dbh->commit() if (0 == $i % $commitnum); } + $dbh->commit() if (0 == $i % $commitnum); } +$dbh->commit; print "\nauthorities done\n"; -- 2.39.5