@@ -11597,6 +11597,24 @@ void DropRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
1159711597
1159811598 indexList.exec(tdbb, transaction);
1159911599
11600+ if (name.package.isEmpty())
11601+ {
11602+ // Drop CHECK/NOT NULL constraints before fields, otherwise system triggers
11603+ // still see active constraints while RDB$RELATION_FIELDS is erased.
11604+ request.reset(tdbb, drq_e_rel_con3, DYN_REQUESTS);
11605+
11606+ FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
11607+ CRT IN RDB$RELATION_CONSTRAINTS
11608+ WITH CRT.RDB$SCHEMA_NAME EQ name.schema.c_str() AND
11609+ CRT.RDB$RELATION_NAME EQ name.object.c_str() AND
11610+ (CRT.RDB$CONSTRAINT_TYPE EQ CHECK_CNSTRT OR
11611+ CRT.RDB$CONSTRAINT_TYPE EQ NOT_NULL_CNSTRT)
11612+ {
11613+ ERASE CRT;
11614+ }
11615+ END_FOR
11616+ }
11617+
1160011618 request.reset(tdbb, drq_e_rel_flds, DYN_REQUESTS);
1160111619
1160211620 FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
@@ -11639,20 +11657,6 @@ void DropRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
1163911657 }
1164011658 END_FOR
1164111659
11642- // CVC: Moved this block here to avoid SF Bug #1111570.
11643- request.reset(tdbb, drq_e_rel_con3, DYN_REQUESTS);
11644-
11645- FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
11646- CRT IN RDB$RELATION_CONSTRAINTS
11647- WITH CRT.RDB$SCHEMA_NAME EQ name.schema.c_str() AND
11648- CRT.RDB$RELATION_NAME EQ name.object.c_str() AND
11649- (CRT.RDB$CONSTRAINT_TYPE EQ CHECK_CNSTRT OR
11650- CRT.RDB$CONSTRAINT_TYPE EQ NOT_NULL_CNSTRT)
11651- {
11652- ERASE CRT;
11653- }
11654- END_FOR
11655-
1165611660 request.reset(tdbb, drq_e_view_rels, DYN_REQUESTS);
1165711661
1165811662 FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
0 commit comments