fix: register embedding functions in extension SQL and install v2.0.0 schema in Docker #136
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
Fix version mismatch: Dockerfile now copies both
ruvector--0.1.0.sqlandruvector--2.0.0.sqlinto the image. Previously only 0.1.0 was installed, butruvector.controldeclaresdefault_version = '2.0.0', causingCREATE EXTENSION ruvectorto 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 FUNCTIONdeclarations. The Docker build compiles fastembed intoruvector.sovia--features embeddings, and all_wrappersymbols 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.sqlincorrectly marked stateful functions (ruvector_load_model,ruvector_embedding_models,ruvector_embed, etc.) asIMMUTABLE. Changed toVOLATILEwhere the function loads models, mutates cache state, or returns mutable results. Onlyruvector_embedding_dimsremainsIMMUTABLE(pure dimension lookup).Add
ruvector_embed_vec()convenience function:ruvector_embed()returnsreal[](PostgreSQL array format{...}), but theruvectortype expects bracket notation[...]. This SQL wrapper handles the conversion so users can doruvector_embed_vec('some text')::ruvector(384)in a single call.Add embedding smoke test to init.sql: Tests
ruvector_default_model()andruvector_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 becausecargo pgrx schemais unreliable in Docker. The embedding function declarations fromsql/embeddings.sqlwere never merged into these files — they only contained a note saying "build with --features embeddings", even though the Dockerfile does exactly that.Files Changed
crates/ruvector-postgres/Dockerfilecrates/ruvector-postgres/sql/ruvector--0.1.0.sqlcrates/ruvector-postgres/sql/ruvector--2.0.0.sqlcrates/ruvector-postgres/sql/embeddings.sqlruvector_embed_vec(), add _wrapper docscrates/ruvector-postgres/docker/init.sqlTest plan
docker build -f crates/ruvector-postgres/Dockerfile -t ruvector-postgres .CREATE EXTENSION ruvectorsucceeds (v2.0.0)SELECT ruvector_embed('hello world')returns 384-dim real[]SELECT ruvector_embed_vec('hello world')returns ruvector typeSELECT * FROM ruvector_embedding_models()lists 6 modelsSELECT ruvector_default_model()returnsall-MiniLM-L6-v2🤖 Generated with claude-flow