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
NO ACTION should be different from RESTRICT #2440
Comments
The SQL Standard determines behavior in the following way:
H2 incorrectly treats the default and explicit |
@katzyn many thanks for your work! |
Sorry, I don't have enough time for this problem. H2 is developed by its community and contributions are welcome, as usual. But this issue isn't trivial and may require good knowledge of H2's internals. |
We have a couple of foreign keys in our database that reference another record within the same table. As of release 1.4.200, if we attempt to delete records in which the first record is referenced by the second record, a Referential integrity constraint violation will occur. We were previously using 1.4.199 and this was not an issue, and I would not expect this to ever be an issue as the DBMS is typically designed to handle this scenario.
Here is the query I used to test with (Ran through the H2 web client):
ID 2 uses the UPLINEID to reference ID 1. I assume what is happening is that the delete is just sequentially attempts to delete the first first and then the second.
Edit:
I have also tested with using CASCADE on the constraint:
FOREIGN KEY (UPLINEID) REFERENCES TEST(ID) ON DELETE CASCADE
This does allow it to work, although this would make the behavior of H2 different than SQL Server, Oracle, etc since they handle this fine without cascading.
The text was updated successfully, but these errors were encountered: