From c5a360ce877a2705eb968f0e7b998811074ce453 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 19 Feb 2008 08:17:41 +1300 Subject: [PATCH] bug 1834: add entries to zebraqueue only when necessary Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 17 ++++++++++++++--- installer/data/mysql/kohastructure.sql | 3 ++- installer/data/mysql/updatedatabase.pl | 8 ++++++++ kohaversion.pl | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index ef76847784..26451e7d71 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2095,9 +2095,20 @@ sub ModZebra { # # we use zebra, just fill zebraqueue table # - my $sth=$dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); - $sth->execute($biblionumber,$server,$op); - $sth->finish; + my $check_sql = "SELECT COUNT(*) FROM zebraqueue + WHERE server = ? + AND biblio_auth_number = ? + AND operation = ? + AND done = 0"; + my $check_sth = $dbh->prepare_cached($check_sql); + $check_sth->execute($server, $biblionumber, $op); + my ($count) = $check_sth->fetchrow_array; + $check_sth->finish(); + if ($count == 0) { + my $sth=$dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); + $sth->execute($biblionumber,$server,$op); + $sth->finish; + } } } diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 42f42a30b6..971b400f20 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1861,7 +1861,8 @@ CREATE TABLE `zebraqueue` ( `server` char(20) NOT NULL default '', `done` int(11) NOT NULL default '0', `time` timestamp NOT NULL default CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `services_throttle`; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 05c3bcbce4..6600cc6cc2 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1021,6 +1021,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.055"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE `zebraqueue` ADD KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)"); + print "Upgrade to $DBversion done ( Added index on zebraqueue. )\n"; + SetVersion ($DBversion); +} + + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table diff --git a/kohaversion.pl b/kohaversion.pl index ab84da6988..cd8442b2f0 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = "3.00.00.054"; + our $VERSION = "3.00.00.055"; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.39.5