fix: Ensure GPKG metadata consistency in test for GDAL 3.10+#740
Merged
paleolimbot merged 1 commit intoMar 28, 2026
Merged
Conversation
This fix explicitly drops the writer dataset before opening a reader connection in test_layer_iteration_and_reset. GDAL 3.10+ (via commit f7224b4c60f7) changed metadata initialization for GPKG from feature_count = NULL to feature_count = 0. Since the reader in this test uses a separate connection, it would see the stale '0' value because the writer's implicit transaction hadn't been flushed or committed yet. Trusting this non-negative value is a GDAL optimization that resulted in the reader reporting 0 features. Closing the writer ensures all features are committed and the gpkg_ogr_contents metadata is correctly updated to 3.
fc114e3 to
4b328ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the failing
vector::layer::tests::test_layer_iteration_and_resettest insedona-gdalfor GDAL 3.10+. I encountered this test failure on Fedora Asahi Remix release 42.Root Cause
The test failure is rooted in a change introduced in GDAL 3.10.0 (specifically commit f7224b4c60f7).
gpkg_ogr_contentswithfeature_count = NULL.0ea26b22cd0f01689bfd94263331ffc694112a80(backported to release/3.10 asf7224b4c60f74fc9076f37141b65ec71f8a4102f, PR#11275, issue#11274), a newly created layer is inserted withfeature_count = 0.Because
OGRGeoPackageTableLayer::GetFeatureCount()first consultsgpkg_ogr_contents, this changes behavior materially:NULLmeans "unknown", so GDAL falls back toSELECT COUNT(*) FROM table.0is treated as a valid cached count, so GDAL returns0immediately.In our test, that means:
feature_count(true)returns the stale cached metadata value0.So the mismatch is specifically: feature iteration sees the rows, but
GetFeatureCount()trusts stale metadata.Implementation
By explicitly
drop(dataset)ing the writer before opening the reader, we triggerGDALClose, which commits all features and accurately updates thegpkg_ogr_contentsmetadata to 3. This approach ensures consistent test results across all GDAL versions by respecting transactional visibility.