get_data: fix SPI fetch order and portal leak on zero-row input - #3147
get_data: fix SPI fetch order and portal leak on zero-row input#3147AdeshDeshmukh wants to merge 1 commit into
Conversation
Check SPI_processed before touching SPI_tuptable->tupdesc, with a defensive null guard for PG-version variance. On zero-row batches, validate columns when a descriptor is available so schema typos still raise a clean Column not Found error, then exit cleanly and let the drivers emit the standard No edges found notice. Wrap validation and row iteration in try/catch so the tuple table is freed and the cursor closed exactly once before rethrowing. Add zero-row regression tests to pgtap/dijkstra/dijkstra/no_crash_test.pg (empty set on valid schema, XX000 on missing column). Fixes pgRouting#3146 Signed-off-by: Adesh Deshmukh <adeshkd123@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. Walkthrough
ChangesSPI fetch safety
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Empty edge queries now return safely while invalid schemas still report the expected error, with cleanup preserved on failures. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks the empty stream, Comment |
Fixes #3146
Summary
Hardens the shared SPI fetch helper (
pgget::get_datavector overload ininclude/cpp_common/get_data.hpp) that all graph loaders (get_edges()+~12 sibling getters) funnel through. Two defects, one focused patch, no
API/signature change.
What was wrong
SPI_tuptable->tupdescbefore checkingSPI_processed,so a valid query returning zero rows (filtered-out
edges_sql, emptytenant/partition) walked an unchecked path.
never closed, leaking the portal.
This is distinct from the empty-string
''case (#3054), which is handledupstream in the driver before the fetch loop.
Changes
include/cpp_common/get_data.hpp(vector overload only; the legacychar*overload has no callers and is untouched):
SPI_processedfirst, with a defensive null guard onSPI_tuptable/tupdescfor PG-version variance.typos still raise
Column 'cost' not Foundinstead of returning amisleading empty set; otherwise exit cleanly so drivers emit the standard
NOTICE: No edges found.closed exactly once before rethrowing.
pgtap/dijkstra/dijkstra/no_crash_test.pg: +2 regression assertions(zero-row valid schema -> empty set; zero-row missing column ->
XX000),plan counts adjusted accordingly.
Behavior after fix
NOTICE, connection healthy.ERROR XX000, portal closed.''empty string -> unchangedERROR: Empty edges SQL.Verification
-std=c++17 -fsyntax-only, templateinstantiation checked)
git diff --checkclean; 4-space style, no lines >120pg_prove+ liveWHERE falserepro need a PG+PostGIS box —requesting CI run for confirmation
Happy to adjust scope or split anything per reviewer preference.
Summary by CodeRabbit
Bug Fixes
Tests