From 1fd9a9ad71cb0ee6abdea25f64d88f725855c37c Mon Sep 17 00:00:00 2001
From: dbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Thu, 15 Jul 2010 10:22:17 +0000
Subject: [PATCH] On second thought, delete authority links pointing to stale
 bib records

This avoids the overhead of updating controlled fields in deleted bib records.


git-svn-id: svn://svn.open-ils.org/ILS/trunk@16936 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/sql/Pg/999.functions.global.sql                        | 6 +++---
 .../src/sql/Pg/upgrade/0337.function.asset.merge_record_assets.sql  | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql
index 6124ad0e8c..fcf0d5f1da 100644
--- a/Open-ILS/src/sql/Pg/999.functions.global.sql
+++ b/Open-ILS/src/sql/Pg/999.functions.global.sql
@@ -1103,10 +1103,10 @@ BEGIN
 		moved_objects := moved_objects + 1;
 	END LOOP;
 
-    -- Find and move authority->bib links to the target record
+    -- Delete authority->bib links to the source record to avoid
+    -- the overhead of updating controlled fields in deleted records
     FOR auth_link IN SELECT * FROM authority.bib_linking WHERE bib = source_record LOOP
-        UPDATE  authority.bib_linking
-          SET   bib = target_record
+        DELETE FROM authority.bib_linking
           WHERE id = auth_link.id;
 
         moved_objects := moved_objects + 1;
diff --git a/Open-ILS/src/sql/Pg/upgrade/0337.function.asset.merge_record_assets.sql b/Open-ILS/src/sql/Pg/upgrade/0337.function.asset.merge_record_assets.sql
index ef73095a3a..af36d9f728 100644
--- a/Open-ILS/src/sql/Pg/upgrade/0337.function.asset.merge_record_assets.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0337.function.asset.merge_record_assets.sql
@@ -141,10 +141,10 @@ BEGIN
         moved_objects := moved_objects + 1;
     END LOOP;
 
-    -- Find and move authority->bib links to the target record
+    -- Delete authority->bib links to the source record to avoid
+    -- the overhead of updating controlled fields in deleted records
     FOR auth_link IN SELECT * FROM authority.bib_linking WHERE bib = source_record LOOP
-        UPDATE  authority.bib_linking
-          SET   bib = target_record
+        DELETE FROM authority.bib_linking
           WHERE id = auth_link.id;
 
         moved_objects := moved_objects + 1;
-- 
2.11.0