LP1820339: Vandelay Imports on Pg 10
authorJason Stephenson <jason@sigio.com>
Thu, 25 Apr 2019 22:11:59 +0000 (18:11 -0400)
committerJason Boyer <jboyer@library.in.gov>
Wed, 8 May 2019 14:18:56 +0000 (10:18 -0400)
The previous commit used a function that only exists in Pg 10, so it
would require everyone to upgrade PostgreSQL.

After some investigation, Ben Shum and I found a method that works on
Pg 9.4 through Pg 10 by putting the existing function into a
subselect as suggested by PostgreSQL documentation.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Ben Shum <ben@evergreener.net>
Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Open-ILS/src/sql/Pg/012.schema.vandelay.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1820339-pg10-vandelay.sql

index 5a11ac6..b22677c 100644 (file)
@@ -632,9 +632,9 @@ BEGIN
               FROM  (SELECT tag,
                             subfield,
                             CASE WHEN tag = '020' THEN -- caseless -- isbn
-                                LOWER((REGEXP_MATCH(value,$$^(\S{10,17})$$))[1] || '%')
+                                LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{10,17})$$))[1] || '%')
                             WHEN tag = '022' THEN -- caseless -- issn
-                                LOWER((REGEXP_MATCH(value,$$^(\S{4}[- ]?\S{4})$$))[1] || '%')
+                                LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{4}[- ]?\S{4})$$))[1] || '%')
                             WHEN tag = '024' THEN -- caseless -- upc (other)
                                 LOWER(value || '%')
                             ELSE
index 1f7416c..86b18ea 100644 (file)
@@ -16,9 +16,9 @@ BEGIN
               FROM  (SELECT tag,
                             subfield,
                             CASE WHEN tag = '020' THEN -- caseless -- isbn
-                                LOWER((REGEXP_MATCH(value,$$^(\S{10,17})$$))[1] || '%')
+                                LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{10,17})$$))[1] || '%')
                             WHEN tag = '022' THEN -- caseless -- issn
-                                LOWER((REGEXP_MATCH(value,$$^(\S{4}[- ]?\S{4})$$))[1] || '%')
+                                LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{4}[- ]?\S{4})$$))[1] || '%')
                             WHEN tag = '024' THEN -- caseless -- upc (other)
                                 LOWER(value || '%')
                             ELSE