From: Mike Rylander Date: Fri, 24 Jun 2011 14:42:15 +0000 (-0400) Subject: Address LP#801129, in-db unAPI failure X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f1df2c98b9acd4cb0f95d38e2efee164b85f9b99;p=working%2FEvergreen.git Address LP#801129, in-db unAPI failure Start the cleanup of improper use of XMLAGG in the unAPI stored procs first identified by Bill Erickson in https://bugs.launchpad.net/bugs/801129 Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql index c12a3a864d..19c6f9b85b 100644 --- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql +++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql @@ -232,7 +232,7 @@ CREATE OR REPLACE FUNCTION unapi.holdings_xml (bid BIGINT, ouid INT, org TEXT, d name holdings, XMLATTRIBUTES( CASE WHEN $8 THEN 'http://open-ils.org/spec/holdings/v1' ELSE NULL END AS xmlns, - CASE WHEN ('bre' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN 'tag:open-ils.org:U2@bre/' || $1 || '/' || $3 ELSE NULL END AS id + CASE WHEN ('bre' = ANY ($5)) THEN 'tag:open-ils.org:U2@bre/' || $1 || '/' || $3 ELSE NULL END AS id ), XMLELEMENT( name counts, @@ -253,40 +253,43 @@ CREATE OR REPLACE FUNCTION unapi.holdings_xml (bid BIGINT, ouid INT, org TEXT, d ), CASE WHEN ('bmp' = ANY ($5)) THEN - XMLELEMENT( name monograph_parts, - XMLAGG((SELECT unapi.bmp( id, 'xml', 'monograph_part', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'bre'), 'holdings_xml'), $3, $4, $6, $7, FALSE) FROM biblio.monograph_part WHERE record = $1)) + XMLELEMENT( + name monograph_parts, + (SELECT XMLAGG(bmp) FROM ( + SELECT unapi.bmp( id, 'xml', 'monograph_part', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'bre'), 'holdings_xml'), $3, $4, $6, $7, FALSE) + FROM biblio.monograph_part + WHERE record = $1 + )x) ) ELSE NULL END, - CASE WHEN ('acn' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN - XMLELEMENT( - name volumes, - (SELECT XMLAGG(acn) FROM ( - SELECT unapi.acn(acn.id,'xml','volume',array_remove_item_by_value( evergreen.array_remove_item_by_value('{acn,auri}'::TEXT[] || $5,'holdings_xml'),'bre'), $3, $4, $6, $7, FALSE) - FROM asset.call_number acn - WHERE acn.record = $1 - AND EXISTS ( - SELECT 1 - FROM asset.copy acp - JOIN actor.org_unit_descendants( - $2, - (COALESCE( - $4, - (SELECT aout.depth - FROM actor.org_unit_type aout - JOIN actor.org_unit aou ON (aou.ou_type = aout.id AND aou.id = $2) - ) - )) - ) aoud ON (acp.circ_lib = aoud.id) - LIMIT 1 - ) - ORDER BY label_sortkey - LIMIT $6 - OFFSET $7 - )x) - ) - ELSE NULL END, - CASE WHEN ('ssub' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN + XMLELEMENT( + name volumes, + (SELECT XMLAGG(acn) FROM ( + SELECT unapi.acn(acn.id,'xml','volume',array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'holdings_xml'),'bre'), $3, $4, $6, $7, FALSE) + FROM asset.call_number acn + WHERE acn.record = $1 + AND EXISTS ( + SELECT 1 + FROM asset.copy acp + JOIN actor.org_unit_descendants( + $2, + (COALESCE( + $4, + (SELECT aout.depth + FROM actor.org_unit_type aout + JOIN actor.org_unit aou ON (aou.ou_type = aout.id AND aou.id = $2) + ) + )) + ) aoud ON (acp.circ_lib = aoud.id) + LIMIT 1 + ) + ORDER BY label_sortkey + LIMIT $6 + OFFSET $7 + )x) + ), + CASE WHEN ('ssub' = ANY ($5)) THEN XMLELEMENT( name subscriptions, (SELECT XMLAGG(ssub) FROM (