]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/110.hold_matrix.sql
Stamped upgrade script for "lp 823496: do not fail to index personal names that have...
[Evergreen.git] / Open-ILS / src / sql / Pg / 110.hold_matrix.sql
1 /*
2
3 -- If, for some reason, you need to reload this chunk of the schema
4 -- just use the following two statements to remove the tables before
5 -- running the rest of the file.  See 950.data.seed-values.sql for
6 -- the one default entry to add back to config.hold_matrix_matchpoint.
7
8 DROP TABLE config.hold_matrix_matchpoint CASCADE;
9 DROP TABLE config.hold_matrix_test CASCADE;
10
11 */
12
13 BEGIN;
14
15
16 --
17 --                 ****** Which ruleset and tests to use *******
18 --
19 -- * Most specific range for org_unit and grp wins.
20 --
21 -- * circ_modifier match takes precidence over marc_type match, if circ_modifier is set here
22 --
23 -- * marc_type is first checked against the circ_as_type from the copy, then the item type from the marc record
24 --
25 -- * If neither circ_modifier nor marc_type is set (both are NULLABLE) then the entry defines the default
26 --   ruleset and tests for the OU + group (like BOOK in PINES)
27 --
28
29
30
31 CREATE TABLE config.hold_matrix_matchpoint (
32     id                      SERIAL    PRIMARY KEY,
33     active                  BOOL    NOT NULL DEFAULT TRUE,
34     strict_ou_match         BOOL    NOT NULL DEFAULT FALSE,
35     -- Match Fields
36     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"
37     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"
38     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"
39     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"
40     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"
41     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
42     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
43     circ_modifier           TEXT    REFERENCES config.circ_modifier (code) DEFERRABLE INITIALLY DEFERRED,
44     marc_type               TEXT,
45     marc_form               TEXT,
46     marc_bib_level          TEXT,
47     marc_vr_format          TEXT,
48     juvenile_flag           BOOL,
49     ref_flag                BOOL,
50     item_age                INTERVAL,
51     -- "Result" Fields
52     holdable                BOOL    NOT NULL DEFAULT TRUE,                -- Hard "can't hold" flag requiring an override
53     distance_is_from_owner  BOOL    NOT NULL DEFAULT FALSE,                -- How to calculate transit_range.  True means owning lib, false means copy circ lib
54     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
55     max_holds               INT,                            -- Total hold requests must be less than this, NULL means skip (always pass)
56     include_frozen_holds    BOOL    NOT NULL DEFAULT TRUE,                -- Include frozen hold requests in the count for max_holds test
57     stop_blocked_user       BOOL    NOT NULL DEFAULT FALSE,                -- Stop users who cannot check out items from placing holds
58     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
59 );
60
61 -- Nulls don't count for a constraint match, so we have to coalesce them into something that does.
62 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;
63
64 CREATE OR REPLACE FUNCTION action.find_hold_matrix_matchpoint(pickup_ou integer, request_ou integer, match_item bigint, match_user integer, match_requestor integer)
65   RETURNS integer AS
66 $func$
67 DECLARE
68     requestor_object    actor.usr%ROWTYPE;
69     user_object         actor.usr%ROWTYPE;
70     item_object         asset.copy%ROWTYPE;
71     item_cn_object      asset.call_number%ROWTYPE;
72     my_item_age         INTERVAL;
73     rec_descriptor      metabib.rec_descriptor%ROWTYPE;
74     matchpoint          config.hold_matrix_matchpoint%ROWTYPE;
75     weights             config.hold_matrix_weights%ROWTYPE;
76     denominator         NUMERIC(6,2);
77 BEGIN
78     SELECT INTO user_object         * FROM actor.usr                WHERE id = match_user;
79     SELECT INTO requestor_object    * FROM actor.usr                WHERE id = match_requestor;
80     SELECT INTO item_object         * FROM asset.copy               WHERE id = match_item;
81     SELECT INTO item_cn_object      * FROM asset.call_number        WHERE id = item_object.call_number;
82     SELECT INTO rec_descriptor      * FROM metabib.rec_descriptor   WHERE record = item_cn_object.record;
83
84     SELECT INTO my_item_age age(coalesce(item_object.active_date, now()));
85
86     -- The item's owner should probably be the one determining if the item is holdable
87     -- How to decide that is debatable. Decided to default to the circ library (where the item lives)
88     -- This flag will allow for setting it to the owning library (where the call number "lives")
89     PERFORM * FROM config.internal_flag WHERE name = 'circ.holds.weight_owner_not_circ' AND enabled;
90
91     -- Grab the closest set circ weight setting.
92     IF NOT FOUND THEN
93         -- Default to circ library
94         SELECT INTO weights hw.*
95           FROM config.weight_assoc wa
96                JOIN config.hold_matrix_weights hw ON (hw.id = wa.hold_weights)
97                JOIN actor.org_unit_ancestors_distance( item_object.circ_lib ) d ON (wa.org_unit = d.id)
98           WHERE active
99           ORDER BY d.distance
100           LIMIT 1;
101     ELSE
102         -- Flag is set, use owning library
103         SELECT INTO weights hw.*
104           FROM config.weight_assoc wa
105                JOIN config.hold_matrix_weights hw ON (hw.id = wa.hold_weights)
106                JOIN actor.org_unit_ancestors_distance( item_cn_object.owning_lib ) d ON (wa.org_unit = d.id)
107           WHERE active
108           ORDER BY d.distance
109           LIMIT 1;
110     END IF;
111
112     -- No weights? Bad admin! Defaults to handle that anyway.
113     IF weights.id IS NULL THEN
114         weights.user_home_ou    := 5.0;
115         weights.request_ou      := 5.0;
116         weights.pickup_ou       := 5.0;
117         weights.item_owning_ou  := 5.0;
118         weights.item_circ_ou    := 5.0;
119         weights.usr_grp         := 7.0;
120         weights.requestor_grp   := 8.0;
121         weights.circ_modifier   := 4.0;
122         weights.marc_type       := 3.0;
123         weights.marc_form       := 2.0;
124         weights.marc_bib_level  := 1.0;
125         weights.marc_vr_format  := 1.0;
126         weights.juvenile_flag   := 4.0;
127         weights.ref_flag        := 0.0;
128         weights.item_age        := 0.0;
129     END IF;
130
131     -- Determine the max (expected) depth (+1) of the org tree and max depth of the permisson tree
132     -- If you break your org tree with funky parenting this may be wrong
133     -- Note: This CTE is duplicated in the find_circ_matrix_matchpoint function, and it may be a good idea to split it off to a function
134     -- We use one denominator for all tree-based checks for when permission groups and org units have the same weighting
135     WITH all_distance(distance) AS (
136             SELECT depth AS distance FROM actor.org_unit_type
137         UNION
138             SELECT distance AS distance FROM permission.grp_ancestors_distance((SELECT id FROM permission.grp_tree WHERE parent IS NULL))
139         )
140     SELECT INTO denominator MAX(distance) + 1 FROM all_distance;
141
142     -- To ATTEMPT to make this work like it used to, make it reverse the user/requestor profile ids.
143     -- This may be better implemented as part of the upgrade script?
144     -- Set usr_grp = requestor_grp, requestor_grp = 1 or something when this flag is already set
145     -- Then remove this flag, of course.
146     PERFORM * FROM config.internal_flag WHERE name = 'circ.holds.usr_not_requestor' AND enabled;
147
148     IF FOUND THEN
149         -- Note: This, to me, is REALLY hacky. I put it in anyway.
150         -- If you can't tell, this is a single call swap on two variables.
151         SELECT INTO user_object.profile, requestor_object.profile
152                     requestor_object.profile, user_object.profile;
153     END IF;
154
155     -- Select the winning matchpoint into the matchpoint variable for returning
156     SELECT INTO matchpoint m.*
157       FROM  config.hold_matrix_matchpoint m
158             /*LEFT*/ JOIN permission.grp_ancestors_distance( requestor_object.profile ) rpgad ON m.requestor_grp = rpgad.id
159             LEFT JOIN permission.grp_ancestors_distance( user_object.profile ) upgad ON m.usr_grp = upgad.id
160             LEFT JOIN actor.org_unit_ancestors_distance( pickup_ou ) puoua ON m.pickup_ou = puoua.id
161             LEFT JOIN actor.org_unit_ancestors_distance( request_ou ) rqoua ON m.request_ou = rqoua.id
162             LEFT JOIN actor.org_unit_ancestors_distance( item_cn_object.owning_lib ) cnoua ON m.item_owning_ou = cnoua.id
163             LEFT JOIN actor.org_unit_ancestors_distance( item_object.circ_lib ) iooua ON m.item_circ_ou = iooua.id
164             LEFT JOIN actor.org_unit_ancestors_distance( user_object.home_ou  ) uhoua ON m.user_home_ou = uhoua.id
165       WHERE m.active
166             -- Permission Groups
167          -- AND (m.requestor_grp        IS NULL OR upgad.id IS NOT NULL) -- Optional Requestor Group?
168             AND (m.usr_grp              IS NULL OR upgad.id IS NOT NULL)
169             -- Org Units
170             AND (m.pickup_ou            IS NULL OR (puoua.id IS NOT NULL AND (puoua.distance = 0 OR NOT m.strict_ou_match)))
171             AND (m.request_ou           IS NULL OR (rqoua.id IS NOT NULL AND (rqoua.distance = 0 OR NOT m.strict_ou_match)))
172             AND (m.item_owning_ou       IS NULL OR (cnoua.id IS NOT NULL AND (cnoua.distance = 0 OR NOT m.strict_ou_match)))
173             AND (m.item_circ_ou         IS NULL OR (iooua.id IS NOT NULL AND (iooua.distance = 0 OR NOT m.strict_ou_match)))
174             AND (m.user_home_ou         IS NULL OR (uhoua.id IS NOT NULL AND (uhoua.distance = 0 OR NOT m.strict_ou_match)))
175             -- Static User Checks
176             AND (m.juvenile_flag        IS NULL OR m.juvenile_flag = user_object.juvenile)
177             -- Static Item Checks
178             AND (m.circ_modifier        IS NULL OR m.circ_modifier = item_object.circ_modifier)
179             AND (m.marc_type            IS NULL OR m.marc_type = COALESCE(item_object.circ_as_type, rec_descriptor.item_type))
180             AND (m.marc_form            IS NULL OR m.marc_form = rec_descriptor.item_form)
181             AND (m.marc_bib_level       IS NULL OR m.marc_bib_level = rec_descriptor.bib_level)
182             AND (m.marc_vr_format       IS NULL OR m.marc_vr_format = rec_descriptor.vr_format)
183             AND (m.ref_flag             IS NULL OR m.ref_flag = item_object.ref)
184             AND (m.item_age             IS NULL OR (my_item_age IS NOT NULL AND m.item_age > my_item_age))
185       ORDER BY
186             -- Permission Groups
187             CASE WHEN rpgad.distance    IS NOT NULL THEN 2^(2*weights.requestor_grp - (rpgad.distance/denominator)) ELSE 0.0 END +
188             CASE WHEN upgad.distance    IS NOT NULL THEN 2^(2*weights.usr_grp - (upgad.distance/denominator)) ELSE 0.0 END +
189             -- Org Units
190             CASE WHEN puoua.distance    IS NOT NULL THEN 2^(2*weights.pickup_ou - (puoua.distance/denominator)) ELSE 0.0 END +
191             CASE WHEN rqoua.distance    IS NOT NULL THEN 2^(2*weights.request_ou - (rqoua.distance/denominator)) ELSE 0.0 END +
192             CASE WHEN cnoua.distance    IS NOT NULL THEN 2^(2*weights.item_owning_ou - (cnoua.distance/denominator)) ELSE 0.0 END +
193             CASE WHEN iooua.distance    IS NOT NULL THEN 2^(2*weights.item_circ_ou - (iooua.distance/denominator)) ELSE 0.0 END +
194             CASE WHEN uhoua.distance    IS NOT NULL THEN 2^(2*weights.user_home_ou - (uhoua.distance/denominator)) ELSE 0.0 END +
195             -- Static User Checks       -- Note: 4^x is equiv to 2^(2*x)
196             CASE WHEN m.juvenile_flag   IS NOT NULL THEN 4^weights.juvenile_flag ELSE 0.0 END +
197             -- Static Item Checks
198             CASE WHEN m.circ_modifier   IS NOT NULL THEN 4^weights.circ_modifier ELSE 0.0 END +
199             CASE WHEN m.marc_type       IS NOT NULL THEN 4^weights.marc_type ELSE 0.0 END +
200             CASE WHEN m.marc_form       IS NOT NULL THEN 4^weights.marc_form ELSE 0.0 END +
201             CASE WHEN m.marc_vr_format  IS NOT NULL THEN 4^weights.marc_vr_format ELSE 0.0 END +
202             CASE WHEN m.ref_flag        IS NOT NULL THEN 4^weights.ref_flag ELSE 0.0 END +
203             -- Item age has a slight adjustment to weight based on value.
204             -- This should ensure that a shorter age limit comes first when all else is equal.
205             -- NOTE: This assumes that intervals will normally be in days.
206             CASE WHEN m.item_age            IS NOT NULL THEN 4^weights.item_age - 86400/EXTRACT(EPOCH FROM m.item_age) ELSE 0.0 END DESC,
207             -- Final sort on id, so that if two rules have the same sorting in the previous sort they have a defined order
208             -- This prevents "we changed the table order by updating a rule, and we started getting different results"
209             m.id;
210
211     -- Return just the ID for now
212     RETURN matchpoint.id;
213 END;
214 $func$ LANGUAGE 'plpgsql';
215
216 CREATE TYPE action.matrix_test_result AS ( success BOOL, matchpoint INT, fail_part TEXT );
217 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$
218 DECLARE
219     matchpoint_id        INT;
220     user_object        actor.usr%ROWTYPE;
221     age_protect_object    config.rule_age_hold_protect%ROWTYPE;
222     standing_penalty    config.standing_penalty%ROWTYPE;
223     transit_range_ou_type    actor.org_unit_type%ROWTYPE;
224     transit_source        actor.org_unit%ROWTYPE;
225     item_object        asset.copy%ROWTYPE;
226     item_cn_object     asset.call_number%ROWTYPE;
227     ou_skip              actor.org_unit_setting%ROWTYPE;
228     result            action.matrix_test_result;
229     hold_test        config.hold_matrix_matchpoint%ROWTYPE;
230     use_active_date   TEXT;
231     age_protect_date  TIMESTAMP WITH TIME ZONE;
232     hold_count        INT;
233     hold_transit_prox    INT;
234     frozen_hold_count    INT;
235     context_org_list    INT[];
236     done            BOOL := FALSE;
237 BEGIN
238     SELECT INTO user_object * FROM actor.usr WHERE id = match_user;
239     SELECT INTO context_org_list ARRAY_ACCUM(id) FROM actor.org_unit_full_path( pickup_ou );
240
241     result.success := TRUE;
242
243     -- Fail if we couldn't find a user
244     IF user_object.id IS NULL THEN
245         result.fail_part := 'no_user';
246         result.success := FALSE;
247         done := TRUE;
248         RETURN NEXT result;
249         RETURN;
250     END IF;
251
252     SELECT INTO item_object * FROM asset.copy WHERE id = match_item;
253
254     -- Fail if we couldn't find a copy
255     IF item_object.id IS NULL THEN
256         result.fail_part := 'no_item';
257         result.success := FALSE;
258         done := TRUE;
259         RETURN NEXT result;
260         RETURN;
261     END IF;
262
263     SELECT INTO matchpoint_id action.find_hold_matrix_matchpoint(pickup_ou, request_ou, match_item, match_user, match_requestor);
264     result.matchpoint := matchpoint_id;
265
266     SELECT INTO ou_skip * FROM actor.org_unit_setting WHERE name = 'circ.holds.target_skip_me' AND org_unit = item_object.circ_lib;
267
268     -- Fail if the circ_lib for the item has circ.holds.target_skip_me set to true
269     IF ou_skip.id IS NOT NULL AND ou_skip.value = 'true' THEN
270         result.fail_part := 'circ.holds.target_skip_me';
271         result.success := FALSE;
272         done := TRUE;
273         RETURN NEXT result;
274         RETURN;
275     END IF;
276
277     -- Fail if user is barred
278     IF user_object.barred IS TRUE THEN
279         result.fail_part := 'actor.usr.barred';
280         result.success := FALSE;
281         done := TRUE;
282         RETURN NEXT result;
283         RETURN;
284     END IF;
285
286     -- Fail if we couldn't find any matchpoint (requires a default)
287     IF matchpoint_id IS NULL THEN
288         result.fail_part := 'no_matchpoint';
289         result.success := FALSE;
290         done := TRUE;
291         RETURN NEXT result;
292         RETURN;
293     END IF;
294
295     SELECT INTO hold_test * FROM config.hold_matrix_matchpoint WHERE id = matchpoint_id;
296
297     IF hold_test.holdable IS FALSE THEN
298         result.fail_part := 'config.hold_matrix_test.holdable';
299         result.success := FALSE;
300         done := TRUE;
301         RETURN NEXT result;
302     END IF;
303
304     IF hold_test.transit_range IS NOT NULL THEN
305         SELECT INTO transit_range_ou_type * FROM actor.org_unit_type WHERE id = hold_test.transit_range;
306         IF hold_test.distance_is_from_owner THEN
307             SELECT INTO transit_source ou.* FROM actor.org_unit ou JOIN asset.call_number cn ON (cn.owning_lib = ou.id) WHERE cn.id = item_object.call_number;
308         ELSE
309             SELECT INTO transit_source * FROM actor.org_unit WHERE id = item_object.circ_lib;
310         END IF;
311
312         PERFORM * FROM actor.org_unit_descendants( transit_source.id, transit_range_ou_type.depth ) WHERE id = pickup_ou;
313
314         IF NOT FOUND THEN
315             result.fail_part := 'transit_range';
316             result.success := FALSE;
317             done := TRUE;
318             RETURN NEXT result;
319         END IF;
320     END IF;
321  
322     FOR standing_penalty IN
323         SELECT  DISTINCT csp.*
324           FROM  actor.usr_standing_penalty usp
325                 JOIN config.standing_penalty csp ON (csp.id = usp.standing_penalty)
326           WHERE usr = match_user
327                 AND usp.org_unit IN ( SELECT * FROM unnest(context_org_list) )
328                 AND (usp.stop_date IS NULL or usp.stop_date > NOW())
329                 AND csp.block_list LIKE '%HOLD%' LOOP
330
331         result.fail_part := standing_penalty.name;
332         result.success := FALSE;
333         done := TRUE;
334         RETURN NEXT result;
335     END LOOP;
336
337     IF hold_test.stop_blocked_user IS TRUE THEN
338         FOR standing_penalty IN
339             SELECT  DISTINCT csp.*
340               FROM  actor.usr_standing_penalty usp
341                     JOIN config.standing_penalty csp ON (csp.id = usp.standing_penalty)
342               WHERE usr = match_user
343                     AND usp.org_unit IN ( SELECT * FROM unnest(context_org_list) )
344                     AND (usp.stop_date IS NULL or usp.stop_date > NOW())
345                     AND csp.block_list LIKE '%CIRC%' LOOP
346     
347             result.fail_part := standing_penalty.name;
348             result.success := FALSE;
349             done := TRUE;
350             RETURN NEXT result;
351         END LOOP;
352     END IF;
353
354     IF hold_test.max_holds IS NOT NULL AND NOT retargetting THEN
355         SELECT    INTO hold_count COUNT(*)
356           FROM    action.hold_request
357           WHERE    usr = match_user
358             AND fulfillment_time IS NULL
359             AND cancel_time IS NULL
360             AND CASE WHEN hold_test.include_frozen_holds THEN TRUE ELSE frozen IS FALSE END;
361
362         IF hold_count >= hold_test.max_holds THEN
363             result.fail_part := 'config.hold_matrix_test.max_holds';
364             result.success := FALSE;
365             done := TRUE;
366             RETURN NEXT result;
367         END IF;
368     END IF;
369
370     IF item_object.age_protect IS NOT NULL THEN
371         SELECT INTO age_protect_object * FROM config.rule_age_hold_protect WHERE id = item_object.age_protect;
372         IF hold_test.distance_is_from_owner THEN
373             SELECT INTO use_active_date value FROM actor.org_unit_ancestor_setting('circ.holds.age_protect.active_date', item_cn_object.owning_lib);
374         ELSE
375             SELECT INTO use_active_date value FROM actor.org_unit_ancestor_setting('circ.holds.age_protect.active_date', item_object.circ_lib);
376         END IF;
377         IF use_active_date = 'true' THEN
378             age_protect_date := COALESCE(item_object.active_date, NOW());
379         ELSE
380             age_protect_date := item_object.create_date;
381         END IF;
382         IF age_protect_date + age_protect_object.age > NOW() THEN
383             IF hold_test.distance_is_from_owner THEN
384                 SELECT INTO item_cn_object * FROM asset.call_number WHERE id = item_object.call_number;
385                 SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_cn_object.owning_lib AND to_org = pickup_ou;
386             ELSE
387                 SELECT INTO hold_transit_prox prox FROM actor.org_unit_proximity WHERE from_org = item_object.circ_lib AND to_org = pickup_ou;
388             END IF;
389
390             IF hold_transit_prox > age_protect_object.prox THEN
391                 result.fail_part := 'config.rule_age_hold_protect.prox';
392                 result.success := FALSE;
393                 done := TRUE;
394                 RETURN NEXT result;
395             END IF;
396         END IF;
397     END IF;
398
399     IF NOT done THEN
400         RETURN NEXT result;
401     END IF;
402
403     RETURN;
404 END;
405 $func$ LANGUAGE plpgsql;
406
407 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$
408     SELECT * FROM action.hold_request_permit_test( $1, $2, $3, $4, $5, FALSE );
409 $func$ LANGUAGE SQL;
410
411 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$
412     SELECT * FROM action.hold_request_permit_test( $1, $2, $3, $4, $5, TRUE );
413 $func$ LANGUAGE SQL;
414
415 COMMIT;
416