Skip to content

Commit

Permalink
Prepare 0.4.0 (#140)
Browse files Browse the repository at this point in the history
* Prepare 0.4.0

* fix

* Install pgrx 0.11.1 when building 0.0.2

---------

Co-authored-by: Matvey Arye <[email protected]>
  • Loading branch information
syvb and cevian authored Oct 11, 2024
1 parent 7af7933 commit ecf6e3a
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pgvectorscale/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vectorscale"
version = "0.3.0"
version = "0.4.0"
edition = "2021"

[lib]
Expand Down
1 change: 1 addition & 0 deletions pgvectorscale/sql/vectorscale--0.0.2--0.4.0.sql
1 change: 1 addition & 0 deletions pgvectorscale/sql/vectorscale--0.2.0--0.4.0.sql
55 changes: 55 additions & 0 deletions pgvectorscale/sql/vectorscale--0.3.0--0.4.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* <begin connected objects> */
/*
This file is auto generated by pgrx.
The ordering of items is not stable, it is driven by a dependency graph.
*/
/* </end connected objects> */

/* <begin connected objects> */
-- src/access_method/mod.rs:26
-- vectorscale::access_method::amhandler

CREATE OR REPLACE FUNCTION diskann_amhandler(internal) RETURNS index_am_handler PARALLEL SAFE IMMUTABLE STRICT COST 0.0001 LANGUAGE c AS '$libdir/vectorscale-0.4.0', 'amhandler_wrapper';

DO $$
DECLARE
c int;
BEGIN
SELECT count(*)
INTO c
FROM pg_catalog.pg_am a
WHERE a.amname = 'diskann';

IF c = 0 THEN
CREATE ACCESS METHOD diskann TYPE INDEX HANDLER diskann_amhandler;
END IF;
END;
$$;
/* </end connected objects> */

/* <begin connected objects> */
-- src/access_method/mod.rs:89
-- requires:
-- amhandler


DO $$
DECLARE
c int;
BEGIN
SELECT count(*)
INTO c
FROM pg_catalog.pg_opclass c
WHERE c.opcname = 'vector_cosine_ops'
AND c.opcmethod = (SELECT oid FROM pg_catalog.pg_am am WHERE am.amname = 'diskann');

IF c = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops;
END IF;
END;
$$;
/* </end connected objects> */

64 changes: 30 additions & 34 deletions pgvectorscale/src/access_method/upgrade_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pub mod tests {
#[ignore]
///This function is only a mock to bring up the test framewokr in test_delete_vacuum
fn test_upgrade() {
if cfg!(feature = "pg17") {
// PG17 is only supported for one version
return;
}
pgrx_tests::run_test(
"test_delete_mock_fn",
None,
Expand Down Expand Up @@ -73,48 +77,40 @@ pub mod tests {
temp_dir.path()
);

// use latest pgrx
let res = std::process::Command::new("cargo")
.current_dir(temp_path.join("timescale_vector"))
.args(["rm", "pgrx"])
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.unwrap();
assert!(res.status.success(), "failed: {:?}", res);

let res = std::process::Command::new("cargo")
.current_dir(temp_path.join("timescale_vector"))
.args(["rm", "--dev", "pgrx-tests"])
.args([
"install",
"cargo-pgrx",
"--version",
"=0.11.1",
"--force",
"--root",
temp_path.join("pgrx-0.11.1").to_str().unwrap(),
"cargo-pgrx",
])
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.unwrap();
assert!(res.status.success(), "failed: {:?}", res);

let res = std::process::Command::new("cargo")
.current_dir(temp_path.join("timescale_vector"))
.args(["add", "-F", &format!("pg{}", pg_version), "pgrx"])
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.unwrap();
assert!(res.status.success(), "failed: {:?}", res);

//let contents = fs::read_to_string(temp_path.join("pgvectorscale/Cargo.toml")).unwrap();
//print!("cargo {}", contents);

let res = std::process::Command::new("cargo")
.current_dir(temp_path.join("timescale_vector"))
.arg("pgrx")
.arg("install")
.arg("--test")
.arg("--pg-config")
.arg(pg_config.path().unwrap())
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.unwrap();
let res = std::process::Command::new(
temp_path
.join("pgrx-0.11.1/bin/cargo-pgrx")
.to_str()
.unwrap(),
)
.current_dir(temp_path.join("timescale_vector"))
.arg("pgrx")
.arg("install")
.arg("--test")
.arg("--pg-config")
.arg(pg_config.path().unwrap())
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.unwrap();
assert!(res.status.success(), "failed: {:?}", res);

client
Expand Down

0 comments on commit ecf6e3a

Please sign in to comment.