From 2bdb74056cfee44d1d3f12d84a01bfd01d931664 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 26 Sep 2012 22:54:06 -0400 Subject: [PATCH] After upgrade, list records with missing or incorrect 901$c This is a common cause of pain for upgrades. Let's try to identify the problem early (even if it takes forever on a site with 3 million bibs) and offer advice on correcting the problem if it is flagged. Signed-off-by: Dan Scott Signed-off-by: Lebbeous Fogle-Weekley --- .../version-upgrade/2.2-2.3.0-upgrade-db.sql | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.2-2.3.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.2-2.3.0-upgrade-db.sql index 4d8b87bbc3..a6cfd9a93b 100644 --- a/Open-ILS/src/sql/Pg/version-upgrade/2.2-2.3.0-upgrade-db.sql +++ b/Open-ILS/src/sql/Pg/version-upgrade/2.2-2.3.0-upgrade-db.sql @@ -2234,3 +2234,23 @@ $$ WHERE name = 'Bookbag CSV'; COMMIT; + +\qecho Evergreen depends heavily on each bibliographic record containing +\qecho a 901 field with a subfield "c" to hold the record ID. The following +\qecho query identifies the bibs that are missing 901s or whose first +\qecho 901$c is not equal to the bib ID. This *will* take a long time in a +\qecho big database; as the schema updates are over now, you can cancel this +\qecho if you are in a rush. + +SELECT id + FROM biblio.record_entry + WHERE ( + (XPATH('//marc:datafield[@tag="901"][1]/marc:subfield[@code="c"]/text()', marc::XML, ARRAY[ARRAY['marc', 'http://www.loc.gov/MARC21/slim']]))[1]::TEXT IS NULL + OR + (XPATH('//marc:datafield[@tag="901"][1]/marc:subfield[@code="c"]/text()', marc::XML, ARRAY[ARRAY['marc', 'http://www.loc.gov/MARC21/slim']]))[1]::TEXT <> id::TEXT) + AND id > -1; + +\qecho If there are records with missing or incorrect 901$c values, you can +\qecho generally rely on the triggers in the biblio.record_entry table to +\qecho populate the 901$c properly; for each offending record, run: +\qecho UPDATE biblio.record_entry SET marc = marc WHERE id = ; -- 2.43.2