[open-ils-commits] [GIT] Evergreen ILS branch rel_2_1 updated. da1f4b024ace0de1cfce762e54ffe67baecab2f7
Evergreen Git
git at git.evergreen-ils.org
Tue Jul 12 18:56:15 EDT 2011
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, rel_2_1 has been updated
via da1f4b024ace0de1cfce762e54ffe67baecab2f7 (commit)
via 490cdecd98708f68cbf42507bf046d97853ccf46 (commit)
via 4a21fdf39543385353080fbcf750c15fe1569231 (commit)
from d23ebf0e00aac60cf95c98d9c57c4931fcbe767d (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 da1f4b024ace0de1cfce762e54ffe67baecab2f7
Author: Jason Etheridge <jason at esilibrary.com>
Date: Tue Jul 12 17:55:54 2011 -0400
pin an upgrade version for fix_maintain_901_quoting
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 44619cb..ceb780f 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -57,7 +57,7 @@ CREATE TABLE config.upgrade_log (
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0573'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0576'); -- phasefx/gmcharlt
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_maintain_901_quoting.sql b/Open-ILS/src/sql/Pg/upgrade/0576.fix_maintain_901_quoting.sql
similarity index 96%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.fix_maintain_901_quoting.sql
rename to Open-ILS/src/sql/Pg/upgrade/0576.fix_maintain_901_quoting.sql
index c59e2f1..7e8e87f 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_maintain_901_quoting.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0576.fix_maintain_901_quoting.sql
@@ -1,4 +1,4 @@
--- Evergreen DB patch XXXX.fix_maintain_901_quoting.sql
+-- Evergreen DB patch 0576.fix_maintain_901_quoting.sql
--
-- Fix for bug LP#809540 - fixes crash when inserting or updating
-- bib whose tcn_value contains regex metacharacters.
@@ -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('0576', :eg_version);
CREATE OR REPLACE FUNCTION evergreen.maintain_901 () RETURNS TRIGGER AS $func$
DECLARE
commit 490cdecd98708f68cbf42507bf046d97853ccf46
Author: Galen Charlton <gmc at esilibrary.com>
Date: Tue Jul 12 16:56:10 2011 -0400
upgrade script for bugfix for lp#809540
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_maintain_901_quoting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_maintain_901_quoting.sql
new file mode 100644
index 0000000..c59e2f1
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_maintain_901_quoting.sql
@@ -0,0 +1,74 @@
+-- Evergreen DB patch XXXX.fix_maintain_901_quoting.sql
+--
+-- Fix for bug LP#809540 - fixes crash when inserting or updating
+-- bib whose tcn_value contains regex metacharacters.
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION evergreen.maintain_901 () RETURNS TRIGGER AS $func$
+DECLARE
+ use_id_for_tcn BOOLEAN;
+BEGIN
+ -- Remove any existing 901 fields before we insert the authoritative one
+ NEW.marc := REGEXP_REPLACE(NEW.marc, E'<datafield[^>]*?tag="901".+?</datafield>', '', 'g');
+
+ IF TG_TABLE_SCHEMA = 'biblio' THEN
+ -- Set TCN value to record ID?
+ SELECT enabled FROM config.global_flag INTO use_id_for_tcn
+ WHERE name = 'cat.bib.use_id_for_tcn';
+
+ IF use_id_for_tcn = 't' THEN
+ NEW.tcn_value := NEW.id;
+ END IF;
+
+ NEW.marc := REGEXP_REPLACE(
+ NEW.marc,
+ E'(</(?:[^:]*?:)?record>)',
+ E'<datafield tag="901" ind1=" " ind2=" ">' ||
+ '<subfield code="a">' || REPLACE(evergreen.xml_escape(NEW.tcn_value), E'\\', E'\\\\') || E'</subfield>' ||
+ '<subfield code="b">' || REPLACE(evergreen.xml_escape(NEW.tcn_source), E'\\', E'\\\\') || E'</subfield>' ||
+ '<subfield code="c">' || NEW.id || E'</subfield>' ||
+ '<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
+ CASE WHEN NEW.owner IS NOT NULL THEN '<subfield code="o">' || NEW.owner || E'</subfield>' ELSE '' END ||
+ CASE WHEN NEW.share_depth IS NOT NULL THEN '<subfield code="d">' || NEW.share_depth || E'</subfield>' ELSE '' END ||
+ E'</datafield>\\1'
+ );
+ ELSIF TG_TABLE_SCHEMA = 'authority' THEN
+ NEW.marc := REGEXP_REPLACE(
+ NEW.marc,
+ E'(</(?:[^:]*?:)?record>)',
+ E'<datafield tag="901" ind1=" " ind2=" ">' ||
+ '<subfield code="c">' || NEW.id || E'</subfield>' ||
+ '<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
+ E'</datafield>\\1'
+ );
+ ELSIF TG_TABLE_SCHEMA = 'serial' THEN
+ NEW.marc := REGEXP_REPLACE(
+ NEW.marc,
+ E'(</(?:[^:]*?:)?record>)',
+ E'<datafield tag="901" ind1=" " ind2=" ">' ||
+ '<subfield code="c">' || NEW.id || E'</subfield>' ||
+ '<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
+ '<subfield code="o">' || NEW.owning_lib || E'</subfield>' ||
+ CASE WHEN NEW.record IS NOT NULL THEN '<subfield code="r">' || NEW.record || E'</subfield>' ELSE '' END ||
+ E'</datafield>\\1'
+ );
+ ELSE
+ NEW.marc := REGEXP_REPLACE(
+ NEW.marc,
+ E'(</(?:[^:]*?:)?record>)',
+ E'<datafield tag="901" ind1=" " ind2=" ">' ||
+ '<subfield code="c">' || NEW.id || E'</subfield>' ||
+ '<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
+ E'</datafield>\\1'
+ );
+ END IF;
+
+ RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
commit 4a21fdf39543385353080fbcf750c15fe1569231
Author: Galen Charlton <gmc at esilibrary.com>
Date: Tue Jul 12 16:51:31 2011 -0400
lp#809540: quote replacement values properly in maintain_901()
Prevents a failure if, for example, the tcn_value of a bib to be
added or updated contains the string '\1'.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/002.functions.config.sql b/Open-ILS/src/sql/Pg/002.functions.config.sql
index 56a3df8..4574c83 100644
--- a/Open-ILS/src/sql/Pg/002.functions.config.sql
+++ b/Open-ILS/src/sql/Pg/002.functions.config.sql
@@ -439,8 +439,8 @@ BEGIN
NEW.marc,
E'(</(?:[^:]*?:)?record>)',
E'<datafield tag="901" ind1=" " ind2=" ">' ||
- '<subfield code="a">' || evergreen.xml_escape(NEW.tcn_value) || E'</subfield>' ||
- '<subfield code="b">' || evergreen.xml_escape(NEW.tcn_source) || E'</subfield>' ||
+ '<subfield code="a">' || REPLACE(evergreen.xml_escape(NEW.tcn_value), E'\\', E'\\\\') || E'</subfield>' ||
+ '<subfield code="b">' || REPLACE(evergreen.xml_escape(NEW.tcn_source), E'\\', E'\\\\') || E'</subfield>' ||
'<subfield code="c">' || NEW.id || E'</subfield>' ||
'<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
CASE WHEN NEW.owner IS NOT NULL THEN '<subfield code="o">' || NEW.owner || E'</subfield>' ELSE '' END ||
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.functions.config.sql | 4 ++--
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
...regex.sql => 0576.fix_maintain_901_quoting.sql} | 14 ++++++++++----
3 files changed, 13 insertions(+), 7 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{0491.function.maintain_901_fix_regex.sql => 0576.fix_maintain_901_quoting.sql} (80%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list