[open-ils-commits] [GIT] Evergreen ILS branch master updated. a4561f581eb54c088afb95d8758dd849d6f3d69e

Evergreen Git git at git.evergreen-ils.org
Fri May 11 16:03:03 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, master has been updated
       via  a4561f581eb54c088afb95d8758dd849d6f3d69e (commit)
       via  bcb1c10f2cde5c812f47da557c2dddc9fda2e0ab (commit)
      from  8f95eaeaf0bbc03be7c5e017d574234315eee97d (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 a4561f581eb54c088afb95d8758dd849d6f3d69e
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Fri May 11 15:59:37 2012 -0400

    Be more prepared for malformed serial holding code data in upgrade scripts
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous 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 2bf618d..eae6810 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 ('0709', :eg_version); -- berick/senator
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0710', :eg_version); -- senator
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0710.schema.stricter-could-be-holding-code.sql b/Open-ILS/src/sql/Pg/upgrade/0710.schema.stricter-could-be-holding-code.sql
new file mode 100644
index 0000000..5736a4f
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0710.schema.stricter-could-be-holding-code.sql
@@ -0,0 +1,27 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('0710', :eg_version);
+
+CREATE OR REPLACE FUNCTION evergreen.could_be_serial_holding_code(TEXT) RETURNS BOOL AS $$
+    use JSON::XS;
+    use MARC::Field;
+
+    eval {
+        my $holding_code = (new JSON::XS)->decode(shift);
+        new MARC::Field('999', @$holding_code);
+    };
+    return $@ ? 0 : 1;
+$$ LANGUAGE PLPERLU;
+
+-- This throws away data, but only data that causes breakage anyway.
+UPDATE serial.issuance
+    SET holding_code = NULL
+    WHERE NOT could_be_serial_holding_code(holding_code);
+
+ALTER TABLE serial.issuance
+    DROP CONSTRAINT IF EXISTS issuance_holding_code_check;
+
+ALTER TABLE serial.issuance
+    ADD CHECK (holding_code IS NULL OR could_be_serial_holding_code(holding_code));
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql
index 59a59af..6d1a138 100644
--- a/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql
+++ b/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql
@@ -11698,14 +11698,29 @@ INSERT INTO config.org_unit_setting_type ( name, label, description, datatype, g
 
 SELECT evergreen.upgrade_deps_block_check('0700', :eg_version);
 SELECT evergreen.upgrade_deps_block_check('0706', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0710', :eg_version);
+
+CREATE OR REPLACE FUNCTION evergreen.could_be_serial_holding_code(TEXT) RETURNS BOOL AS $$
+    use JSON::XS;
+    use MARC::Field;
+
+    eval {
+        my $holding_code = (new JSON::XS)->decode(shift);
+        new MARC::Field('999', @$holding_code);
+    };  
+    return $@ ? 0 : 1;
+$$ LANGUAGE PLPERLU;
 
 -- This throws away data, but only data that causes breakage anyway.
-UPDATE serial.issuance SET holding_code = NULL WHERE NOT is_json(holding_code);
+UPDATE serial.issuance SET holding_code = NULL WHERE NOT could_be_serial_holding_code(holding_code);
 
 -- If we don't do this, we have unprocessed triggers and we can't alter the table
 SET CONSTRAINTS serial.issuance_caption_and_pattern_fkey IMMEDIATE;
 
-ALTER TABLE serial.issuance ADD CHECK (holding_code IS NULL OR is_json(holding_code));
+ALTER TABLE serial.issuance
+    DROP CONSTRAINT IF EXISTS issuance_holding_code_check;
+
+ALTER TABLE serial.issuance ADD CHECK (holding_code IS NULL OR could_be_serial_holding_code(holding_code));
 
 INSERT INTO config.internal_flag (name, value, enabled) VALUES (
     'serial.rematerialize_on_same_holding_code', NULL, FALSE

commit bcb1c10f2cde5c812f47da557c2dddc9fda2e0ab
Author: Dan Scott <dan at coffeecode.net>
Date:   Fri May 11 10:45:39 2012 -0400

    Move PLPERL dropping outside of 2.1-2.2 upgrade transaction
    
    Sites might have added custom PLPERL database functions for migrations,
    data clean up, etc, so don't make the success of the 2.1-2.2 upgrade
    hinge on a database schema that exactly matches vanilla Evergreen;
    just move it outside of the upgrade transaction and output a reassuring
    note.
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql
index 5b369e7..59a59af 100644
--- a/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql
+++ b/Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql
@@ -11648,9 +11648,6 @@ CREATE OR REPLACE FUNCTION auditor.clear_audit_info() RETURNS VOID AS $$
     delete($_SHARED{"eg_audit_ws"});
 $$ LANGUAGE plperlu;
 
--- And remove the language so that we don't use it later.
-DROP LANGUAGE plperl;
-
 -- Evergreen DB patch 0697.data.place_currently_unfillable_hold.sql
 --
 -- FIXME: insert description of change, if needed
@@ -15656,7 +15653,7 @@ COMMIT;
 \qecho ************************************************************************
 \qecho The following transaction, wrapping upgrades 0679 and 0680, may take a
 \qecho *really* long time, and you might be able to run it by itself in
-\qecho parallel with other operations using a separate sesion.
+\qecho parallel with other operations using a separate session.
 \qecho ************************************************************************
 
 BEGIN;
@@ -16146,4 +16143,12 @@ CREATE INDEX ii_inv_idx on acq.invoice_item (invoice);
 CREATE INDEX ii_po_idx on acq.invoice_item (purchase_order);
 CREATE INDEX ii_poi_idx on acq.invoice_item (po_item);
 
+\qecho All Evergreen core database functions have been converted to
+\qecho use PLPERLU instead of PLPERL, so we are attempting to remove
+\qecho the PLPERL language here; but it is entirely possible that
+\qecho existing sites will have custom PLPERL functions that they
+\qecho will want to retain, so the following DROP LANGUAGE statement
+\qecho may fail, and that is okay.
+
+DROP LANGUAGE plperl;
 

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 .../0710.schema.stricter-could-be-holding-code.sql |   27 ++++++++++++++++
 .../sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql  |   32 ++++++++++++++++----
 3 files changed, 54 insertions(+), 7 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0710.schema.stricter-could-be-holding-code.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list