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