From e8c551480b52bb4e76af61574f8d954fef7f280e Mon Sep 17 00:00:00 2001
From: pkupczyk <pkupczyk>
Date: Mon, 10 Sep 2012 08:01:25 +0000
Subject: [PATCH] BIS-180 - openBIS AS becomes unresponsive when performing
 batch sample updates - fix test db creation scripts

SVN: 26562
---
 .../sourceTest/sql/postgresql/120/finish-120.sql | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/openbis/sourceTest/sql/postgresql/120/finish-120.sql b/openbis/sourceTest/sql/postgresql/120/finish-120.sql
index b8800a6bb13..99ac57c75a7 100644
--- a/openbis/sourceTest/sql/postgresql/120/finish-120.sql
+++ b/openbis/sourceTest/sql/postgresql/120/finish-120.sql
@@ -347,8 +347,8 @@ CREATE RULE data_parent_child_delete AS ON DELETE TO data_set_relationships_all
 CREATE RULE data_parent_child_insert AS ON INSERT TO data_set_relationships_all WHERE (new.del_id IS NULL) DO (INSERT INTO data_set_relationships_history (id, main_data_id, relation_type, data_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('data_set_relationships_history_id_seq'::regclass), new.data_id_parent, 'PARENT'::text, new.data_id_child, (SELECT data_all.code FROM data_all WHERE ((data_all.id)::bigint = (new.data_id_child)::bigint)), new.pers_id_author, new.modification_timestamp); INSERT INTO data_set_relationships_history (id, main_data_id, relation_type, data_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('data_set_relationships_history_id_seq'::regclass), new.data_id_child, 'CHILD'::text, new.data_id_parent, (SELECT data_all.code FROM data_all WHERE ((data_all.id)::bigint = (new.data_id_parent)::bigint)), new.pers_id_author, new.modification_timestamp); );
 CREATE RULE data_parent_child_revert_update AS ON UPDATE TO data_set_relationships_all WHERE ((old.del_id IS NOT NULL) AND (new.del_id IS NULL)) DO (INSERT INTO data_set_relationships_history (id, main_data_id, relation_type, data_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('data_set_relationships_history_id_seq'::regclass), new.data_id_parent, 'PARENT'::text, new.data_id_child, (SELECT data_all.code FROM data_all WHERE ((data_all.id)::bigint = (new.data_id_child)::bigint)), new.pers_id_author, new.modification_timestamp); INSERT INTO data_set_relationships_history (id, main_data_id, relation_type, data_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('data_set_relationships_history_id_seq'::regclass), new.data_id_child, 'CHILD'::text, new.data_id_parent, (SELECT data_all.code FROM data_all WHERE ((data_all.id)::bigint = (new.data_id_parent)::bigint)), new.pers_id_author, new.modification_timestamp); );
 CREATE RULE data_parent_child_update AS ON UPDATE TO data_set_relationships_all WHERE ((new.del_id IS NOT NULL) AND (old.del_id IS NULL)) DO UPDATE data_set_relationships_history SET valid_until_timestamp = now() WHERE (((((data_set_relationships_history.main_data_id)::bigint = (old.data_id_parent)::bigint) AND ((data_set_relationships_history.data_id)::bigint = (old.data_id_child)::bigint)) AND (data_set_relationships_history.valid_until_timestamp IS NULL)) OR ((((data_set_relationships_history.main_data_id)::bigint = (old.data_id_child)::bigint) AND ((data_set_relationships_history.data_id)::bigint = (old.data_id_parent)::bigint)) AND (data_set_relationships_history.valid_until_timestamp IS NULL)));
