[open-ils-commits] r9743 - branches/rel_1_2/Open-ILS/src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat May 31 01:21:32 EDT 2008
Author: miker
Date: 2008-05-31 01:21:29 -0400 (Sat, 31 May 2008)
New Revision: 9743
Added:
branches/rel_1_2/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql
Modified:
branches/rel_1_2/Open-ILS/src/sql/Pg/reporter-schema.sql
Log:
some new management functions for the materialized reporting view
Added: branches/rel_1_2/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql
===================================================================
--- branches/rel_1_2/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql (rev 0)
+++ branches/rel_1_2/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql 2008-05-31 05:21:29 UTC (rev 9743)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008 Equinox Software, Inc.
+ * Mike Rylander <miker at esilibrary.com.com>
+ *
+ * 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.
+ *
+ */
+
+BEGIN;
+
+-- Handy management functions for the new materialized reporting view
+
+CREATE OR REPLACE FUNCTION reporter.disable_materialized_simple_record_trigger () RETURNS VOID AS $$
+ DROP TRIGGER zzz_update_materialized_simple_record_tgr ON metabib.full_rec;
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION reporter.enable_materialized_simple_record_trigger () RETURNS VOID AS $$
+
+ TRUNCATE TABLE reporter.materialized_simple_record;
+
+ INSERT INTO reporter.materialized_simple_record
+ (id,fingerprint,quality,tcn_source,tcn_value,title,author,publisher,pubdate,isbn,issn)
+ SELECT DISTINCT ON (id) * FROM reporter.old_super_simple_record;
+
+ CREATE TRIGGER zzz_update_materialized_simple_record_tgr
+ AFTER INSERT OR UPDATE OR DELETE ON metabib.full_rec
+ FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_sync();
+
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION reporter.refresh_materialized_simple_record () RETURNS VOID AS $$
+ SELECT reporter.disable_materialized_simple_record_trigger();
+ SELECT reporter.enable_materialized_simple_record_trigger();
+$$ LANGUAGE SQL;
+
+COMMIT;
Modified: branches/rel_1_2/Open-ILS/src/sql/Pg/reporter-schema.sql
===================================================================
--- branches/rel_1_2/Open-ILS/src/sql/Pg/reporter-schema.sql 2008-05-31 05:20:44 UTC (rev 9742)
+++ branches/rel_1_2/Open-ILS/src/sql/Pg/reporter-schema.sql 2008-05-31 05:21:29 UTC (rev 9743)
@@ -185,6 +185,29 @@
AFTER INSERT OR UPDATE OR DELETE ON metabib.full_rec
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.full_rec;
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION reporter.enable_materialized_simple_record_trigger () RETURNS VOID AS $$
+
+ TRUNCATE TABLE reporter.materialized_simple_record;
+
+ INSERT INTO reporter.materialized_simple_record
+ (id,fingerprint,quality,tcn_source,tcn_value,title,author,publisher,pubdate,isbn,issn)
+ SELECT DISTINCT ON (id) * FROM reporter.old_super_simple_record;
+
+ CREATE TRIGGER zzz_update_materialized_simple_record_tgr
+ AFTER INSERT OR UPDATE OR DELETE ON metabib.full_rec
+ FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_sync();
+
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION reporter.refresh_materialized_simple_record () RETURNS VOID AS $$
+ SELECT reporter.disable_materialized_simple_record_trigger();
+ SELECT reporter.enable_materialized_simple_record_trigger();
+$$ LANGUAGE SQL;
+
CREATE OR REPLACE VIEW reporter.demographic AS
SELECT u.id,
u.dob,
More information about the open-ils-commits
mailing list