Skip to content

Conversation

@jjohare
Copy link

@jjohare jjohare commented Jan 27, 2026

Summary

  • Fix version mismatch: Dockerfile now copies both ruvector--0.1.0.sql and ruvector--2.0.0.sql into the image. Previously only 0.1.0 was installed, but ruvector.control declares default_version = '2.0.0', causing CREATE EXTENSION ruvector to fail with "no installation script for version 2.0.0".

  • Register embedding functions: Both extension SQL files had a comment stub for embedding functions instead of actual CREATE FUNCTION declarations. The Docker build compiles fastembed into ruvector.so via --features embeddings, and all _wrapper symbols are present in the binary, but PostgreSQL never knew about them. Replaced the stubs with 11 function declarations (10 C functions + 1 SQL convenience function).

  • Fix volatility markers: embeddings.sql incorrectly marked stateful functions (ruvector_load_model, ruvector_embedding_models, ruvector_embed, etc.) as IMMUTABLE. Changed to VOLATILE where the function loads models, mutates cache state, or returns mutable results. Only ruvector_embedding_dims remains IMMUTABLE (pure dimension lookup).

  • Add ruvector_embed_vec() convenience function: ruvector_embed() returns real[] (PostgreSQL array format {...}), but the ruvector type expects bracket notation [...]. This SQL wrapper handles the conversion so users can do ruvector_embed_vec('some text')::ruvector(384) in a single call.

  • Add embedding smoke test to init.sql: Tests ruvector_default_model() and ruvector_embedding_dims() during container initialization.

Root Cause

The extension SQL files (ruvector--0.1.0.sql / ruvector--2.0.0.sql) were hand-crafted as a fallback because cargo pgrx schema is unreliable in Docker. The embedding function declarations from sql/embeddings.sql were never merged into these files — they only contained a note saying "build with --features embeddings", even though the Dockerfile does exactly that.

Files Changed

File Change
crates/ruvector-postgres/Dockerfile Copy both 0.1.0 and 2.0.0 SQL; verify embedding functions in build
crates/ruvector-postgres/sql/ruvector--0.1.0.sql Replace embedding comment stub with 11 function declarations
crates/ruvector-postgres/sql/ruvector--2.0.0.sql Replace embedding comment stub with 11 function declarations
crates/ruvector-postgres/sql/embeddings.sql Fix IMMUTABLE→VOLATILE, add ruvector_embed_vec(), add _wrapper docs
crates/ruvector-postgres/docker/init.sql Add embedding function smoke test

Test plan

  • Build Docker image: docker build -f crates/ruvector-postgres/Dockerfile -t ruvector-postgres .
  • Verify CREATE EXTENSION ruvector succeeds (v2.0.0)
  • Verify SELECT ruvector_embed('hello world') returns 384-dim real[]
  • Verify SELECT ruvector_embed_vec('hello world') returns ruvector type
  • Verify SELECT * FROM ruvector_embedding_models() lists 6 models
  • Verify SELECT ruvector_default_model() returns all-MiniLM-L6-v2
  • Verify init.sql smoke tests pass in container logs

🤖 Generated with claude-flow

… schema in Docker

The Docker image builds ruvector.so with --features embeddings, compiling
fastembed into the binary. However, the extension SQL files (ruvector--0.1.0.sql
and ruvector--2.0.0.sql) contained only a comment stub for embedding functions
instead of actual CREATE FUNCTION declarations. This meant CREATE EXTENSION
ruvector never registered the embedding functions despite the compiled symbols
being present in the .so.

Additionally, the Dockerfile only copied ruvector--0.1.0.sql into the image
while ruvector.control declares default_version = '2.0.0', causing CREATE
EXTENSION ruvector to fail with "no installation script for version 2.0.0".

Changes:
- Replace embedding comment stubs in both ruvector--0.1.0.sql and
  ruvector--2.0.0.sql with actual CREATE FUNCTION declarations using
  the pgrx _wrapper symbol convention
- Add ruvector_embed_vec() convenience function (text -> ruvector type)
- Fix Dockerfile to copy both 0.1.0 and 2.0.0 SQL files into the image
- Fix volatility markers in embeddings.sql (IMMUTABLE -> VOLATILE for
  functions that load models or mutate state)
- Add embedding function smoke test to docker/init.sql

Co-Authored-By: claude-flow <ruv@ruv.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant