mirror of
https://github.com/tensorchord/pgvecto.rs.git
synced 2025-04-18 21:44:00 +03:00
chore: set schema and search_path (#273)
* chore: set schema and search_path Signed-off-by: usamoi <usamoi@outlook.com> * fix: remove unnecessary changes Signed-off-by: usamoi <usamoi@outlook.com> * fix: set search_path for docker Signed-off-by: usamoi <usamoi@outlook.com> * fix: ci Signed-off-by: usamoi <usamoi@outlook.com> * fix: docker Signed-off-by: usamoi <usamoi@outlook.com> * fix: search_path search order Signed-off-by: usamoi <usamoi@outlook.com> --------- Signed-off-by: usamoi <usamoi@outlook.com>
This commit is contained in:
parent
0e5fb8b029
commit
da6686e823
@ -4,7 +4,7 @@ version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
||||
[features]
|
||||
default = ["pg15"]
|
||||
|
@ -7,4 +7,4 @@ FROM tensorchord/pgvecto-rs-binary:${TAG}-${TARGETARCH} as binary
|
||||
FROM postgres:$POSTGRES_VERSION
|
||||
COPY --from=binary /pgvecto-rs-binary-release.deb /tmp/vectors.deb
|
||||
RUN apt-get install -y /tmp/vectors.deb && rm -f /tmp/vectors.deb
|
||||
CMD ["postgres","-c","shared_preload_libraries=vectors.so"]
|
||||
CMD ["postgres", "-c" ,"shared_preload_libraries='vectors.so'", "-c", "search_path='\"\$user\", public, vectors'"]
|
||||
|
@ -3,6 +3,7 @@ set -e
|
||||
|
||||
cargo pgrx install --no-default-features --features "pg$VERSION" --release
|
||||
psql -c 'ALTER SYSTEM SET shared_preload_libraries = "vectors.so"'
|
||||
psql -c 'ALTER SYSTEM SET search_path TO "$user", public, vectors'
|
||||
|
||||
if [ "$OS" == "ubuntu-latest" ]; then
|
||||
sudo systemctl restart postgresql
|
||||
|
12
src/bin/pgrx_embed.rs
Normal file
12
src/bin/pgrx_embed.rs
Normal file
@ -0,0 +1,12 @@
|
||||
macro_rules! pgrx_embed {
|
||||
() => {
|
||||
#[cfg(not(pgrx_embed))]
|
||||
fn main() {
|
||||
panic!("PGRX_EMBED was not set.");
|
||||
}
|
||||
#[cfg(pgrx_embed)]
|
||||
include!(env!("PGRX_EMBED"));
|
||||
};
|
||||
}
|
||||
|
||||
pgrx_embed!();
|
@ -226,7 +226,7 @@ impl IntoDatum for Vecf16Output {
|
||||
}
|
||||
|
||||
fn type_oid() -> Oid {
|
||||
pgrx::wrappers::regtypein("vecf16")
|
||||
pgrx::wrappers::regtypein("vectors.vecf16")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ impl IntoDatum for Vecf32Output {
|
||||
}
|
||||
|
||||
fn type_oid() -> Oid {
|
||||
pgrx::wrappers::regtypein("vector")
|
||||
pgrx::wrappers::regtypein("vectors.vector")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub unsafe fn convert_opclass_to_distance(opclass: pgrx::pg_sys::Oid) -> (Distan
|
||||
let tuple = pgrx::pg_sys::SearchSysCache1(opclass_cache_id, opclass.into());
|
||||
assert!(
|
||||
!tuple.is_null(),
|
||||
"cache lookup failed for operator class {opclass}"
|
||||
"cache lookup failed for operator class {opclass:?}"
|
||||
);
|
||||
let classform = pgrx::pg_sys::GETSTRUCT(tuple).cast::<pgrx::pg_sys::FormData_pg_opclass>();
|
||||
let opfamily = (*classform).opcfamily;
|
||||
@ -36,7 +36,7 @@ pub unsafe fn convert_opfamily_to_distance(opfamily: pgrx::pg_sys::Oid) -> (Dist
|
||||
let tuple = pgrx::pg_sys::SearchSysCache1(opfamily_cache_id, opfamily.into());
|
||||
assert!(
|
||||
!tuple.is_null(),
|
||||
"cache lookup failed for operator family {opfamily}"
|
||||
"cache lookup failed for operator family {opfamily:?}"
|
||||
);
|
||||
let list = pgrx::pg_sys::SearchSysCacheList(
|
||||
opstrategy_cache_id,
|
||||
@ -53,17 +53,17 @@ pub unsafe fn convert_opfamily_to_distance(opfamily: pgrx::pg_sys::Oid) -> (Dist
|
||||
assert!((*amop).amoppurpose == pgrx::pg_sys::AMOP_ORDER as libc::c_char);
|
||||
let operator = (*amop).amopopr;
|
||||
let result;
|
||||
if operator == regoperatorin("<->(vector,vector)") {
|
||||
if operator == regoperatorin("vectors.<->(vectors.vector,vectors.vector)") {
|
||||
result = (Distance::L2, Kind::F32);
|
||||
} else if operator == regoperatorin("<#>(vector,vector)") {
|
||||
} else if operator == regoperatorin("vectors.<#>(vectors.vector,vectors.vector)") {
|
||||
result = (Distance::Dot, Kind::F32);
|
||||
} else if operator == regoperatorin("<=>(vector,vector)") {
|
||||
} else if operator == regoperatorin("vectors.<=>(vectors.vector,vectors.vector)") {
|
||||
result = (Distance::Cos, Kind::F32);
|
||||
} else if operator == regoperatorin("<->(vecf16,vecf16)") {
|
||||
} else if operator == regoperatorin("vectors.<->(vectors.vecf16,vectors.vecf16)") {
|
||||
result = (Distance::L2, Kind::F16);
|
||||
} else if operator == regoperatorin("<#>(vecf16,vecf16)") {
|
||||
} else if operator == regoperatorin("vectors.<#>(vectors.vecf16,vectors.vecf16)") {
|
||||
result = (Distance::Dot, Kind::F16);
|
||||
} else if operator == regoperatorin("<=>(vecf16,vecf16)") {
|
||||
} else if operator == regoperatorin("vectors.<=>(vectors.vecf16,vectors.vecf16)") {
|
||||
result = (Distance::Cos, Kind::F16);
|
||||
} else {
|
||||
SessionError::BadOptions2.friendly();
|
||||
|
@ -2,7 +2,9 @@ use crate::prelude::*;
|
||||
use service::prelude::*;
|
||||
|
||||
#[pgrx::pg_extern(volatile, strict)]
|
||||
fn _vectors_index_stat(oid: pgrx::pg_sys::Oid) -> pgrx::composite_type!("vector_index_stat") {
|
||||
fn _vectors_index_stat(
|
||||
oid: pgrx::pg_sys::Oid,
|
||||
) -> pgrx::composite_type!('static, "vector_index_stat") {
|
||||
use service::index::IndexStat;
|
||||
let id = Handle::from_sys(oid);
|
||||
let mut res = pgrx::prelude::PgHeapTuple::new_composite_type("vector_index_stat").unwrap();
|
||||
|
@ -3,3 +3,4 @@ default_version = '@CARGO_VERSION@'
|
||||
module_pathname = '$libdir/vectors'
|
||||
relocatable = false
|
||||
superuser = true
|
||||
schema = vectors
|
||||
|
Loading…
x
Reference in New Issue
Block a user