Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign Key with ON DELETE CASCADE ignored [CORE3068] #3447

Closed
firebird-automations opened this issue Jul 9, 2010 · 8 comments
Closed

Foreign Key with ON DELETE CASCADE ignored [CORE3068] #3447

firebird-automations opened this issue Jul 9, 2010 · 8 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Alex Poloziouk (poloziouk)

Attachments:
Test.zip

Please see attached database backup.

Two tables DMG (master) and TRNS (child) linked via foreign key with ON DELETE CASCADE.

For some reason when I try to delete records from DMG (delete from dmg where dmg_id=1) I get following error:
violation of FOREIGN KEY constraint "FK_TRNS" on table "TRNS".
Foreign key references are present for the record.

This is how FK looks like:

ALTER TABLE TRNS ADD CONSTRAINT FK_TRNS FOREIGN KEY (DMG_ID) REFERENCES DMG (DMG_ID) ON DELETE CASCADE USING INDEX IX_FK_TRNS;

If I re-create FK all works.
Backup/restore does not help.

Looking at metadata I can not find any issues.

We have several databases (most of them around 5-6GB) with this issue and re-creation of FK is not a solution.

Thank you,
Alex Poloziouk

@firebird-automations
Copy link
Collaborator Author

Commented by: Alex Poloziouk (poloziouk)

Backup

@firebird-automations
Copy link
Collaborator Author

Modified by: Alex Poloziouk (poloziouk)

Attachment: Test.zip [ 11681 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: Alex Poloziouk (poloziouk)

description: Please see attached database backup.

Two tables DMG (master) and TRNS (child) linked via foreign key with ON DELETE CASCADE.

For some reason when I try to delete records from DMG (delete from dmg where dmg_id=1) I get following error:
violation of FOREIGN KEY constraint "FK_TRNS" on table "TRNS".
Foreign key references are present for the record.

This is how FK looks like:
ALTER TABLE DMG ADD CONSTRAINT PK_DMG PRIMARY KEY (DMG_ID) USING INDEX IX_PK_DMG;

If I re-create FK all works.
Backup/restore does not help.

Looking at metadata I can not find any issues.

We have several databases (most of them around 5-6GB) with this issue and re-creation of FK is not a solution.

Thank you,
Alex Poloziouk

=>

Please see attached database backup.

Two tables DMG (master) and TRNS (child) linked via foreign key with ON DELETE CASCADE.

For some reason when I try to delete records from DMG (delete from dmg where dmg_id=1) I get following error:
violation of FOREIGN KEY constraint "FK_TRNS" on table "TRNS".
Foreign key references are present for the record.

This is how FK looks like:

ALTER TABLE TRNS ADD CONSTRAINT FK_TRNS FOREIGN KEY (DMG_ID) REFERENCES DMG (DMG_ID) ON DELETE CASCADE USING INDEX IX_FK_TRNS;

If I re-create FK all works.
Backup/restore does not help.

Looking at metadata I can not find any issues.

We have several databases (most of them around 5-6GB) with this issue and re-creation of FK is not a solution.

Thank you,
Alex Poloziouk

@firebird-automations
Copy link
Collaborator Author

Modified by: Alex Poloziouk (poloziouk)

security: Developers [ 10012 ] =>

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Your database have no system trigger on TRANS for FK_TRNS.
I have no idea how it was deleted, most probably by direct DML on RDB$TRIGGERS.
Re-creating constraint creates needed system trigger.

I see nothing to fix there

@firebird-automations
Copy link
Collaborator Author

Commented by: Alex Poloziouk (apoloziouk)

Vlad,

Thank you for fast response.
This makes sense as we probably did ran some questionable queries against metadata.

Please close this ticket.

Best regards,
Alex

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant