From b0b43758c0820faed309161a47b5197cf43345eb Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 19 May 2010 19:24:48 +0000 Subject: [PATCH] make the first_word index normalizer return a not-null value when given an empty string; remove naco and date normalizers from all identifier fields git-svn-id: svn://svn.open-ils.org/ILS/trunk@16453 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/020.schema.functions.sql | 2 +- .../src/sql/Pg/upgrade/0268.schema.identifier-cleanup.sql | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0268.schema.identifier-cleanup.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 3c1d7de43..2ffb67a68 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -65,7 +65,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0267'); -- miker +INSERT INTO config.upgrade_log (version) VALUES ('0268'); -- miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/020.schema.functions.sql b/Open-ILS/src/sql/Pg/020.schema.functions.sql index 89a8fece9..965d9a247 100644 --- a/Open-ILS/src/sql/Pg/020.schema.functions.sql +++ b/Open-ILS/src/sql/Pg/020.schema.functions.sql @@ -85,7 +85,7 @@ CREATE OR REPLACE FUNCTION public.naco_normalize( TEXT ) RETURNS TEXT AS $func$ $func$ LANGUAGE 'sql' STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION public.first_word ( TEXT ) RETURNS TEXT AS $$ - SELECT SUBSTRING( $1 FROM $_$^\S+$_$); + SELECT COALESCE(SUBSTRING( $1 FROM $_$^\S+$_$), ''); $$ LANGUAGE SQL STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION public.naco_normalize_keep_comma( TEXT ) RETURNS TEXT AS $func$ diff --git a/Open-ILS/src/sql/Pg/upgrade/0268.schema.identifier-cleanup.sql b/Open-ILS/src/sql/Pg/upgrade/0268.schema.identifier-cleanup.sql new file mode 100644 index 000000000..30f04f2aa --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0268.schema.identifier-cleanup.sql @@ -0,0 +1,12 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0268'); -- miker + +CREATE OR REPLACE FUNCTION public.first_word ( TEXT ) RETURNS TEXT AS $$ + SELECT COALESCE(SUBSTRING( $1 FROM $_$^\S+$_$), ''); +$$ LANGUAGE SQL STRICT IMMUTABLE; + +DELETE FROM config.metabib_field_index_norm_map WHERE norm IN (1,2) and field > 16; + +COMMIT; + -- 2.11.0