Closed bricelam closed 1 year ago
In trying to diagnose #523 I discovered that load_extension is enabled only for the dynamic provider. See this comment:
https://github.com/ericsink/SQLitePCL.raw/issues/523#issuecomment-1306076412
At the time, I didn't understand how you had not run into this problem already, because, IIRC, the main reason I added support for load_extension was for spatialite use cases at your request.
May I assume this would explain the problem you are seeing?
If my diagnosis is correct, pre-release 2.1.4-pre20230105221937 should contain a fix.
I tested this locally with Microsoft.Data.Sqlite 7.0.1.
I first ran it normally with normal Microsoft.Data.Sqlite 7.0.1, and it failed as expected.
Then I replaced SQLitePCLRaw.core.dll
and SQLitePCLRaw.provider.e_sqlite3.dll
with the new ones from the 2.1.4-pre20230105221937 build and I was able to load mod_spatialite and call "select spatialite_version()".
So it seems like your fix was correct.
At the time, I didn't understand how you had not run into this problem already, because, IIRC, the main reason I added support for load_extension was for spatialite use cases at your request.
Not catching this is totally on me. I made all the code changes, and our automated tests passed, so I ultimately merged the changes. After customers reported issues, I discovered that because of issues on Linux and macOS, our EF tests just get skipped when SpatiaLite can't be loaded, and I didn't notice they were suddenly being skipped on Windows too. The M.D.SQLite tests also just assert that the exception you get when trying to load an extension is different than when extensions are disabled. So, it just slipped through a big hole in our test coverage and verification.
Ah. Well, I had opportunities to avoid this problem as well. I'm just glad the mystery is solved.
I'll plan a 2.1.4 probably early next week.
2.1.4 is now on nuget.org
We're seeing issues loading mod_spatialite in https://github.com/dotnet/efcore/issues/29584. It looks like a problem with the
sqlite3_load_extension
implementation.Here's a repro. ❗ Be sure to install mod_spatialite too.
If I use my own implementation, it works: