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>
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
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