ruvector/crates/ruvector-postgres/src
rUv 625f16c744 fix(hnsw): resolve segfault with parameterized queries (Issue #141)
This commit fixes a critical P0 bug where HNSW indexes on ruvector
columns would crash PostgreSQL with a segmentation fault when using
parameterized queries (prepared statements, ORMs, application drivers).

Root Cause:
- Query vector extraction failed for parameterized queries
- Code fell back to zero vector without validation
- Zero vector caused segfault during HNSW search

Changes:
- Add multi-method query vector extraction pipeline
  1. Direct RuVector::from_polymorphic_datum()
  2. Text parameter conversion for parameterized queries
  3. Validated varlena fallback with dimension checking
- Add query_valid flag to track extraction success
- Add validation before search execution:
  - Reject empty/invalid query vectors with clear errors
  - Reject all-zero vectors (invalid for similarity search)
  - Validate dimension match between query and index
- Apply same fixes to IVFFlat for consistency

Testing:
- Added regression tests for parameterized queries
- Added tests for zero vector error handling
- Added tests for dimension mismatch errors
- Added 384-dimension production-scale tests

Fixes: #141
See: docs/adr/ADR-0027-hnsw-parameterized-query-fix.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 16:34:42 +00:00
..
attention fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00
bin feat(postgres): Add ruvector-postgres extension with SIMD optimizations (#42) 2025-12-02 09:55:07 -05:00
dag fix(postgres): fix chrono and timestamp compilation errors 2025-12-30 18:02:13 +00:00
distance fix(ci): Fix formatting and workflow permission issues 2025-12-26 22:11:57 +00:00
embeddings fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00
gated_transformer style: run cargo fmt across all crates 2025-12-29 17:41:49 +00:00
gnn fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00
graph fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00
healing fix(postgres): fix unused imports and GNN test type mismatches 2025-12-26 22:11:58 +00:00
hybrid fix(ci): Fix formatting and workflow permission issues 2025-12-26 22:11:57 +00:00
hyperbolic fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00
index fix(hnsw): resolve segfault with parameterized queries (Issue #141) 2026-01-28 16:34:42 +00:00
integrity style: run cargo fmt across all crates 2025-12-29 17:41:49 +00:00
learning fix(ci): Fix additional test type mismatches in learning and tenancy 2025-12-26 22:11:59 +00:00
quantization fix(ci): Fix formatting and workflow permission issues 2025-12-26 22:11:57 +00:00
routing fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00
sparse fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00
tenancy fix(ci): Fix formatting in tenancy tests 2025-12-26 22:11:59 +00:00
types fix(postgres): Fix pg_test and pg_schema imports in sparsevec.rs 2025-12-26 22:12:00 +00:00
workers fix(postgres): remove unused pgrx import in queue.rs 2025-12-26 22:11:58 +00:00
lib.rs feat(dag): implement Neural Self-Learning DAG with QuDAG integration 2025-12-29 22:58:43 +00:00
operators.rs fix(postgres): clean up cfg attributes and unused imports 2025-12-26 23:32:24 +00:00