]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/version-upgrade/2.10.10-2.10.11-upgrade-db.sql
LP#1772028 Add some FK violation functions just in case they are missing
[Evergreen.git] / Open-ILS / src / sql / Pg / version-upgrade / 2.10.10-2.10.11-upgrade-db.sql
1 --Upgrade Script for 2.10.10 to 2.10.11
2 \set eg_version '''2.10.11'''
3 BEGIN;
4
5 SELECT evergreen.upgrade_deps_block_check('1030', :eg_version);
6
7 CREATE OR REPLACE FUNCTION evergreen.oils_xslt_process(TEXT, TEXT) RETURNS TEXT AS $func$
8   use strict;
9
10   use XML::LibXSLT;
11   use XML::LibXML;
12
13   my $doc = shift;
14   my $xslt = shift;
15
16   # The following approach uses the older XML::LibXML 1.69 / XML::LibXSLT 1.68
17   # methods of parsing XML documents and stylesheets, in the hopes of broader
18   # compatibility with distributions
19   my $parser = $_SHARED{'_xslt_process'}{parsers}{xml} || XML::LibXML->new();
20
21   # Cache the XML parser, if we do not already have one
22   $_SHARED{'_xslt_process'}{parsers}{xml} = $parser
23     unless ($_SHARED{'_xslt_process'}{parsers}{xml});
24
25   my $xslt_parser = $_SHARED{'_xslt_process'}{parsers}{xslt} || XML::LibXSLT->new();
26
27   # Cache the XSLT processor, if we do not already have one
28   $_SHARED{'_xslt_process'}{parsers}{xslt} = $xslt_parser
29     unless ($_SHARED{'_xslt_process'}{parsers}{xslt});
30
31   my $stylesheet = $_SHARED{'_xslt_process'}{stylesheets}{$xslt} ||
32     $xslt_parser->parse_stylesheet( $parser->parse_string($xslt) );
33
34   $_SHARED{'_xslt_process'}{stylesheets}{$xslt} = $stylesheet
35     unless ($_SHARED{'_xslt_process'}{stylesheets}{$xslt});
36
37   return $stylesheet->output_as_chars(
38     $stylesheet->transform(
39       $parser->parse_string($doc)
40     )
41   );
42
43 $func$ LANGUAGE 'plperlu' STRICT IMMUTABLE;
44
45 COMMIT;