From: Galen Charlton Date: Tue, 8 Apr 2014 21:09:46 +0000 (-0700) Subject: LP#1303940: don't attempt to store NULL values in keyword, browse, or facet indexes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9984b11f6766106f6d8c5b2e05331f9cf2dbf571;p=evergreen%2Fpines.git LP#1303940: don't attempt to store NULL values in keyword, browse, or facet indexes This patch implements a suggestion by Dan Wells and builds on Mike Rylander's patch to skip inserting into field_entry and facet indexes values that have been normalized to NULL. As a side effect, the following warning will no longer be logged when attempting to store such values in the facet index: WARNING: Use of uninitialized value in subroutine entry at /usr/lib/perl/5.18/Unicode/Normalize.pm line 80. CONTEXT: PL/Perl function "force_unicode_normal_form" Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql index 97750e7e07..12421022c6 100644 --- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql +++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql @@ -809,6 +809,10 @@ BEGIN END IF; FOR ind_data IN SELECT * FROM biblio.extract_metabib_field_entry( bib_id ) LOOP + + -- don't store what has been normalized away + CONTINUE WHEN ind_data.value IS NULL; + IF ind_data.field < 0 THEN ind_data.field = -1 * ind_data.field; END IF; @@ -826,7 +830,7 @@ BEGIN -- expensive to add a comparison of index_vector to index_vector -- to the WHERE clause below. - CONTINUE WHEN ind_data.value IS NULL OR ind_data.sort_value IS NULL; + CONTINUE WHEN ind_data.sort_value IS NULL; value_prepped := metabib.browse_normalize(ind_data.value, ind_data.field); SELECT INTO mbe_row * FROM metabib.browse_entry diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.browse-ingest-null-protect.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.browse-ingest-null-protect.sql index 4a3759deaa..beace90017 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.browse-ingest-null-protect.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.browse-ingest-null-protect.sql @@ -35,6 +35,10 @@ BEGIN END IF; FOR ind_data IN SELECT * FROM biblio.extract_metabib_field_entry( bib_id ) LOOP + + -- don't store what has been normalized away + CONTINUE WHEN ind_data.value IS NULL; + IF ind_data.field < 0 THEN ind_data.field = -1 * ind_data.field; END IF; @@ -52,7 +56,7 @@ BEGIN -- expensive to add a comparison of index_vector to index_vector -- to the WHERE clause below. - CONTINUE WHEN ind_data.value IS NULL OR ind_data.sort_value IS NULL; + CONTINUE WHEN ind_data.sort_value IS NULL; value_prepped := metabib.browse_normalize(ind_data.value, ind_data.field); SELECT INTO mbe_row * FROM metabib.browse_entry