LP#1947173: Clean up bad cataloging pot hole
authorMike Rylander <mrylander@gmail.com>
Wed, 20 Oct 2021 20:22:37 +0000 (16:22 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 5 Nov 2021 16:04:47 +0000 (12:04 -0400)
If a MARC record has effectively empty fields (all space or punctuation)
then it's possible to stumble over a NULL text array when parsing
content for the symspell dictionary.  This commit checks for that
condition and returns early to avoid the problem.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/src/sql/Pg/300.schema.staged_search.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.symspell-speed-ingest.sql

index d06c56b..dcdb5af 100644 (file)
@@ -1971,6 +1971,9 @@ BEGIN
 
         input := evergreen.lowercase(full_input);
         word_list := ARRAY_AGG(x) FROM search.symspell_parse_words_distinct(input) x;
+        IF word_list IS NULL THEN
+            RETURN;
+        END IF;
     
         IF CARDINALITY(word_list) > 1 AND include_phrases THEN
             RETURN QUERY SELECT * FROM search.symspell_build_raw_entry(input, source_class, TRUE, prefix_length, maxED);
index 1501357..e0e660f 100644 (file)
@@ -135,6 +135,9 @@ BEGIN
 
         input := evergreen.lowercase(full_input);
         word_list := ARRAY_AGG(x) FROM search.symspell_parse_words_distinct(input) x;
+        IF word_list IS NULL THEN
+            RETURN;
+        END IF;
     
         IF CARDINALITY(word_list) > 1 AND include_phrases THEN
             RETURN QUERY SELECT * FROM search.symspell_build_raw_entry(input, source_class, TRUE, prefix_length, maxED);