From d21177d87459946885a4cd31bc6c858fa1dc2b0b Mon Sep 17 00:00:00 2001 From: dbs Date: Fri, 20 Nov 2009 22:01:23 +0000 Subject: [PATCH] Backport a safer version of the reporter.disable_materialized_simple_record_trigger () function This one works with PostgreSQL 8.1 and up, so it's targeted to the 1.4 branch git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@14993 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/1.4.0.7-1.4.0.8-upgrade-db.sql | 30 ++++++++++++++++++++++ Open-ILS/src/sql/Pg/reporter-schema.sql | 11 ++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100755 Open-ILS/src/sql/Pg/1.4.0.7-1.4.0.8-upgrade-db.sql diff --git a/Open-ILS/src/sql/Pg/1.4.0.7-1.4.0.8-upgrade-db.sql b/Open-ILS/src/sql/Pg/1.4.0.7-1.4.0.8-upgrade-db.sql new file mode 100755 index 0000000000..81f9c2f4a2 --- /dev/null +++ b/Open-ILS/src/sql/Pg/1.4.0.7-1.4.0.8-upgrade-db.sql @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2009 Equinox Software, Inc. + * Mike Rylander + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + + +INSERT INTO config.upgrade_log (version) VALUES ('1.4.0.8'); + +CREATE OR REPLACE FUNCTION reporter.disable_materialized_simple_record_trigger () RETURNS VOID AS $$ + DECLARE x RECORD; + BEGIN + -- DROP TRIGGER IF EXISTS is only available starting with PostgreSQL 8.2 + FOR x IN SELECT tgname FROM pg_trigger WHERE tgname = 'zzz_update_materialized_simple_record_tgr' + LOOP + DROP TRIGGER zzz_update_materialized_simple_record_tgr ON metabib.real_full_rec; + END LOOP; + END; +$$ LANGUAGE plpgsql; + diff --git a/Open-ILS/src/sql/Pg/reporter-schema.sql b/Open-ILS/src/sql/Pg/reporter-schema.sql index 660a1effae..28ffc1f0c8 100644 --- a/Open-ILS/src/sql/Pg/reporter-schema.sql +++ b/Open-ILS/src/sql/Pg/reporter-schema.sql @@ -203,8 +203,15 @@ CREATE TRIGGER zzz_update_materialized_simple_record_tgr FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_sync(); CREATE OR REPLACE FUNCTION reporter.disable_materialized_simple_record_trigger () RETURNS VOID AS $$ - DROP TRIGGER zzz_update_materialized_simple_record_tgr ON metabib.real_full_rec; -$$ LANGUAGE SQL; + DECLARE x RECORD; + BEGIN + -- DROP TRIGGER IF EXISTS is only available starting with PostgreSQL 8.2 + FOR x IN SELECT tgname FROM pg_trigger WHERE tgname = 'zzz_update_materialized_simple_record_tgr' + LOOP + DROP TRIGGER zzz_update_materialized_simple_record_tgr ON metabib.real_full_rec; + END LOOP; + END; +$$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION reporter.enable_materialized_simple_record_trigger () RETURNS VOID AS $$ -- 2.11.0