[open-ils-commits] [GIT] Evergreen ILS branch master updated. 3753e262f00aa0fe45ee62586a6f1b6ca096d640
Evergreen Git
git at git.evergreen-ils.org
Tue Feb 3 16:02:28 EST 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 3753e262f00aa0fe45ee62586a6f1b6ca096d640 (commit)
via 166912da7a2686783db79a092ef63e8382dcbe15 (commit)
from 9452d114f63b2340ced3c301a05bf2c17f4d53df (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3753e262f00aa0fe45ee62586a6f1b6ca096d640
Author: Ben Shum <bshum at biblio.org>
Date: Tue Feb 3 16:01:17 2015 -0500
LP#1415572: Stamping upgrade script for ensuring correct version of authority.normalize_heading
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index b132005..7f4aa2d 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0904', :eg_version); -- miker/gmcharlt/csharp/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0905', :eg_version); -- gmcharlt/csharp/bshum
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.use_current_normalize_heading.sql b/Open-ILS/src/sql/Pg/upgrade/0905.schema.use_current_normalize_heading.sql
similarity index 97%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.use_current_normalize_heading.sql
rename to Open-ILS/src/sql/Pg/upgrade/0905.schema.use_current_normalize_heading.sql
index ee8d00a..8edc0f9 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.use_current_normalize_heading.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0905.schema.use_current_normalize_heading.sql
@@ -1,4 +1,4 @@
--- Evergreen DB patch XXXX.schema.use_current_normalize_heading.sql
+-- Evergreen DB patch 0905.schema.use_current_normalize_heading.sql
--
-- LP#1415572: ensure current version of authority.normalize_heading() is in place
--
@@ -6,7 +6,7 @@ BEGIN;
-- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0905', :eg_version);
CREATE OR REPLACE FUNCTION authority.normalize_heading( marcxml TEXT, no_thesaurus BOOL ) RETURNS TEXT AS $func$
DECLARE
commit 166912da7a2686783db79a092ef63e8382dcbe15
Author: Galen Charlton <gmc at esilibrary.com>
Date: Wed Jan 28 17:24:02 2015 +0000
LP#1415572: ensure correct version of authority.normalize_heading() is in place
Some upgraded Evergreen databases can have the wrong version
of the authority.normalize_heading() function in place because
of a mixup in the 0848 schema upgrade script. The problem can
manifest itself by there being rows in authority.record_entry
where the heading and simple_heading columns have "NOHEADING"
values regardless of the control set:
-[ RECORD 1 ]--+---------------------------------------------
heading | NOHEADING_a ff0ed9fcd13e8944d9a718650840787a
simple_heading | NOHEADING_a ff0ed9fcd13e8944d9a718650840787a
This patch ensures that the correct version is in place and
updates authority.record_entry to fix up affected rows without
requiring a full authority ingest.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.use_current_normalize_heading.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.use_current_normalize_heading.sql
new file mode 100644
index 0000000..ee8d00a
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.use_current_normalize_heading.sql
@@ -0,0 +1,117 @@
+-- Evergreen DB patch XXXX.schema.use_current_normalize_heading.sql
+--
+-- LP#1415572: ensure current version of authority.normalize_heading() is in place
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION authority.normalize_heading( marcxml TEXT, no_thesaurus BOOL ) RETURNS TEXT AS $func$
+DECLARE
+ acsaf authority.control_set_authority_field%ROWTYPE;
+ tag_used TEXT;
+ nfi_used TEXT;
+ sf TEXT;
+ sf_node TEXT;
+ tag_node TEXT;
+ thes_code TEXT;
+ cset INT;
+ heading_text TEXT;
+ tmp_text TEXT;
+ first_sf BOOL;
+ auth_id INT DEFAULT COALESCE(NULLIF(oils_xpath_string('//*[@tag="901"]/*[local-name()="subfield" and @code="c"]', marcxml), ''), '0')::INT;
+BEGIN
+ SELECT control_set INTO cset FROM authority.record_entry WHERE id = auth_id;
+
+ IF cset IS NULL THEN
+ SELECT control_set INTO cset
+ FROM authority.control_set_authority_field
+ WHERE tag IN ( SELECT UNNEST(XPATH('//*[starts-with(@tag,"1")]/@tag',marcxml::XML)::TEXT[]))
+ LIMIT 1;
+ END IF;
+
+ thes_code := vandelay.marc21_extract_fixed_field(marcxml,'Subj');
+ IF thes_code IS NULL THEN
+ thes_code := '|';
+ ELSIF thes_code = 'z' THEN
+ thes_code := COALESCE( oils_xpath_string('//*[@tag="040"]/*[@code="f"][1]', marcxml), '' );
+ END IF;
+
+ heading_text := '';
+ FOR acsaf IN SELECT * FROM authority.control_set_authority_field WHERE control_set = cset AND main_entry IS NULL LOOP
+ tag_used := acsaf.tag;
+ nfi_used := acsaf.nfi;
+ first_sf := TRUE;
+
+ FOR tag_node IN SELECT unnest(oils_xpath('//*[@tag="'||tag_used||'"]',marcxml)) LOOP
+ FOR sf_node IN SELECT unnest(oils_xpath('./*[contains("'||acsaf.sf_list||'", at code)]',tag_node)) LOOP
+
+ tmp_text := oils_xpath_string('.', sf_node);
+ sf := oils_xpath_string('./@code', sf_node);
+
+ IF first_sf AND tmp_text IS NOT NULL AND nfi_used IS NOT NULL THEN
+
+ tmp_text := SUBSTRING(
+ tmp_text FROM
+ COALESCE(
+ NULLIF(
+ REGEXP_REPLACE(
+ oils_xpath_string('./@ind'||nfi_used, tag_node),
+ $$\D+$$,
+ '',
+ 'g'
+ ),
+ ''
+ )::INT,
+ 0
+ ) + 1
+ );
+
+ END IF;
+
+ first_sf := FALSE;
+
+ IF tmp_text IS NOT NULL AND tmp_text <> '' THEN
+ heading_text := heading_text || E'\u2021' || sf || ' ' || tmp_text;
+ END IF;
+ END LOOP;
+
+ EXIT WHEN heading_text <> '';
+ END LOOP;
+
+ EXIT WHEN heading_text <> '';
+ END LOOP;
+
+ IF heading_text <> '' THEN
+ IF no_thesaurus IS TRUE THEN
+ heading_text := tag_used || ' ' || public.naco_normalize(heading_text);
+ ELSE
+ heading_text := tag_used || '_' || COALESCE(nfi_used,'-') || '_' || thes_code || ' ' || public.naco_normalize(heading_text);
+ END IF;
+ ELSE
+ heading_text := 'NOHEADING_' || thes_code || ' ' || MD5(marcxml);
+ END IF;
+
+ RETURN heading_text;
+END;
+$func$ LANGUAGE PLPGSQL STABLE STRICT;
+
+-- fix heading and simple_headings columns without
+-- causing a full authority reingest
+ALTER TABLE authority.record_entry DISABLE TRIGGER a_marcxml_is_well_formed;
+ALTER TABLE authority.record_entry DISABLE TRIGGER aaa_auth_ingest_or_delete;
+ALTER TABLE authority.record_entry DISABLE TRIGGER b_maintain_901;
+ALTER TABLE authority.record_entry DISABLE TRIGGER c_maintain_control_numbers;
+ALTER TABLE authority.record_entry DISABLE TRIGGER map_thesaurus_to_control_set;
+
+UPDATE authority.record_entry SET id = id WHERE heading LIKE 'NOHEADING%';
+
+ALTER TABLE authority.record_entry ENABLE TRIGGER a_marcxml_is_well_formed;
+ALTER TABLE authority.record_entry ENABLE TRIGGER aaa_auth_ingest_or_delete;
+ALTER TABLE authority.record_entry ENABLE TRIGGER b_maintain_901;
+ALTER TABLE authority.record_entry ENABLE TRIGGER c_maintain_control_numbers;
+ALTER TABLE authority.record_entry ENABLE TRIGGER map_thesaurus_to_control_set;
+
+COMMIT;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
... 0905.schema.use_current_normalize_heading.sql} | 99 +++++---------------
2 files changed, 24 insertions(+), 77 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{0802.function.authority-sf-file-order.sql => 0905.schema.use_current_normalize_heading.sql} (56%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list