[open-ils-commits] [GIT] Evergreen ILS branch master updated. 7ea9abada5fa1e2e013e35dd50665b76bba9a065
Evergreen Git
git at git.evergreen-ils.org
Tue Jul 12 17:47:48 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, master has been updated
via 7ea9abada5fa1e2e013e35dd50665b76bba9a065 (commit)
via c17d9e0b89c43c066d49208392b24a97447ff32c (commit)
via e974a6e7d3a5fcc3a8dc58326742dd888e614aab (commit)
from c34228d534daf25f2c670050496334ea092fa0c5 (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 7ea9abada5fa1e2e013e35dd50665b76bba9a065
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 96277db..10038a9 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,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 ('0575', :eg_version); -- miker/senator
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0576', :eg_version); -- 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 c17d9e0b89c43c066d49208392b24a97447ff32c
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 e974a6e7d3a5fcc3a8dc58326742dd888e614aab
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