-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 constraint failed" error with the geopackage driver #9135
Comments
I believe that the foreign key constraint that stops the insert is this:
So maybe the solution would be to run BTW where the -DSQLITE_DEFAULT_FOREIGN_KEYS=1 option is documented? |
It's documented here: |
Expected behavior and actual behavior.
I have a custom setup that use a libsqlite3 version that is build with
-DSQLITE_DEFAULT_FOREIGN_KEYS=1
(which enables foreign key constraints by default. If I now try to create a new geopackage geometry and insert data in that geometry this process fails with a "FOREIGN KEY constraint failed" error.It's possible to workaround this issue for libsqlite3 versions build with the mentioned feature flag by just setting
OGR_SQLITE_PRAGMA=FOREIGN_KEYS=0
(i.e disabling the foreign key check). The produced sqlite database contains only valid foreign key relations afterwards, so it just seems to be an issue in the order of which certain SQL statements are executed. I would expect that gdal uses an order that always results in valid foreign key relations instead of the other way around. If someone points to the relevant code I might consider working on a fix.Steps to reproduce the problem.
This problem can be reproduced by manually requiring sqlite to check the foreign key constraints by setting the
OGR_SQLITE_PRAGMA=FOREIGN_KEYS=1
config flag while running the driver independently from your sqlite compile flags.For example it can be reproduced by using
ogr2ogr
:Operating system
Fedora 39
GDAL version and provenance
Observed with:
The text was updated successfully, but these errors were encountered: