[open-ils-commits] [GIT] Evergreen ILS branch rel_2_2 updated. ef7c2441919ff2ff54fae5b0a195b06ca11dcab0
Evergreen Git
git at git.evergreen-ils.org
Fri Jul 27 09:33:25 EDT 2012
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_2 has been updated
via ef7c2441919ff2ff54fae5b0a195b06ca11dcab0 (commit)
via a0467b52a56ddb06eb98789a592eb63cf385d565 (commit)
via 7a96a8e30f13c153593b560fafa100a2db1d3dfc (commit)
from 132ab5633eeb54ee1731870d8aacd484f3a461dc (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 ef7c2441919ff2ff54fae5b0a195b06ca11dcab0
Author: Galen Charlton <gmc at esilibrary.com>
Date: Fri Jul 27 09:29:35 2012 -0400
stamp upgrade script for lp1028514
Signed-off-by: Galen Charlton <gmc 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 a13502a..0518aee 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -87,7 +87,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 ('0723', :eg_version); -- denials/senator
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0724', :eg_version); -- denials/gmcharlt
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql b/Open-ILS/src/sql/Pg/upgrade/0724.schema.fix_maintain_901_regex.sql
similarity index 95%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql
rename to Open-ILS/src/sql/Pg/upgrade/0724.schema.fix_maintain_901_regex.sql
index 334caeb..ddf17d8 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0724.schema.fix_maintain_901_regex.sql
@@ -1,3 +1,7 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0724', :eg_version); -- denials/gmcharlt
+
CREATE OR REPLACE FUNCTION evergreen.maintain_901 () RETURNS TRIGGER AS $func$
use strict;
use MARC::Record;
@@ -97,3 +101,5 @@ $_TD->{new}{marc} = $xml;
return "MODIFY";
$func$ LANGUAGE PLPERLU;
+
+COMMIT;
commit a0467b52a56ddb06eb98789a592eb63cf385d565
Author: Dan Scott <dscott at laurentian.ca>
Date: Tue Jul 24 14:14:01 2012 -0400
Switch to a PLPERLU maintain_901() trigger function
We've been burned by regexes that fail to grok XML properly numerous
times now. Standardizing on something that actually understands MARC
seems like a good idea.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Galen Charlton <gmc 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 b441ad8..274adc3 100644
--- a/Open-ILS/src/sql/Pg/002.functions.config.sql
+++ b/Open-ILS/src/sql/Pg/002.functions.config.sql
@@ -420,67 +420,104 @@ CREATE OR REPLACE FUNCTION oils_json_to_text( TEXT ) RETURNS TEXT AS $f$
$f$ LANGUAGE PLPERLU;
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');
+use strict;
+use MARC::Record;
+use MARC::File::XML (BinaryEncoding => 'UTF-8');
+use MARC::Charset;
+use Encode;
+use Unicode::Normalize;
- 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';
+MARC::Charset->assume_unicode(1);
- IF use_id_for_tcn = 't' THEN
- NEW.tcn_value := NEW.id;
- END IF;
+my $schema = $_TD->{table_schema};
+my $marc = MARC::Record->new_from_xml($_TD->{new}{marc});
+
+my @old901s = $marc->field('901');
+$marc->delete_fields(@old901s);
+
+if ($schema eq 'biblio') {
+ my $tcn_value = $_TD->{new}{tcn_value};
+
+ # Set TCN value to record ID?
+ my $id_as_tcn = spi_exec_query("
+ SELECT enabled
+ FROM config.global_flag
+ WHERE name = 'cat.bib.use_id_for_tcn'
+ ");
+ if (($id_as_tcn->{processed}) && $id_as_tcn->{rows}[0]->{enabled} eq 't') {
+ $tcn_value = $_TD->{new}{id};
+ }
- 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;
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "a" => $tcn_value,
+ "b" => $_TD->{new}{tcn_source},
+ "c" => $_TD->{new}{id},
+ "t" => $schema
+ );
- RETURN NEW;
-END;
-$func$ LANGUAGE PLPGSQL;
+ if ($_TD->{new}{owner}) {
+ $new_901->add_subfields("o" => $_TD->{new}{owner});
+ }
+
+ if ($_TD->{new}{share_depth}) {
+ $new_901->add_subfields("d" => $_TD->{new}{share_depth});
+ }
+
+ $marc->append_fields($new_901);
+} elsif ($schema = 'authority') {
+ $marc->append_fields(
+ ["901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ ]
+ );
+} elsif ($schema = 'serial') {
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ "o" => $_TD->{new}{owning_lib},
+ );
+
+ if ($_TD->{new}{record}) {
+ $new_901->add_subfields("r" => $_TD->{new}{record});
+ }
+
+ $marc->append_fields($new_901);
+} else {
+ $marc->append_fields(
+ ["901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ ]
+ );
+}
+
+my $xml = $marc->as_xml_record();
+$xml =~ s/\n//sgo;
+$xml =~ s/^<\?xml.+\?\s*>//go;
+$xml =~ s/>\s+</></go;
+$xml =~ s/\p{Cc}//go;
+
+# Embed a version of OpenILS::Application::AppUtils->entityize()
+# to avoid having to set PERL5LIB for PostgreSQL as well
+
+# If we are going to convert non-ASCII characters to XML entities,
+# we had better be dealing with a UTF8 string to begin with
+$xml = decode_utf8($xml);
+
+$xml = NFC($xml);
+
+# Convert raw ampersands to entities
+$xml =~ s/&(?!\S+;)/&/gso;
+
+# Convert Unicode characters to entities
+$xml =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
+
+$xml =~ s/[\x00-\x1f]//go;
+$_TD->{new}{marc} = $xml;
+
+return "MODIFY";
+$func$ LANGUAGE PLPERLU;
CREATE OR REPLACE FUNCTION evergreen.force_unicode_normal_form(string TEXT, form TEXT) RETURNS TEXT AS $func$
use Unicode::Normalize 'normalize';
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql
index 607e3a7..334caeb 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql
@@ -1,68 +1,99 @@
-BEGIN;
+CREATE OR REPLACE FUNCTION evergreen.maintain_901 () RETURNS TRIGGER AS $func$
+use strict;
+use MARC::Record;
+use MARC::File::XML (BinaryEncoding => 'UTF-8');
+use MARC::Charset;
+use Encode;
+use Unicode::Normalize;
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+MARC::Charset->assume_unicode(1);
-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;
+my $schema = $_TD->{table_schema};
+my $marc = MARC::Record->new_from_xml($_TD->{new}{marc});
+
+my @old901s = $marc->field('901');
+$marc->delete_fields(@old901s);
+
+if ($schema eq 'biblio') {
+ my $tcn_value = $_TD->{new}{tcn_value};
+
+ # Set TCN value to record ID?
+ my $id_as_tcn = spi_exec_query("
+ SELECT enabled
+ FROM config.global_flag
+ WHERE name = 'cat.bib.use_id_for_tcn'
+ ");
+ if (($id_as_tcn->{processed}) && $id_as_tcn->{rows}[0]->{enabled} eq 't') {
+ $tcn_value = $_TD->{new}{id};
+ }
+
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "a" => $tcn_value,
+ "b" => $_TD->{new}{tcn_source},
+ "c" => $_TD->{new}{id},
+ "t" => $schema
+ );
+
+ if ($_TD->{new}{owner}) {
+ $new_901->add_subfields("o" => $_TD->{new}{owner});
+ }
+
+ if ($_TD->{new}{share_depth}) {
+ $new_901->add_subfields("d" => $_TD->{new}{share_depth});
+ }
+
+ $marc->append_fields($new_901);
+} elsif ($schema = 'authority') {
+ $marc->append_fields(
+ ["901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ ]
+ );
+} elsif ($schema = 'serial') {
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ "o" => $_TD->{new}{owning_lib},
+ );
+
+ if ($_TD->{new}{record}) {
+ $new_901->add_subfields("r" => $_TD->{new}{record});
+ }
+
+ $marc->append_fields($new_901);
+} else {
+ $marc->append_fields(
+ ["901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ ]
+ );
+}
+
+my $xml = $marc->as_xml_record();
+$xml =~ s/\n//sgo;
+$xml =~ s/^<\?xml.+\?\s*>//go;
+$xml =~ s/>\s+</></go;
+$xml =~ s/\p{Cc}//go;
+
+# Embed a version of OpenILS::Application::AppUtils->entityize()
+# to avoid having to set PERL5LIB for PostgreSQL as well
+
+# If we are going to convert non-ASCII characters to XML entities,
+# we had better be dealing with a UTF8 string to begin with
+$xml = decode_utf8($xml);
+
+$xml = NFC($xml);
+
+# Convert raw ampersands to entities
+$xml =~ s/&(?!\S+;)/&/gso;
+
+# Convert Unicode characters to entities
+$xml =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
+
+$xml =~ s/[\x00-\x1f]//go;
+$_TD->{new}{marc} = $xml;
+
+return "MODIFY";
+$func$ LANGUAGE PLPERLU;
commit 7a96a8e30f13c153593b560fafa100a2db1d3dfc
Author: Galen Charlton <gmc at esilibrary.com>
Date: Tue Jul 24 11:51:52 2012 -0400
lp1028514: fix regex replace in maintain_901()
The regex used to insert the 901 field can put the new
field in the wrong location if the MARCXML record being
modified uses namespace prefixes. This patch tightens
the regexp to avoid this problem.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Dan Scott <dscott at laurentian.ca>
diff --git a/Open-ILS/src/sql/Pg/002.functions.config.sql b/Open-ILS/src/sql/Pg/002.functions.config.sql
index 3ea61ae..b441ad8 100644
--- a/Open-ILS/src/sql/Pg/002.functions.config.sql
+++ b/Open-ILS/src/sql/Pg/002.functions.config.sql
@@ -437,7 +437,7 @@ BEGIN
NEW.marc := REGEXP_REPLACE(
NEW.marc,
- E'(</(?:[^:]*?:)?record>)',
+ 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>' ||
@@ -450,7 +450,7 @@ BEGIN
ELSIF TG_TABLE_SCHEMA = 'authority' THEN
NEW.marc := REGEXP_REPLACE(
NEW.marc,
- E'(</(?:[^:]*?:)?record>)',
+ E'(</(?:[^:>]*?:)?record>)',
E'<datafield tag="901" ind1=" " ind2=" ">' ||
'<subfield code="c">' || NEW.id || E'</subfield>' ||
'<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
@@ -459,7 +459,7 @@ BEGIN
ELSIF TG_TABLE_SCHEMA = 'serial' THEN
NEW.marc := REGEXP_REPLACE(
NEW.marc,
- E'(</(?:[^:]*?:)?record>)',
+ E'(</(?:[^:>]*?:)?record>)',
E'<datafield tag="901" ind1=" " ind2=" ">' ||
'<subfield code="c">' || NEW.id || E'</subfield>' ||
'<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
@@ -470,7 +470,7 @@ BEGIN
ELSE
NEW.marc := REGEXP_REPLACE(
NEW.marc,
- E'(</(?:[^:]*?:)?record>)',
+ E'(</(?:[^:>]*?:)?record>)',
E'<datafield tag="901" ind1=" " ind2=" ">' ||
'<subfield code="c">' || NEW.id || E'</subfield>' ||
'<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql
new file mode 100644
index 0000000..607e3a7
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_maintain_901_regex.sql
@@ -0,0 +1,68 @@
+BEGIN;
+
+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;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.functions.config.sql | 159 ++++++++++++--------
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
.../upgrade/0724.schema.fix_maintain_901_regex.sql | 105 +++++++++++++
3 files changed, 204 insertions(+), 62 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0724.schema.fix_maintain_901_regex.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list