/* * * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at license/ESCIDOC.LICENSE * or http://www.escidoc.de/license. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at license/ESCIDOC.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2006-2010 Fachinformationszentrum Karlsruhe Gesellschaft * für wissenschaftlich-technische Information mbH and Max-Planck- * Gesellschaft zur Förderung der Wissenschaft e.V. * All rights reserved. Use is subject to license terms. */ /** * Script for creation of trigger that sets value to max 2000 chars in the filter cache * * @author Natasa Bulatovic * @created: 27.04.2009 * NOTE: run this script before create_index.sql script **/ -- Language: plpgsql -- DROP LANGUAGE plpgsql; CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler VALIDATOR plpgsql_validator; -- Function: list.set_value_length() -- DROP FUNCTION list.set_value_length(); CREATE OR REPLACE FUNCTION list.set_value_length() RETURNS trigger AS $BODY$BEGIN NEW.value := substring(NEW.value, 1, 2000); return NEW; END $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100; ALTER FUNCTION list.set_value_length() OWNER TO postgres; -- Trigger: BIUR_Value_Reset on list.property -- DROP TRIGGER "BIUR_Value_Reset" ON list.property; CREATE TRIGGER "BIUR_Value_Reset" BEFORE INSERT OR UPDATE ON list.property FOR EACH ROW EXECUTE PROCEDURE list.set_value_length(); --run the following command just to make sure cache does correct its work afterwards update list.property set value=substring(value, 1, 2000) where length(value)> 2000;