[open-ils-commits] r18410 - in branches/rel_2_0/Open-ILS/src/sql/Pg: . upgrade (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Oct 20 12:20:47 EDT 2010
Author: dbs
Date: 2010-10-20 12:20:43 -0400 (Wed, 20 Oct 2010)
New Revision: 18410
Added:
branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0443.schema.authority_ingest.sql
Modified:
branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/999.functions.global.sql
Log:
Prevent "Validate" from matching against deleted authority records
2.0 introduces the ability to delete authority records. The routines in
OpenILS:Application:Storage:Publisher:authority check for matching values
of authority.full_rec without concern about whether the corresponding
entry in authority.record_entry has been deleted or not.
This change removes entries from authority.full_rec when an
authority.record_entry row is deleted, with the (possibly incorrect)
assumption that there won't be many cases where users will want to
search for deleted authority records and undelete them. If that
assumption turns out to be incorrect, then further changes can follow;
this change at least makes the current behaviour for user-visible
actions work as expected.
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-10-20 16:17:45 UTC (rev 18409)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-10-20 16:20:43 UTC (rev 18410)
@@ -70,7 +70,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0442'); -- tsbere via miker
+INSERT INTO config.upgrade_log (version) VALUES ('0443'); -- dbs
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2010-10-20 16:17:45 UTC (rev 18409)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2010-10-20 16:20:43 UTC (rev 18410)
@@ -16519,6 +16519,7 @@
IF NEW.deleted IS TRUE THEN -- If this authority is deleted
DELETE FROM authority.bib_linking WHERE authority = NEW.id; -- Avoid updating fields in bibs that are no longer visible
+ DELETE FROM authority.full_rec WHERE record = NEW.id; -- Avoid validating fields against deleted authority records
-- Should remove matching $0 from controlled fields at the same time?
RETURN NEW; -- and we're done
END IF;
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/999.functions.global.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/999.functions.global.sql 2010-10-20 16:17:45 UTC (rev 18409)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/999.functions.global.sql 2010-10-20 16:20:43 UTC (rev 18410)
@@ -1419,6 +1419,7 @@
IF NEW.deleted IS TRUE THEN -- If this authority is deleted
DELETE FROM authority.bib_linking WHERE authority = NEW.id; -- Avoid updating fields in bibs that are no longer visible
+ DELETE FROM authority.full_rec WHERE record = NEW.id; -- Avoid validating fields against deleted authority records
-- Should remove matching $0 from controlled fields at the same time?
RETURN NEW; -- and we're done
END IF;
Copied: branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0443.schema.authority_ingest.sql (from rev 18409, trunk/Open-ILS/src/sql/Pg/upgrade/0443.schema.authority_ingest.sql)
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0443.schema.authority_ingest.sql (rev 0)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0443.schema.authority_ingest.sql 2010-10-20 16:20:43 UTC (rev 18410)
@@ -0,0 +1,39 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0443'); -- dbs
+
+-- AFTER UPDATE OR INSERT trigger for authority.record_entry
+CREATE OR REPLACE FUNCTION authority.indexing_ingest_or_delete () RETURNS TRIGGER AS $func$
+BEGIN
+
+ IF NEW.deleted IS TRUE THEN -- If this authority is deleted
+ DELETE FROM authority.bib_linking WHERE authority = NEW.id; -- Avoid updating fields in bibs that are no longer visible
+ DELETE FROM authority.full_rec WHERE record = NEW.id; -- Avoid validating fields against deleted authority records
+ -- Should remove matching $0 from controlled fields at the same time?
+ RETURN NEW; -- and we're done
+ END IF;
+
+ IF TG_OP = 'UPDATE' THEN -- re-ingest?
+ PERFORM * FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc' AND enabled;
+
+ IF NOT FOUND AND OLD.marc = NEW.marc THEN -- don't do anything if the MARC didn't change
+ RETURN NEW;
+ END IF;
+ END IF;
+
+ -- Flatten and insert the afr data
+ PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_full_rec' AND enabled;
+ IF NOT FOUND THEN
+ PERFORM authority.reingest_authority_full_rec(NEW.id);
+-- authority.rec_descriptor is not currently used
+-- PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_rec_descriptor' AND enabled;
+-- IF NOT FOUND THEN
+-- PERFORM authority.reingest_authority_rec_descriptor(NEW.id);
+-- END IF;
+ END IF;
+
+ RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
More information about the open-ils-commits
mailing list