[open-ils-commits] r16472 - in trunk/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri May 21 11:24:42 EDT 2010
Author: miker
Date: 2010-05-21 11:24:39 -0400 (Fri, 21 May 2010)
New Revision: 16472
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0271.schema.ingest-normalizer-json.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
Log:
use proper JSON, re ' vs "
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-05-21 15:09:13 UTC (rev 16471)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-05-21 15:24:39 UTC (rev 16472)
@@ -65,7 +65,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0270'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0271'); -- miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
@@ -737,43 +737,43 @@
CREATE OR REPLACE FUNCTION oils_tsearch2 () RETURNS TRIGGER AS $$
DECLARE
- normalizer RECORD;
- value TEXT := '';
+ normalizer RECORD;
+ value TEXT := '';
BEGIN
- IF NEW.index_vector = ''::tsvector THEN
- RETURN NEW;
- END IF;
+ IF NEW.index_vector = ''::tsvector THEN
+ RETURN NEW;
+ END IF;
- value := NEW.value;
+ value := NEW.value;
- IF TG_TABLE_NAME::TEXT ~ 'field_entry$' THEN
- FOR normalizer IN
- SELECT n.func AS func,
- n.param_count AS param_count,
- m.params AS params
- FROM config.index_normalizer n
- JOIN config.metabib_field_index_norm_map m ON (m.norm = n.id)
- WHERE field = NEW.field
- ORDER BY m.pos
- LOOP
- EXECUTE 'SELECT ' || normalizer.func || '(' ||
- quote_literal( value ) ||
- CASE
- WHEN normalizer.param_count > 0 THEN ',' || BTRIM(normalizer.params,'[]')
- ELSE ''
- END ||
- ')' INTO value;
+ IF TG_TABLE_NAME::TEXT ~ 'field_entry$' THEN
+ FOR normalizer IN
+ SELECT n.func AS func,
+ n.param_count AS param_count,
+ m.params AS params
+ FROM config.index_normalizer n
+ JOIN config.metabib_field_index_norm_map m ON (m.norm = n.id)
+ WHERE field = NEW.field
+ ORDER BY m.pos LOOP
+ EXECUTE 'SELECT ' || normalizer.func || '(' ||
+ quote_literal( value ) ||
+ CASE
+ WHEN normalizer.param_count > 0
+ THEN ',' || REPLACE(REPLACE(BTRIM(normalizer.params,'[]'),E'\'',E'\\\''),E'"',E'\'')
+ ELSE ''
+ END ||
+ ')' INTO value;
- END LOOP;
- END IF;
+ END LOOP;
+ END IF;
- IF REGEXP_REPLACE(VERSION(),E'^.+?(\\d+\\.\\d+).*?$',E'\\1')::FLOAT > 8.2 THEN
- NEW.index_vector = to_tsvector((TG_ARGV[0])::regconfig, value);
- ELSE
- NEW.index_vector = to_tsvector(TG_ARGV[0], value);
- END IF;
+ IF REGEXP_REPLACE(VERSION(),E'^.+?(\\d+\\.\\d+).*?$',E'\\1')::FLOAT > 8.2 THEN
+ NEW.index_vector = to_tsvector((TG_ARGV[0])::regconfig, value);
+ ELSE
+ NEW.index_vector = to_tsvector(TG_ARGV[0], value);
+ END IF;
- RETURN NEW;
+ RETURN NEW;
END;
$$ LANGUAGE PLPGSQL;
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0271.schema.ingest-normalizer-json.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0271.schema.ingest-normalizer-json.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0271.schema.ingest-normalizer-json.sql 2010-05-21 15:24:39 UTC (rev 16472)
@@ -0,0 +1,53 @@
+BEGIN;
+
+-- Create new expression type for IS [NOT] NULL
+
+INSERT INTO config.upgrade_log (version) VALUES ('0271'); -- miker
+
+UPDATE config.metabib_field_index_norm_map
+ SET params = REPLACE(params,E'\'','"')
+ WHERE params IS NOT NULL AND params <> '';
+
+CREATE OR REPLACE FUNCTION oils_tsearch2 () RETURNS TRIGGER AS $$
+DECLARE
+ normalizer RECORD;
+ value TEXT := '';
+BEGIN
+ IF NEW.index_vector = ''::tsvector THEN
+ RETURN NEW;
+ END IF;
+
+ value := NEW.value;
+
+ IF TG_TABLE_NAME::TEXT ~ 'field_entry$' THEN
+ FOR normalizer IN
+ SELECT n.func AS func,
+ n.param_count AS param_count,
+ m.params AS params
+ FROM config.index_normalizer n
+ JOIN config.metabib_field_index_norm_map m ON (m.norm = n.id)
+ WHERE field = NEW.field
+ ORDER BY m.pos
+ LOOP
+ EXECUTE 'SELECT ' || normalizer.func || '(' ||
+ quote_literal( value ) ||
+ CASE
+ WHEN normalizer.param_count > 0
+ THEN ',' || REPLACE(REPLACE(BTRIM(normalizer.params,'[]'),E'\'',E'\\\''),E'"',E'\'')
+ ELSE ''
+ END ||
+ ')' INTO value;
+ END LOOP;
+ END IF;
+
+ IF REGEXP_REPLACE(VERSION(),E'^.+?(\\d+\\.\\d+).*?$',E'\\1')::FLOAT > 8.2 THEN
+ NEW.index_vector = to_tsvector((TG_ARGV[0])::regconfig, value);
+ ELSE
+ NEW.index_vector = to_tsvector(TG_ARGV[0], value);
+ END IF;
+
+ RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
More information about the open-ils-commits
mailing list