From 06ca13ebe069c68eff578418dfc6d4822a7c5c08 Mon Sep 17 00:00:00 2001 From: skidder Date: Wed, 2 Oct 2002 17:56:08 +0000 Subject: [PATCH] Field check constraints are now deleted automatically --- src/jrd/grant.gdl | 23 +++++ src/jrd/trig.h | 225 ++++++++++++++++++++++++++++++---------------- 2 files changed, 173 insertions(+), 75 deletions(-) diff --git a/src/jrd/grant.gdl b/src/jrd/grant.gdl index fbfd1b42c8..f7d2021081 100644 --- a/src/jrd/grant.gdl +++ b/src/jrd/grant.gdl @@ -553,6 +553,29 @@ for idx in RDB$INDICES cross else erase cnst; end_for; + +for cnst in RDB$RELATION_CONSTRAINTS cross + chk in RDB$CHECK_CONSTRAINTS over RDB$CONSTRAINT_NAME cross + dep in RDB$DEPENDENCIES with + cnst.RDB$RELATION_NAME = old.RDB$RELATION_NAME and + cnst.RDB$CONSTRAINT_TYPE = 'CHECK' and + chk.RDB$TRIGGER_NAME = dep.RDB$DEPENDENT_NAME and + dep.RDB$DEPENDENT_TYPE = 2 and + dep.RDB$DEPENDED_ON_TYPE = 0 and + dep.RDB$DEPENDED_ON_NAME = old.RDB$RELATION_NAME and + dep.RDB$FIELD_NAME = old.RDB$FIELD_NAME + + if any dep1 in RDB$DEPENDENCIES with + dep1.RDB$DEPENDENT_NAME = chk.RDB$TRIGGER_NAME and + dep1.RDB$DEPENDENT_TYPE = 2 and + dep1.RDB$DEPENDED_ON_TYPE = 0 and + dep1.RDB$DEPENDED_ON_NAME = old.RDB$RELATION_NAME and + dep1.RDB$FIELD_NAME NE old.RDB$FIELD_NAME + abort 1 + else + erase cnst; +end_for; + end; end_trigger message 1: "Cannot delete field being used in an integrity constraint."; diff --git a/src/jrd/trig.h b/src/jrd/trig.h index 3b30e985ac..569f5fa45b 100644 --- a/src/jrd/trig.h +++ b/src/jrd/trig.h @@ -1819,81 +1819,156 @@ static CONST TEXT trigger_23_msg_0 [] = "Cannot delete field being used in an in static CONST UCHAR FAR_VARIABLE trigger23[] = { blr_version5, - blr_begin, - blr_for, - blr_rse, 3, - blr_relation, 11, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'I', 'C', 'E', 'S', - 3, - blr_relation, 24, 'R', 'D', 'B', '$', 'R', 'E', 'L', 'A', 'T', 'I', 'O', - 'N', '_', 'C', 'O', 'N', 'S', 'T', 'R', 'A', 'I', 'N', 'T', 'S', 4, - blr_relation, 18, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'S', - 'E', 'G', 'M', 'E', 'N', 'T', 'S', 5, - blr_boolean, - blr_and, - blr_eql, - blr_field, 3, 17, 'R', 'D', 'B', '$', 'R', 'E', 'L', 'A', 'T', 'I', 'O', - 'N', '_', 'N', 'A', 'M', 'E', - blr_field, 0, 17, 'R', 'D', 'B', '$', 'R', 'E', 'L', 'A', 'T', 'I', 'O', - 'N', '_', 'N', 'A', 'M', 'E', - blr_and, - blr_eql, - blr_field, 3, 14, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'N', - 'A', 'M', 'E', - blr_field, 5, 14, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'N', - 'A', 'M', 'E', - blr_and, - blr_eql, - blr_field, 4, 14, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'N', - 'A', 'M', 'E', - blr_field, 5, 14, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'N', - 'A', 'M', 'E', - blr_and, - blr_eql, - blr_field, 5, 14, 'R', 'D', 'B', '$', 'F', 'I', 'E', 'L', 'D', '_', 'N', - 'A', 'M', 'E', - blr_field, 0, 14, 'R', 'D', 'B', '$', 'F', 'I', 'E', 'L', 'D', '_', 'N', - 'A', 'M', 'E', - blr_or, - blr_eql, - blr_field, 4, 19, 'R', 'D', 'B', '$', 'C', 'O', 'N', 'S', 'T', 'R', 'A', - 'I', 'N', 'T', '_', 'T', 'Y', 'P', 'E', - blr_literal, blr_text, 6, 0, 'U', 'N', 'I', 'Q', 'U', 'E', - blr_or, - blr_eql, - blr_field, 4, 19, 'R', 'D', 'B', '$', 'C', 'O', 'N', 'S', 'T', 'R', 'A', - 'I', 'N', 'T', '_', 'T', 'Y', 'P', 'E', - blr_literal, blr_text, 11, 0, 'F', 'O', 'R', 'E', 'I', 'G', 'N', 32, 'K', - 'E', 'Y', - blr_eql, - blr_field, 4, 19, 'R', 'D', 'B', '$', 'C', 'O', 'N', 'S', 'T', 'R', 'A', - 'I', 'N', 'T', '_', 'T', 'Y', 'P', 'E', - blr_literal, blr_text, 11, 0, 'P', 'R', 'I', 'M', 'A', 'R', 'Y', 32, 'K', - 'E', 'Y', - blr_end, - blr_begin, - blr_if, - blr_any, - blr_rse, 1, - blr_relation, 18, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'S', - 'E', 'G', 'M', 'E', 'N', 'T', 'S', 6, - blr_boolean, - blr_and, - blr_eql, - blr_field, 6, 14, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'N', - 'A', 'M', 'E', - blr_field, 5, 14, 'R', 'D', 'B', '$', 'I', 'N', 'D', 'E', 'X', '_', 'N', - 'A', 'M', 'E', - blr_neq, - blr_field, 6, 14, 'R', 'D', 'B', '$', 'F', 'I', 'E', 'L', 'D', '_', 'N', - 'A', 'M', 'E', - blr_field, 0, 14, 'R', 'D', 'B', '$', 'F', 'I', 'E', 'L', 'D', '_', 'N', - 'A', 'M', 'E', - blr_end, - blr_leave, 1, - blr_erase, 4, - blr_end, - blr_end, - blr_eoc, + blr_begin, + blr_for, + blr_rse, 3, + blr_relation, 11, 'R','D','B','$','I','N','D','I','C','E','S', 3, + blr_relation, 24, 'R','D','B','$','R','E','L','A','T','I','O','N','_','C', + 'O','N','S','T','R','A','I','N','T','S', 4, + blr_relation, 18, 'R','D','B','$','I','N','D','E','X','_','S','E','G','M', + 'E','N','T','S', 5, + blr_boolean, + blr_and, + blr_eql, + blr_field, 3, 17, 'R','D','B','$','R','E','L','A','T','I','O','N','_','N', + 'A','M','E', + blr_field, 0, 17, 'R','D','B','$','R','E','L','A','T','I','O','N','_','N', + 'A','M','E', + blr_and, + blr_eql, + blr_field, 3, 14, 'R','D','B','$','I','N','D','E','X','_','N','A','M','E', + blr_field, 5, 14, 'R','D','B','$','I','N','D','E','X','_','N','A','M','E', + blr_and, + blr_eql, + blr_field, 4, 14, 'R','D','B','$','I','N','D','E','X','_','N','A','M','E', + blr_field, 5, 14, 'R','D','B','$','I','N','D','E','X','_','N','A','M','E', + blr_and, + blr_eql, + blr_field, 5, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_field, 0, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_or, + blr_eql, + blr_field, 4, 19, 'R','D','B','$','C','O','N','S','T','R','A','I','N','T', + '_','T','Y','P','E', + blr_literal, blr_text, 6,0, 'U','N','I','Q','U','E', + blr_or, + blr_eql, + blr_field, 4, 19, 'R','D','B','$','C','O','N','S','T','R','A','I','N','T', + '_','T','Y','P','E', + blr_literal, blr_text, 11,0, 'F','O','R','E','I','G','N',32,'K','E','Y', + blr_eql, + blr_field, 4, 19, 'R','D','B','$','C','O','N','S','T','R','A','I','N','T', + '_','T','Y','P','E', + blr_literal, blr_text, 11,0, 'P','R','I','M','A','R','Y',32,'K','E','Y', + blr_end, + blr_begin, + blr_if, + blr_any, + blr_rse, 1, + blr_relation, 18, 'R','D','B','$','I','N','D','E','X','_','S','E','G','M', + 'E','N','T','S', 6, + blr_boolean, + blr_and, + blr_eql, + blr_field, 6, 14, 'R','D','B','$','I','N','D','E','X','_','N','A','M','E', + blr_field, 5, 14, 'R','D','B','$','I','N','D','E','X','_','N','A','M','E', + blr_neq, + blr_field, 6, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_field, 0, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_end, + blr_leave, 1, + blr_erase, 4, + blr_end, + blr_for, + blr_rse, 3, + blr_relation, 24, 'R','D','B','$','R','E','L','A','T','I','O','N','_','C', + 'O','N','S','T','R','A','I','N','T','S', 7, + blr_relation, 21, 'R','D','B','$','C','H','E','C','K','_','C','O','N','S', + 'T','R','A','I','N','T','S', 8, + blr_relation, 16, 'R','D','B','$','D','E','P','E','N','D','E','N','C','I', + 'E','S', 9, + blr_boolean, + blr_and, + blr_and, + blr_eql, + blr_field, 7, 17, 'R','D','B','$','R','E','L','A','T','I','O','N','_','N', + 'A','M','E', + blr_field, 0, 17, 'R','D','B','$','R','E','L','A','T','I','O','N','_','N', + 'A','M','E', + blr_and, + blr_eql, + blr_field, 7, 19, 'R','D','B','$','C','O','N','S','T','R','A','I','N','T', + '_','T','Y','P','E', + blr_literal, blr_text, 5,0, 'C','H','E','C','K', + blr_and, + blr_eql, + blr_field, 8, 16, 'R','D','B','$','T','R','I','G','G','E','R','_','N','A', + 'M','E', + blr_field, 9, 18, 'R','D','B','$','D','E','P','E','N','D','E','N','T','_', + 'N','A','M','E', + blr_and, + blr_eql, + blr_field, 9, 18, 'R','D','B','$','D','E','P','E','N','D','E','N','T','_', + 'T','Y','P','E', + blr_literal, blr_long, 0, 2,0,0,0, + blr_and, + blr_eql, + blr_field, 9, 20, 'R','D','B','$','D','E','P','E','N','D','E','D','_','O', + 'N','_','T','Y','P','E', + blr_literal, blr_long, 0, 0,0,0,0, + blr_and, + blr_eql, + blr_field, 9, 20, 'R','D','B','$','D','E','P','E','N','D','E','D','_','O', + 'N','_','N','A','M','E', + blr_field, 0, 17, 'R','D','B','$','R','E','L','A','T','I','O','N','_','N', + 'A','M','E', + blr_eql, + blr_field, 9, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_field, 0, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_eql, + blr_field, 8, 19, 'R','D','B','$','C','O','N','S','T','R','A','I','N','T', + '_','N','A','M','E', + blr_field, 7, 19, 'R','D','B','$','C','O','N','S','T','R','A','I','N','T', + '_','N','A','M','E', + blr_end, + blr_begin, + blr_if, + blr_any, + blr_rse, 1, + blr_relation, 16, 'R','D','B','$','D','E','P','E','N','D','E','N','C','I', + 'E','S', 10, + blr_boolean, + blr_and, + blr_eql, + blr_field, 10, 18, 'R','D','B','$','D','E','P','E','N','D','E','N','T','_', + 'N','A','M','E', + blr_field, 8, 16, 'R','D','B','$','T','R','I','G','G','E','R','_','N','A', + 'M','E', + blr_and, + blr_eql, + blr_field, 10, 18, 'R','D','B','$','D','E','P','E','N','D','E','N','T','_', + 'T','Y','P','E', + blr_literal, blr_long, 0, 2,0,0,0, + blr_and, + blr_eql, + blr_field, 10, 20, 'R','D','B','$','D','E','P','E','N','D','E','D','_','O', + 'N','_','T','Y','P','E', + blr_literal, blr_long, 0, 0,0,0,0, + blr_and, + blr_eql, + blr_field, 10, 20, 'R','D','B','$','D','E','P','E','N','D','E','D','_','O', + 'N','_','N','A','M','E', + blr_field, 0, 17, 'R','D','B','$','R','E','L','A','T','I','O','N','_','N', + 'A','M','E', + blr_neq, + blr_field, 10, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_field, 0, 14, 'R','D','B','$','F','I','E','L','D','_','N','A','M','E', + blr_end, + blr_leave, 1, + blr_erase, 7, + blr_end, + blr_end, + blr_eoc, };