[open-ils-commits] r9741 - trunk/Open-ILS/src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat May 31 01:17:12 EDT 2008
Author: miker
Date: 2008-05-31 01:17:09 -0400 (Sat, 31 May 2008)
New Revision: 9741
Added:
trunk/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql
Modified:
trunk/Open-ILS/src/sql/Pg/reporter-schema.sql
Log:
some new management functions for the materialized reporting view
Added: trunk/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql 2008-05-31 05:17:09 UTC (rev 9741)
@@ -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: trunk/Open-ILS/src/sql/Pg/reporter-schema.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/reporter-schema.sql 2008-05-30 21:09:10 UTC (rev 9740)
+++ trunk/Open-ILS/src/sql/Pg/reporter-schema.sql 2008-05-31 05:17:09 UTC (rev 9741)
@@ -184,6 +184,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