[open-ils-commits] r16853 - in trunk/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jul 6 12:14:21 EDT 2010
Author: miker
Date: 2010-07-06 12:14:18 -0400 (Tue, 06 Jul 2010)
New Revision: 16853
Modified:
trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
trunk/Open-ILS/src/sql/Pg/upgrade/0324.schema.usr_visible_circ_copies.sql
Log:
use SQL function for speed, instead of PLPGSQL
Modified: trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2010-07-06 16:00:08 UTC (rev 16852)
+++ trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2010-07-06 16:14:18 UTC (rev 16853)
@@ -616,15 +616,9 @@
END;
$func$ LANGUAGE PLPGSQL;
-CREATE OR REPLACE FUNCTION action.usr_visible_circ_copies( user_id INTEGER ) RETURNS SETOF INTEGER AS $$
- DECLARE
- copy INTEGER;
- BEGIN
- FOR copy IN SELECT DISTINCT(target_copy) FROM action.usr_visible_circs(user_id) LOOP
- RETURN NEXT copy;
- END LOOP;
- END;
-$$ LANGUAGE plpgsql;
+CREATE OR REPLACE FUNCTION action.usr_visible_circ_copies( INTEGER ) RETURNS SETOF BIGINT AS $$
+ SELECT DISTINCT(target_copy) FROM action.usr_visible_circs($1)
+$$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION action.usr_visible_holds (usr_id INT) RETURNS SETOF action.hold_request AS $func$
DECLARE
Modified: trunk/Open-ILS/src/sql/Pg/upgrade/0324.schema.usr_visible_circ_copies.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0324.schema.usr_visible_circ_copies.sql 2010-07-06 16:00:08 UTC (rev 16852)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0324.schema.usr_visible_circ_copies.sql 2010-07-06 16:14:18 UTC (rev 16853)
@@ -1,3 +1,5 @@
+DROP FUNCTION action.usr_visible_circ_copies( INTEGER ); -- Ignore me if I fail
+
BEGIN;
INSERT INTO config.upgrade_log (version) VALUES ('0324');
@@ -3,13 +5,7 @@
-- returns the distinct set of target copy IDs from a user's visible circulation history
-CREATE OR REPLACE FUNCTION action.usr_visible_circ_copies( user_id INTEGER ) RETURNS SETOF INTEGER AS $$
- DECLARE
- copy INTEGER;
- BEGIN
- FOR copy IN SELECT DISTINCT(target_copy) FROM action.usr_visible_circs(user_id) LOOP
- RETURN NEXT copy;
- END LOOP;
- END;
-$$ LANGUAGE plpgsql;
+CREATE OR REPLACE FUNCTION action.usr_visible_circ_copies( INTEGER ) RETURNS SETOF BIGINT AS $$
+ SELECT DISTINCT(target_copy) FROM action.usr_visible_circs($1)
+$$ LANGUAGE SQL;
COMMIT;
More information about the open-ils-commits
mailing list