From 9984b11f6766106f6d8c5b2e05331f9cf2dbf571 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 8 Apr 2014 14:09:46 -0700 Subject: [PATCH] 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 --- Open-ILS/src/sql/Pg/030.schema.metabib.sql | 6 +++++- .../Pg/upgrade/XXXX.schema.browse-ingest-null-protect.sql | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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 -- 2.43.2