LP#2004055: Stamp Upgrade Script
authorJason Boyer <JBoyer@equinoxOLI.org>
Wed, 17 May 2023 16:06:31 +0000 (12:06 -0400)
committerJason Boyer <JBoyer@equinoxOLI.org>
Wed, 17 May 2023 20:28:53 +0000 (16:28 -0400)
Signed-off-by: Jason Boyer <JBoyer@equinoxOLI.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1378.function.safer_highlight.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.function.safer_highlight.sql [deleted file]

index 4dcbad7..2e04cf2 100644 (file)
@@ -92,7 +92,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 ('1377', :eg_version); -- miker / Dyrcona / JBoyer
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1378', :eg_version); -- miker / gmcharlt / JBoyer
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1378.function.safer_highlight.sql b/Open-ILS/src/sql/Pg/upgrade/1378.function.safer_highlight.sql
new file mode 100644 (file)
index 0000000..c3cbb0d
--- /dev/null
@@ -0,0 +1,48 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1378', :eg_version);
+
+CREATE OR REPLACE FUNCTION search.highlight_display_fields(
+    rid         BIGINT,
+    tsq_map     TEXT, -- '(a | b) & c' => '1,2,3,4', ...
+    css_class   TEXT DEFAULT 'oils_SH',
+    hl_all      BOOL DEFAULT TRUE,
+    minwords    INT DEFAULT 5,
+    maxwords    INT DEFAULT 25,
+    shortwords  INT DEFAULT 0,
+    maxfrags    INT DEFAULT 0,
+    delimiter   TEXT DEFAULT ' ... '
+) RETURNS SETOF search.highlight_result AS $f$
+DECLARE
+    tsq         TEXT;
+    fields      TEXT;
+    afields     INT[];
+    seen        INT[];
+BEGIN
+
+    FOR tsq, fields IN SELECT key, value FROM each(tsq_map::HSTORE) LOOP
+        SELECT  ARRAY_AGG(unnest::INT) INTO afields
+          FROM  unnest(regexp_split_to_array(fields,','));
+        seen := seen || afields;
+
+        RETURN QUERY
+            SELECT * FROM search.highlight_display_fields_impl(
+                rid, tsq, afields, css_class, hl_all,minwords,
+                maxwords, shortwords, maxfrags, delimiter
+            );
+    END LOOP;
+
+    RETURN QUERY
+        SELECT  id,
+                source,
+                field,
+                evergreen.escape_for_html(value) AS value,
+                evergreen.escape_for_html(value) AS highlight
+          FROM  metabib.display_entry
+          WHERE source = rid
+                AND NOT (field = ANY (seen));
+END;
+$f$ LANGUAGE PLPGSQL ROWS 10;
+
+COMMIT;
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.safer_highlight.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.safer_highlight.sql
deleted file mode 100644 (file)
index f61e516..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-BEGIN;
-
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE FUNCTION search.highlight_display_fields(
-    rid         BIGINT,
-    tsq_map     TEXT, -- '(a | b) & c' => '1,2,3,4', ...
-    css_class   TEXT DEFAULT 'oils_SH',
-    hl_all      BOOL DEFAULT TRUE,
-    minwords    INT DEFAULT 5,
-    maxwords    INT DEFAULT 25,
-    shortwords  INT DEFAULT 0,
-    maxfrags    INT DEFAULT 0,
-    delimiter   TEXT DEFAULT ' ... '
-) RETURNS SETOF search.highlight_result AS $f$
-DECLARE
-    tsq         TEXT;
-    fields      TEXT;
-    afields     INT[];
-    seen        INT[];
-BEGIN
-
-    FOR tsq, fields IN SELECT key, value FROM each(tsq_map::HSTORE) LOOP
-        SELECT  ARRAY_AGG(unnest::INT) INTO afields
-          FROM  unnest(regexp_split_to_array(fields,','));
-        seen := seen || afields;
-
-        RETURN QUERY
-            SELECT * FROM search.highlight_display_fields_impl(
-                rid, tsq, afields, css_class, hl_all,minwords,
-                maxwords, shortwords, maxfrags, delimiter
-            );
-    END LOOP;
-
-    RETURN QUERY
-        SELECT  id,
-                source,
-                field,
-                evergreen.escape_for_html(value) AS value,
-                evergreen.escape_for_html(value) AS highlight
-          FROM  metabib.display_entry
-          WHERE source = rid
-                AND NOT (field = ANY (seen));
-END;
-$f$ LANGUAGE PLPGSQL ROWS 10;
-
-COMMIT;
-