[open-ils-commits] r17203 - in trunk/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 12 20:58:28 EDT 2010
Author: miker
Date: 2010-08-12 20:58:26 -0400 (Thu, 12 Aug 2010)
New Revision: 17203
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0370.schema.protect-authority-linking.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql
Log:
protect authority linking trigger against broken $0 values
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-08-12 21:39:11 UTC (rev 17202)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-08-13 00:58:26 UTC (rev 17203)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0369'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0370'); -- miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql 2010-08-12 21:39:11 UTC (rev 17202)
+++ trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql 2010-08-13 00:58:26 UTC (rev 17203)
@@ -901,7 +901,8 @@
y.authority
FROM ( SELECT DISTINCT $1 AS bib,
BTRIM(remove_paren_substring(x))::BIGINT AS authority
- FROM explode_array(oils_xpath('//*[@code="0"]/text()',$2)) x
+ FROM explode_array(oils_xpath('//*[@code="0"]/text()',$2)) x(txt)
+ WHERE BTRIM(remove_paren_substring(x)) ~ $re$^\d+$$re$
) y JOIN authority.record_entry r ON r.id = y.authority;
SELECT $1;
$func$ LANGUAGE SQL;
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0370.schema.protect-authority-linking.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0370.schema.protect-authority-linking.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0370.schema.protect-authority-linking.sql 2010-08-13 00:58:26 UTC (rev 17203)
@@ -0,0 +1,18 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0370');
+
+CREATE OR REPLACE FUNCTION biblio.map_authority_linking (bibid BIGINT, marc TEXT) RETURNS BIGINT AS $func$
+ DELETE FROM authority.bib_linking WHERE bib = $1;
+ INSERT INTO authority.bib_linking (bib, authority)
+ SELECT y.bib,
+ y.authority
+ FROM ( SELECT DISTINCT $1 AS bib,
+ BTRIM(remove_paren_substring(x))::BIGINT AS authority
+ FROM explode_array(oils_xpath('//*[@code="0"]/text()',$2)) x(txt)
+ WHERE BTRIM(remove_paren_substring(x)) ~ $re$^\d+$$re$
+ ) y JOIN authority.record_entry r ON r.id = y.authority;
+ SELECT $1;
+$func$ LANGUAGE SQL;
+
+COMMIT;
More information about the open-ils-commits
mailing list