-CREATE RULE data_set_properties_delete AS ON DELETE TO data_set_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO data_set_properties_history (id, ds_id, dstpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('data_set_property_id_seq'::regclass), old.ds_id, old.dstpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
-CREATE RULE data_set_properties_update AS ON UPDATE TO data_set_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO data_set_properties_history (id, ds_id, dstpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('data_set_property_id_seq'::regclass), old.ds_id, old.dstpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE data_set_properties_delete AS ON DELETE TO data_set_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO data_set_properties_history (id, ds_id, dstpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('data_set_property_id_seq'::regclass), old.ds_id, old.dstpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE data_set_properties_update AS ON UPDATE TO data_set_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO data_set_properties_history (id, ds_id, dstpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('data_set_property_id_seq'::regclass), old.ds_id, old.dstpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
 CREATE RULE data_set_relationships_delete AS ON DELETE TO data_set_relationships DO INSTEAD DELETE FROM data_set_relationships_all WHERE (((data_set_relationships_all.data_id_parent)::bigint = (old.data_id_parent)::bigint) AND ((data_set_relationships_all.data_id_child)::bigint = (old.data_id_child)::bigint));
 CREATE RULE data_set_relationships_insert AS ON INSERT TO data_set_relationships DO INSTEAD INSERT INTO data_set_relationships_all (data_id_parent, data_id_child, pers_id_author, registration_timestamp, modification_timestamp) VALUES (new.data_id_parent, new.data_id_child, new.pers_id_author, new.registration_timestamp, new.modification_timestamp);
 CREATE RULE data_set_relationships_update AS ON UPDATE TO data_set_relationships DO INSTEAD UPDATE data_set_relationships_all SET data_id_parent = new.data_id_parent, data_id_child = new.data_id_child, del_id = new.del_id, pers_id_author = new.pers_id_author, registration_timestamp = new.registration_timestamp, modification_timestamp = new.modification_timestamp WHERE (((data_set_relationships_all.data_id_parent)::bigint = (new.data_id_parent)::bigint) AND ((data_set_relationships_all.data_id_child)::bigint = (new.data_id_child)::bigint));
@@ -368,13 +368,13 @@ CREATE RULE experiment_project_delete AS ON DELETE TO experiments_all WHERE (old
 CREATE RULE experiment_project_insert AS ON INSERT TO experiments_all WHERE (new.proj_id IS NOT NULL) DO (INSERT INTO project_relationships_history (id, main_proj_id, relation_type, expe_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('project_relationships_history_id_seq'::regclass), new.proj_id, 'OWNER'::text, new.id, new.perm_id, new.pers_id_modifier, new.modification_timestamp); INSERT INTO experiment_relationships_history (id, main_expe_id, relation_type, proj_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('experiment_relationships_history_id_seq'::regclass), new.id, 'OWNED'::text, new.proj_id, (SELECT projects.code FROM projects WHERE ((projects.id)::bigint = (new.proj_id)::bigint)), new.pers_id_modifier, new.modification_timestamp); );
 CREATE RULE experiment_project_remove_update AS ON UPDATE TO experiments_all WHERE ((old.proj_id IS NOT NULL) AND (new.proj_id IS NULL)) DO (UPDATE project_relationships_history SET valid_until_timestamp = new.modification_timestamp WHERE ((((project_relationships_history.main_proj_id)::bigint = (old.proj_id)::bigint) AND ((project_relationships_history.expe_id)::bigint = (old.id)::bigint)) AND (project_relationships_history.valid_until_timestamp IS NULL)); UPDATE experiment_relationships_history SET valid_until_timestamp = new.modification_timestamp WHERE ((((experiment_relationships_history.main_expe_id)::bigint = (old.id)::bigint) AND ((experiment_relationships_history.proj_id)::bigint = (old.proj_id)::bigint)) AND (experiment_relationships_history.valid_until_timestamp IS NULL)); );
 CREATE RULE experiment_project_update AS ON UPDATE TO experiments_all WHERE ((((old.proj_id)::bigint <> (new.proj_id)::bigint) OR (old.proj_id IS NULL)) AND (new.proj_id IS NOT NULL)) DO (UPDATE project_relationships_history SET valid_until_timestamp = new.modification_timestamp WHERE ((((project_relationships_history.main_proj_id)::bigint = (old.proj_id)::bigint) AND ((project_relationships_history.expe_id)::bigint = (old.id)::bigint)) AND (project_relationships_history.valid_until_timestamp IS NULL)); INSERT INTO project_relationships_history (id, main_proj_id, relation_type, expe_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('project_relationships_history_id_seq'::regclass), new.proj_id, 'OWNER'::text, new.id, new.perm_id, new.pers_id_modifier, new.modification_timestamp); UPDATE experiment_relationships_history SET valid_until_timestamp = new.modification_timestamp WHERE ((((experiment_relationships_history.main_expe_id)::bigint = (old.id)::bigint) AND ((experiment_relationships_history.proj_id)::bigint = (old.proj_id)::bigint)) AND (experiment_relationships_history.valid_until_timestamp IS NULL)); INSERT INTO experiment_relationships_history (id, main_expe_id, relation_type, proj_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('experiment_relationships_history_id_seq'::regclass), new.id, 'OWNED'::text, new.proj_id, (SELECT projects.code FROM projects WHERE ((projects.id)::bigint = (new.proj_id)::bigint)), new.pers_id_modifier, new.modification_timestamp); );
-CREATE RULE experiment_properties_delete AS ON DELETE TO experiment_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO experiment_properties_history (id, expe_id, etpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('experiment_property_id_seq'::regclass), old.expe_id, old.etpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
-CREATE RULE experiment_properties_update AS ON UPDATE TO experiment_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO experiment_properties_history (id, expe_id, etpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('experiment_property_id_seq'::regclass), old.expe_id, old.etpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE experiment_properties_delete AS ON DELETE TO experiment_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO experiment_properties_history (id, expe_id, etpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('experiment_property_id_seq'::regclass), old.expe_id, old.etpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE experiment_properties_update AS ON UPDATE TO experiment_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO experiment_properties_history (id, expe_id, etpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('experiment_property_id_seq'::regclass), old.expe_id, old.etpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
 CREATE RULE experiment_update AS ON UPDATE TO experiments DO INSTEAD UPDATE experiments_all SET code = new.code, del_id = new.del_id, exty_id = new.exty_id, is_public = new.is_public, modification_timestamp = new.modification_timestamp, perm_id = new.perm_id, pers_id_registerer = new.pers_id_registerer, pers_id_modifier = new.pers_id_modifier, proj_id = new.proj_id, registration_timestamp = new.registration_timestamp WHERE ((experiments_all.id)::bigint = (new.id)::bigint);
 CREATE RULE experiments_deleted_delete AS ON DELETE TO experiments_deleted DO INSTEAD DELETE FROM experiments_all WHERE ((experiments_all.id)::bigint = (old.id)::bigint);
 CREATE RULE experiments_deleted_update AS ON UPDATE TO experiments_deleted DO INSTEAD UPDATE experiments_all SET del_id = new.del_id, modification_timestamp = new.modification_timestamp WHERE ((experiments_all.id)::bigint = (new.id)::bigint);
-CREATE RULE material_properties_delete AS ON DELETE TO material_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO material_properties_history (id, mate_id, mtpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('material_property_id_seq'::regclass), old.mate_id, old.mtpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
-CREATE RULE material_properties_update AS ON UPDATE TO material_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO material_properties_history (id, mate_id, mtpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('material_property_id_seq'::regclass), old.mate_id, old.mtpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE material_properties_delete AS ON DELETE TO material_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO material_properties_history (id, mate_id, mtpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('material_property_id_seq'::regclass), old.mate_id, old.mtpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE material_properties_update AS ON UPDATE TO material_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO material_properties_history (id, mate_id, mtpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('material_property_id_seq'::regclass), old.mate_id, old.mtpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
 CREATE RULE project_space_insert AS ON INSERT TO projects WHERE (new.space_id IS NOT NULL) DO INSERT INTO project_relationships_history (id, main_proj_id, relation_type, space_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('project_relationships_history_id_seq'::regclass), new.id, 'OWNED'::text, new.space_id, (SELECT spaces.code FROM spaces WHERE ((spaces.id)::bigint = (new.space_id)::bigint)), new.pers_id_modifier, new.modification_timestamp);
 CREATE RULE project_space_remove_update AS ON UPDATE TO projects WHERE ((old.space_id IS NOT NULL) AND (new.space_id IS NULL)) DO UPDATE project_relationships_history SET valid_until_timestamp = new.modification_timestamp WHERE ((((project_relationships_history.main_proj_id)::bigint = (old.id)::bigint) AND ((project_relationships_history.space_id)::bigint = (old.space_id)::bigint)) AND (project_relationships_history.valid_until_timestamp IS NULL));
 CREATE RULE project_space_update AS ON UPDATE TO projects WHERE ((((old.space_id)::bigint <> (new.space_id)::bigint) OR (old.space_id IS NULL)) AND (new.space_id IS NOT NULL)) DO (UPDATE project_relationships_history SET valid_until_timestamp = new.modification_timestamp WHERE ((((project_relationships_history.main_proj_id)::bigint = (old.id)::bigint) AND ((project_relationships_history.space_id)::bigint = (old.space_id)::bigint)) AND (project_relationships_history.valid_until_timestamp IS NULL)); INSERT INTO project_relationships_history (id, main_proj_id, relation_type, space_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('project_relationships_history_id_seq'::regclass), new.id, 'OWNED'::text, new.space_id, (SELECT spaces.code FROM spaces WHERE ((spaces.id)::bigint = (new.space_id)::bigint)), new.pers_id_modifier, new.modification_timestamp); );
@@ -394,8 +394,8 @@ CREATE RULE sample_parent_child_delete AS ON DELETE TO sample_relationships_all
 CREATE RULE sample_parent_child_insert AS ON INSERT TO sample_relationships_all WHERE (new.del_id IS NULL) DO (INSERT INTO sample_relationships_history (id, main_samp_id, relation_type, samp_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('sample_relationships_history_id_seq'::regclass), new.sample_id_parent, 'PARENT'::text, new.sample_id_child, (SELECT samples_all.perm_id FROM samples_all WHERE ((samples_all.id)::bigint = (new.sample_id_child)::bigint)), new.pers_id_author, new.modification_timestamp); INSERT INTO sample_relationships_history (id, main_samp_id, relation_type, samp_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('sample_relationships_history_id_seq'::regclass), new.sample_id_child, 'CHILD'::text, new.sample_id_parent, (SELECT samples_all.perm_id FROM samples_all WHERE ((samples_all.id)::bigint = (new.sample_id_parent)::bigint)), new.pers_id_author, new.modification_timestamp); );
 CREATE RULE sample_parent_child_revert_update AS ON UPDATE TO sample_relationships_all WHERE ((new.del_id IS NULL) AND (old.del_id IS NOT NULL)) DO (INSERT INTO sample_relationships_history (id, main_samp_id, relation_type, samp_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('sample_relationships_history_id_seq'::regclass), new.sample_id_parent, 'PARENT'::text, new.sample_id_child, (SELECT samples_all.perm_id FROM samples_all WHERE ((samples_all.id)::bigint = (new.sample_id_child)::bigint)), new.pers_id_author, new.modification_timestamp); INSERT INTO sample_relationships_history (id, main_samp_id, relation_type, samp_id, entity_perm_id, pers_id_author, valid_from_timestamp) VALUES (nextval('sample_relationships_history_id_seq'::regclass), new.sample_id_child, 'CHILD'::text, new.sample_id_parent, (SELECT samples_all.perm_id FROM samples_all WHERE ((samples_all.id)::bigint = (new.sample_id_parent)::bigint)), new.pers_id_author, new.modification_timestamp); );
 CREATE RULE sample_parent_child_update AS ON UPDATE TO sample_relationships_all WHERE ((new.del_id IS NOT NULL) AND (old.del_id IS NULL)) DO UPDATE sample_relationships_history SET valid_until_timestamp = now() WHERE (((((sample_relationships_history.main_samp_id)::bigint = (old.sample_id_parent)::bigint) AND ((sample_relationships_history.samp_id)::bigint = (old.sample_id_child)::bigint)) AND (sample_relationships_history.valid_until_timestamp IS NULL)) OR ((((sample_relationships_history.main_samp_id)::bigint = (old.sample_id_child)::bigint) AND ((sample_relationships_history.samp_id)::bigint = (old.sample_id_parent)::bigint)) AND (sample_relationships_history.valid_until_timestamp IS NULL)));
-CREATE RULE sample_properties_delete AS ON DELETE TO sample_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO sample_properties_history (id, samp_id, stpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('sample_property_id_seq'::regclass), old.samp_id, old.stpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
-CREATE RULE sample_properties_update AS ON UPDATE TO sample_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\x5c78656662666264'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO sample_properties_history (id, samp_id, stpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('sample_property_id_seq'::regclass), old.samp_id, old.stpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE sample_properties_delete AS ON DELETE TO sample_properties WHERE ((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) OR (old.cvte_id IS NOT NULL)) OR (old.mate_prop_id IS NOT NULL)) DO INSERT INTO sample_properties_history (id, samp_id, stpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('sample_property_id_seq'::regclass), old.samp_id, old.stpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
+CREATE RULE sample_properties_update AS ON UPDATE TO sample_properties WHERE (((((old.value IS NOT NULL) AND (decode("substring"((old.value)::text, 1, 1), 'escape'::text) <> '\xefbfbd'::bytea)) AND ((old.value)::text <> (new.value)::text)) OR ((old.cvte_id IS NOT NULL) AND ((old.cvte_id)::bigint <> (new.cvte_id)::bigint))) OR ((old.mate_prop_id IS NOT NULL) AND ((old.mate_prop_id)::bigint <> (new.mate_prop_id)::bigint))) DO INSERT INTO sample_properties_history (id, samp_id, stpt_id, value, vocabulary_term, material, pers_id_author, valid_from_timestamp, valid_until_timestamp) VALUES (nextval('sample_property_id_seq'::regclass), old.samp_id, old.stpt_id, old.value, (SELECT ((((t.code)::text || ' ['::text) || (v.code)::text) || ']'::text) FROM (controlled_vocabulary_terms t JOIN controlled_vocabularies v ON (((t.covo_id)::bigint = (v.id)::bigint))) WHERE ((t.id)::bigint = (old.cvte_id)::bigint)), (SELECT ((((m.code)::text || ' ['::text) || (mt.code)::text) || ']'::text) FROM (materials m JOIN material_types mt ON (((m.maty_id)::bigint = (mt.id)::bigint))) WHERE ((m.id)::bigint = (old.mate_prop_id)::bigint)), old.pers_id_author, old.modification_timestamp, now());
 CREATE RULE sample_relationships_delete AS ON DELETE TO sample_relationships DO INSTEAD DELETE FROM sample_relationships_all WHERE ((sample_relationships_all.id)::bigint = (old.id)::bigint);
 CREATE RULE sample_relationships_insert AS ON INSERT TO sample_relationships DO INSTEAD INSERT INTO sample_relationships_all (id, sample_id_parent, relationship_id, sample_id_child, pers_id_author, registration_timestamp, modification_timestamp) VALUES (new.id, new.sample_id_parent, new.relationship_id, new.sample_id_child, new.pers_id_author, new.registration_timestamp, new.modification_timestamp);
 CREATE RULE sample_relationships_update AS ON UPDATE TO sample_relationships DO INSTEAD UPDATE sample_relationships_all SET sample_id_parent = new.sample_id_parent, relationship_id = new.relationship_id, sample_id_child = new.sample_id_child, del_id = new.del_id, pers_id_author = new.pers_id_author, registration_timestamp = new.registration_timestamp, modification_timestamp = new.modification_timestamp WHERE ((sample_relationships_all.id)::bigint = (new.id)::bigint);
-- 
GitLab