Closed rouault closed 1 year ago
At the March 28 SWG meeting, we agreed in principle with @rouault 's statements. We also agreed to develop a new extension to indicate the presence of the revised upsert-compatible trigger. Clients that detect the presence of the extension would be free to use upserts. Clients that don't detect the trigger would have two options:
Stay tuned!
I've found an issue when wanting to use the UPSERT capability on a table with a RTree. For example the following UPSERT that inserts a FID 1 or update it
fails with an error like "UNIQUE constraint failed: foo_rtree.id (19)" when updating an existing row. I've spotted it to be caused by the "_update1" trigger that has a "INSERT OR REPLACE INTO" statement. More details in https://sqlite.org/forum/forumpost/8c8de6ff91 where the SQLite author answered that SQLite3 behave as documented here, although a bit surprising. In https://github.com/OSGeo/gdal/pull/6532, I've put a workardound where I remove the _update1 trigger and replace it with 2 separate triggers to avoid the need of a "INSERT OR REPLACE INTO" statement.
One is a _update1_old_geom_notnull trigger that does an update of the rtree when both the old and new geoms are not null/empty
and one is a _update1_old_geom_null that does an insert in the rtree when the old geom is null/empty and the new one is not:
Should the spec be updated to replace the _update1 trigger by the 2 above ones ?