[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch master updated. 906ba880fb73d2b477f94b7bda17f31d324403f1
Evergreen Git
git at git.evergreen-ils.org
Tue Mar 11 14:36:22 EDT 2014
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 906ba880fb73d2b477f94b7bda17f31d324403f1 (commit)
via 2542c713ea4a0d686d7b7ceae352929b60a80806 (commit)
from fcd7de207a1c6f97f53f8fbade62ab9385c9e113 (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 906ba880fb73d2b477f94b7bda17f31d324403f1
Author: Dan Wells <dbw2 at calvin.edu>
Date: Tue Mar 11 14:33:58 2014 -0400
LP#1277731: Stamping upgrade for hold_test_params
Signed-off-by: Dan Wells <dbw2 at calvin.edu>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 688d9b0..5efa89b 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,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 ('0872', :eg_version); -- miker/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0873', :eg_version); -- miker/dbwells
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.hold_test_params.sql b/Open-ILS/src/sql/Pg/upgrade/0873.function.hold_test_params.sql
similarity index 99%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.function.hold_test_params.sql
rename to Open-ILS/src/sql/Pg/upgrade/0873.function.hold_test_params.sql
index f51aa47..b285d88 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.hold_test_params.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0873.function.hold_test_params.sql
@@ -1,6 +1,6 @@
BEGIN;
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0873', :eg_version);
CREATE OR REPLACE FUNCTION action.find_hold_matrix_matchpoint(pickup_ou integer, request_ou integer, match_item bigint, match_user integer, match_requestor integer)
RETURNS integer AS
commit 2542c713ea4a0d686d7b7ceae352929b60a80806
Author: Mike Rylander <mrylander at gmail.com>
Date: Tue Mar 4 15:47:12 2014 -0500
LP#1277731: Disambiguate parameter/column names
Due to slightly different and more strict disabiguation rules
for parameters and column names in PLPGSQL in modern versions
of Postgres, our hold matrix functions were failing in 9.3.
This commit attempts to address that by declaring and using
aliases for parameters that share names with columns used in
in-line SQL.
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Dan Wells <dbw2 at calvin.edu>
diff --git a/Open-ILS/src/sql/Pg/110.hold_matrix.sql b/Open-ILS/src/sql/Pg/110.hold_matrix.sql
index 25ac264..8f6518b 100644
--- a/Open-ILS/src/sql/Pg/110.hold_matrix.sql
+++ b/Open-ILS/src/sql/Pg/110.hold_matrix.sql
@@ -74,6 +74,8 @@ DECLARE
matchpoint config.hold_matrix_matchpoint%ROWTYPE;
weights config.hold_matrix_weights%ROWTYPE;
denominator NUMERIC(6,2);
+ v_pickup_ou ALIAS FOR pickup_ou;
+ v_request_ou ALIAS FOR request_ou;
BEGIN
SELECT INTO user_object * FROM actor.usr WHERE id = match_user;
SELECT INTO requestor_object * FROM actor.usr WHERE id = match_requestor;
@@ -157,8 +159,8 @@ BEGIN
FROM config.hold_matrix_matchpoint m
/*LEFT*/ JOIN permission.grp_ancestors_distance( requestor_object.profile ) rpgad ON m.requestor_grp = rpgad.id
LEFT JOIN permission.grp_ancestors_distance( user_object.profile ) upgad ON m.usr_grp = upgad.id
- LEFT JOIN actor.org_unit_ancestors_distance( pickup_ou ) puoua ON m.pickup_ou = puoua.id
- LEFT JOIN actor.org_unit_ancestors_distance( request_ou ) rqoua ON m.request_ou = rqoua.id
+ LEFT JOIN actor.org_unit_ancestors_distance( v_pickup_ou ) puoua ON m.pickup_ou = puoua.id
+ LEFT JOIN actor.org_unit_ancestors_distance( v_request_ou ) rqoua ON m.request_ou = rqoua.id
LEFT JOIN actor.org_unit_ancestors_distance( item_cn_object.owning_lib ) cnoua ON m.item_owning_ou = cnoua.id
LEFT JOIN actor.org_unit_ancestors_distance( item_object.circ_lib ) iooua ON m.item_circ_ou = iooua.id
LEFT JOIN actor.org_unit_ancestors_distance( user_object.home_ou ) uhoua ON m.user_home_ou = uhoua.id
@@ -237,9 +239,11 @@ DECLARE
context_org_list INT[];
done BOOL := FALSE;
hold_penalty TEXT;
+ v_pickup_ou ALIAS FOR pickup_ou;
+ v_request_ou ALIAS FOR request_ou;
BEGIN
SELECT INTO user_object * FROM actor.usr WHERE id = match_user;
- SELECT INTO context_org_list ARRAY_AGG(id) FROM actor.org_unit_full_path( pickup_ou );
+ SELECT INTO context_org_list ARRAY_AGG(id) FROM actor.org_unit_full_path( v_pickup_ou );
result.success := TRUE;
@@ -270,7 +274,7 @@ BEGIN
RETURN;
END IF;
- SELECT INTO matchpoint_id action.find_hold_matrix_matchpoint(pickup_ou, request_ou, match_item, match_user, match_requestor);
+ SELECT INTO matchpoint_id action.find_hold_matrix_matchpoint(v_pickup_ou, v_request_ou, match_item, match_user, match_requestor);
result.matchpoint := matchpoint_id;
SELECT INTO ou_skip * FROM actor.org_unit_setting WHERE name = 'circ.holds.target_skip_me' AND org_unit = item_object.circ_lib;
@@ -344,7 +348,7 @@ BEGIN
SELECT INTO transit_source * FROM actor.org_unit WHERE id = item_object.circ_lib;
END IF;
- PERFORM * FROM actor.org_unit_descendants( transit_source.id, transit_range_ou_type.depth ) WHERE id = pickup_ou;
+ PERFORM * FROM actor.org_unit_descendants( transit_source.id, transit_range_ou_type.depth ) WHERE id = v_pickup_ou;
IF NOT FOUND THEN
result.fail_part := 'transit_range';
@@ -417,9 +421,9 @@ BEGIN
IF age_protect_date + age_protect_object.age > NOW() THEN
IF hold_test.distance_is_from_owner THEN
SELECT INTO item_cn_object * FROM asset.call_number WHERE id = item_object.call_number;
- SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_cn_object.owning_lib AND to_org = pickup_ou;
+ SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_cn_object.owning_lib AND to_org = v_pickup_ou;
ELSE
- SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_object.circ_lib AND to_org = pickup_ou;
+ SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_object.circ_lib AND to_org = v_pickup_ou;
END IF;
IF hold_transit_prox > age_protect_object.prox THEN
diff --git a/Open-ILS/src/sql/Pg/110.hold_matrix.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.hold_test_params.sql
similarity index 75%
copy from Open-ILS/src/sql/Pg/110.hold_matrix.sql
copy to Open-ILS/src/sql/Pg/upgrade/XXXX.function.hold_test_params.sql
index 25ac264..f51aa47 100644
--- a/Open-ILS/src/sql/Pg/110.hold_matrix.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.hold_test_params.sql
@@ -1,65 +1,6 @@
-/*
-
--- If, for some reason, you need to reload this chunk of the schema
--- just use the following two statements to remove the tables before
--- running the rest of the file. See 950.data.seed-values.sql for
--- the one default entry to add back to config.hold_matrix_matchpoint.
-
-DROP TABLE config.hold_matrix_matchpoint CASCADE;
-DROP TABLE config.hold_matrix_test CASCADE;
-
-*/
-
BEGIN;
-
---
--- ****** Which ruleset and tests to use *******
---
--- * Most specific range for org_unit and grp wins.
---
--- * circ_modifier match takes precidence over marc_type match, if circ_modifier is set here
---
--- * marc_type is first checked against the circ_as_type from the copy, then the item type from the marc record
---
--- * If neither circ_modifier nor marc_type is set (both are NULLABLE) then the entry defines the default
--- ruleset and tests for the OU + group (like BOOK in PINES)
---
-
-
-
-CREATE TABLE config.hold_matrix_matchpoint (
- id SERIAL PRIMARY KEY,
- active BOOL NOT NULL DEFAULT TRUE,
- strict_ou_match BOOL NOT NULL DEFAULT FALSE,
- -- Match Fields
- user_home_ou INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best"
- request_ou INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best"
- pickup_ou INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best"
- item_owning_ou INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best"
- item_circ_ou INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best"
- usr_grp INT REFERENCES permission.grp_tree (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top applicable group from the group tree; will need descendents and prox functions for filtering
- requestor_grp INT NOT NULL REFERENCES permission.grp_tree (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top applicable group from the group tree; will need descendents and prox functions for filtering
- circ_modifier TEXT REFERENCES config.circ_modifier (code) DEFERRABLE INITIALLY DEFERRED,
- marc_type TEXT,
- marc_form TEXT,
- marc_bib_level TEXT,
- marc_vr_format TEXT,
- juvenile_flag BOOL,
- ref_flag BOOL,
- item_age INTERVAL,
- -- "Result" Fields
- holdable BOOL NOT NULL DEFAULT TRUE, -- Hard "can't hold" flag requiring an override
- distance_is_from_owner BOOL NOT NULL DEFAULT FALSE, -- How to calculate transit_range. True means owning lib, false means copy circ lib
- transit_range INT REFERENCES actor.org_unit_type (id) DEFERRABLE INITIALLY DEFERRED, -- Can circ inside range of cn.owner/cp.circ_lib at depth of the org_unit_type specified here
- max_holds INT, -- Total hold requests must be less than this, NULL means skip (always pass)
- include_frozen_holds BOOL NOT NULL DEFAULT TRUE, -- Include frozen hold requests in the count for max_holds test
- stop_blocked_user BOOL NOT NULL DEFAULT FALSE, -- Stop users who cannot check out items from placing holds
- age_hold_protect_rule INT REFERENCES config.rule_age_hold_protect (id) DEFERRABLE INITIALLY DEFERRED -- still not sure we want to move this off the copy
-);
-
--- Nulls don't count for a constraint match, so we have to coalesce them into something that does.
-CREATE UNIQUE INDEX chmm_once_per_paramset ON config.hold_matrix_matchpoint (COALESCE(user_home_ou::TEXT, ''), COALESCE(request_ou::TEXT, ''), COALESCE(pickup_ou::TEXT, ''), COALESCE(item_owning_ou::TEXT, ''), COALESCE(item_circ_ou::TEXT, ''), COALESCE(usr_grp::TEXT, ''), COALESCE(requestor_grp::TEXT, ''), COALESCE(circ_modifier, ''), COALESCE(marc_type, ''), COALESCE(marc_form, ''), COALESCE(marc_bib_level, ''), COALESCE(marc_vr_format, ''), COALESCE(juvenile_flag::TEXT, ''), COALESCE(ref_flag::TEXT, ''), COALESCE(item_age::TEXT, '')) WHERE active;
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
CREATE OR REPLACE FUNCTION action.find_hold_matrix_matchpoint(pickup_ou integer, request_ou integer, match_item bigint, match_user integer, match_requestor integer)
RETURNS integer AS
@@ -74,6 +15,8 @@ DECLARE
matchpoint config.hold_matrix_matchpoint%ROWTYPE;
weights config.hold_matrix_weights%ROWTYPE;
denominator NUMERIC(6,2);
+ v_pickup_ou ALIAS FOR pickup_ou;
+ v_request_ou ALIAS FOR request_ou;
BEGIN
SELECT INTO user_object * FROM actor.usr WHERE id = match_user;
SELECT INTO requestor_object * FROM actor.usr WHERE id = match_requestor;
@@ -157,8 +100,8 @@ BEGIN
FROM config.hold_matrix_matchpoint m
/*LEFT*/ JOIN permission.grp_ancestors_distance( requestor_object.profile ) rpgad ON m.requestor_grp = rpgad.id
LEFT JOIN permission.grp_ancestors_distance( user_object.profile ) upgad ON m.usr_grp = upgad.id
- LEFT JOIN actor.org_unit_ancestors_distance( pickup_ou ) puoua ON m.pickup_ou = puoua.id
- LEFT JOIN actor.org_unit_ancestors_distance( request_ou ) rqoua ON m.request_ou = rqoua.id
+ LEFT JOIN actor.org_unit_ancestors_distance( v_pickup_ou ) puoua ON m.pickup_ou = puoua.id
+ LEFT JOIN actor.org_unit_ancestors_distance( v_request_ou ) rqoua ON m.request_ou = rqoua.id
LEFT JOIN actor.org_unit_ancestors_distance( item_cn_object.owning_lib ) cnoua ON m.item_owning_ou = cnoua.id
LEFT JOIN actor.org_unit_ancestors_distance( item_object.circ_lib ) iooua ON m.item_circ_ou = iooua.id
LEFT JOIN actor.org_unit_ancestors_distance( user_object.home_ou ) uhoua ON m.user_home_ou = uhoua.id
@@ -213,7 +156,6 @@ BEGIN
END;
$func$ LANGUAGE 'plpgsql';
-CREATE TYPE action.matrix_test_result AS ( success BOOL, matchpoint INT, fail_part TEXT );
CREATE OR REPLACE FUNCTION action.hold_request_permit_test( pickup_ou INT, request_ou INT, match_item BIGINT, match_user INT, match_requestor INT, retargetting BOOL ) RETURNS SETOF action.matrix_test_result AS $func$
DECLARE
matchpoint_id INT;
@@ -237,9 +179,11 @@ DECLARE
context_org_list INT[];
done BOOL := FALSE;
hold_penalty TEXT;
+ v_pickup_ou ALIAS FOR pickup_ou;
+ v_request_ou ALIAS FOR request_ou;
BEGIN
SELECT INTO user_object * FROM actor.usr WHERE id = match_user;
- SELECT INTO context_org_list ARRAY_AGG(id) FROM actor.org_unit_full_path( pickup_ou );
+ SELECT INTO context_org_list ARRAY_AGG(id) FROM actor.org_unit_full_path( v_pickup_ou );
result.success := TRUE;
@@ -270,7 +214,7 @@ BEGIN
RETURN;
END IF;
- SELECT INTO matchpoint_id action.find_hold_matrix_matchpoint(pickup_ou, request_ou, match_item, match_user, match_requestor);
+ SELECT INTO matchpoint_id action.find_hold_matrix_matchpoint(v_pickup_ou, v_request_ou, match_item, match_user, match_requestor);
result.matchpoint := matchpoint_id;
SELECT INTO ou_skip * FROM actor.org_unit_setting WHERE name = 'circ.holds.target_skip_me' AND org_unit = item_object.circ_lib;
@@ -344,7 +288,7 @@ BEGIN
SELECT INTO transit_source * FROM actor.org_unit WHERE id = item_object.circ_lib;
END IF;
- PERFORM * FROM actor.org_unit_descendants( transit_source.id, transit_range_ou_type.depth ) WHERE id = pickup_ou;
+ PERFORM * FROM actor.org_unit_descendants( transit_source.id, transit_range_ou_type.depth ) WHERE id = v_pickup_ou;
IF NOT FOUND THEN
result.fail_part := 'transit_range';
@@ -417,9 +361,9 @@ BEGIN
IF age_protect_date + age_protect_object.age > NOW() THEN
IF hold_test.distance_is_from_owner THEN
SELECT INTO item_cn_object * FROM asset.call_number WHERE id = item_object.call_number;
- SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_cn_object.owning_lib AND to_org = pickup_ou;
+ SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_cn_object.owning_lib AND to_org = v_pickup_ou;
ELSE
- SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_object.circ_lib AND to_org = pickup_ou;
+ SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_object.circ_lib AND to_org = v_pickup_ou;
END IF;
IF hold_transit_prox > age_protect_object.prox THEN
@@ -439,13 +383,5 @@ BEGIN
END;
$func$ LANGUAGE plpgsql;
-CREATE OR REPLACE FUNCTION action.hold_request_permit_test( pickup_ou INT, request_ou INT, match_item BIGINT, match_user INT, match_requestor INT ) RETURNS SETOF action.matrix_test_result AS $func$
- SELECT * FROM action.hold_request_permit_test( $1, $2, $3, $4, $5, FALSE );
-$func$ LANGUAGE SQL;
-
-CREATE OR REPLACE FUNCTION action.hold_retarget_permit_test( pickup_ou INT, request_ou INT, match_item BIGINT, match_user INT, match_requestor INT ) RETURNS SETOF action.matrix_test_result AS $func$
- SELECT * FROM action.hold_request_permit_test( $1, $2, $3, $4, $5, TRUE );
-$func$ LANGUAGE SQL;
-
COMMIT;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/110.hold_matrix.sql | 18 +++--
.../0873.function.hold_test_params.sql} | 88 +++-----------------
3 files changed, 24 insertions(+), 84 deletions(-)
copy Open-ILS/src/sql/Pg/{110.hold_matrix.sql => upgrade/0873.function.hold_test_params.sql} (75%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list