[open-ils-commits] r19902 - in branches/rel_2_0/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Mar 29 14:00:07 EDT 2011
Author: miker
Date: 2011-03-29 14:00:02 -0400 (Tue, 29 Mar 2011)
New Revision: 19902
Added:
branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0505.schema.force_facets_to_NFC.sql
Modified:
branches/rel_2_0/Open-ILS/src/sql/Pg/002.functions.config.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/030.schema.metabib.sql
Log:
Force facet values to Unicode NFC to reduce spurious non-matches
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/002.functions.config.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/002.functions.config.sql 2011-03-29 17:57:25 UTC (rev 19901)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/002.functions.config.sql 2011-03-29 18:00:02 UTC (rev 19902)
@@ -482,6 +482,11 @@
END;
$func$ LANGUAGE PLPGSQL;
+CREATE OR REPLACE FUNCTION force_unicode_normal_form(string TEXT, form TEXT) RETURNS TEXT AS $func$
+use Unicode::Normalize 'normalize';
+return normalize($_[1],$_[0]); # reverse the params
+$func$ LANGUAGE PLPERLU;
+
CREATE OR REPLACE FUNCTION maintain_control_numbers() RETURNS TRIGGER AS $func$
use strict;
use MARC::Record;
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-03-29 17:57:25 UTC (rev 19901)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-03-29 18:00:02 UTC (rev 19902)
@@ -70,7 +70,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0502'); -- dbwells
+INSERT INTO config.upgrade_log (version) VALUES ('0505'); -- miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/030.schema.metabib.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/030.schema.metabib.sql 2011-03-29 17:57:25 UTC (rev 19901)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/030.schema.metabib.sql 2011-03-29 18:00:02 UTC (rev 19902)
@@ -135,7 +135,17 @@
CREATE INDEX metabib_facet_entry_value_idx ON metabib.facet_entry (SUBSTRING(value,1,1024));
CREATE INDEX metabib_facet_entry_source_idx ON metabib.facet_entry (source);
+CREATE OR REPLACE FUNCTION facet_force_nfc() RETURNS TRIGGER AS $$
+BEGIN
+ NEW.value := force_unicode_normal_form(NEW.value,'NFC');
+ RETURN NEW;
+END;
+$$ LANUAGE PLPGSQL;
+CREATE TRIGGER facet_force_nfc_tgr
+ BEFORE UPDATE OR INSERT ON metabib.facet_entry
+ FOR EACH ROW EXECUTE PROCEDURE facet_force_nfc();
+
CREATE TABLE metabib.rec_descriptor (
id BIGSERIAL PRIMARY KEY,
record BIGINT,
Copied: branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0505.schema.force_facets_to_NFC.sql (from rev 19899, trunk/Open-ILS/src/sql/Pg/upgrade/0505.schema.force_facets_to_NFC.sql)
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0505.schema.force_facets_to_NFC.sql (rev 0)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0505.schema.force_facets_to_NFC.sql 2011-03-29 18:00:02 UTC (rev 19902)
@@ -0,0 +1,24 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0505'); --miker
+
+CREATE OR REPLACE FUNCTION force_unicode_normal_form(string TEXT, form TEXT) RETURNS TEXT AS $func$
+use Unicode::Normalize 'normalize';
+return normalize($_[1],$_[0]); # reverse the params
+$func$ LANGUAGE PLPERLU;
+
+UPDATE metabib.facet_entry SET value = force_unicode_normal_form(value,'NFC');
+
+CREATE OR REPLACE FUNCTION facet_force_nfc() RETURNS TRIGGER AS $$
+BEGIN
+ NEW.value := force_unicode_normal_form(NEW.value,'NFC');
+ RETURN NEW;
+END;
+$$ LANUAGE PLPGSQL;
+
+CREATE TRIGGER facet_force_nfc_tgr
+ BEFORE UPDATE OR INSERT ON metabib.facet_entry
+ FOR EACH ROW EXECUTE PROCEDURE facet_force_nfc();
+
+COMMIT;
+
More information about the open-ils-commits
mailing list