From ecf6e3aabe3b47f366b45ace3c871b434264b4c6 Mon Sep 17 00:00:00 2001 From: Smitty Date: Fri, 11 Oct 2024 12:44:58 -0400 Subject: [PATCH] Prepare 0.4.0 (#140) * Prepare 0.4.0 * fix * Install pgrx 0.11.1 when building 0.0.2 --------- Co-authored-by: Matvey Arye --- pgvectorscale/Cargo.toml | 2 +- .../sql/vectorscale--0.0.2--0.4.0.sql | 1 + .../sql/vectorscale--0.2.0--0.4.0.sql | 1 + .../sql/vectorscale--0.3.0--0.4.0.sql | 55 ++++++++++++++++ .../src/access_method/upgrade_test.rs | 64 +++++++++---------- 5 files changed, 88 insertions(+), 35 deletions(-) create mode 120000 pgvectorscale/sql/vectorscale--0.0.2--0.4.0.sql create mode 120000 pgvectorscale/sql/vectorscale--0.2.0--0.4.0.sql create mode 100644 pgvectorscale/sql/vectorscale--0.3.0--0.4.0.sql diff --git a/pgvectorscale/Cargo.toml b/pgvectorscale/Cargo.toml index 2dd8dfb..06df20f 100644 --- a/pgvectorscale/Cargo.toml +++ b/pgvectorscale/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vectorscale" -version = "0.3.0" +version = "0.4.0" edition = "2021" [lib] diff --git a/pgvectorscale/sql/vectorscale--0.0.2--0.4.0.sql b/pgvectorscale/sql/vectorscale--0.0.2--0.4.0.sql new file mode 120000 index 0000000..5ab5368 --- /dev/null +++ b/pgvectorscale/sql/vectorscale--0.0.2--0.4.0.sql @@ -0,0 +1 @@ +vectorscale--0.3.0--0.4.0.sql \ No newline at end of file diff --git a/pgvectorscale/sql/vectorscale--0.2.0--0.4.0.sql b/pgvectorscale/sql/vectorscale--0.2.0--0.4.0.sql new file mode 120000 index 0000000..5ab5368 --- /dev/null +++ b/pgvectorscale/sql/vectorscale--0.2.0--0.4.0.sql @@ -0,0 +1 @@ +vectorscale--0.3.0--0.4.0.sql \ No newline at end of file diff --git a/pgvectorscale/sql/vectorscale--0.3.0--0.4.0.sql b/pgvectorscale/sql/vectorscale--0.3.0--0.4.0.sql new file mode 100644 index 0000000..fa1628f --- /dev/null +++ b/pgvectorscale/sql/vectorscale--0.3.0--0.4.0.sql @@ -0,0 +1,55 @@ +/* */ +/* +This file is auto generated by pgrx. + +The ordering of items is not stable, it is driven by a dependency graph. +*/ +/* */ + +/* */ +-- 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; + $$; +/* */ + +/* */ +-- 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; +$$; +/* */ + diff --git a/pgvectorscale/src/access_method/upgrade_test.rs b/pgvectorscale/src/access_method/upgrade_test.rs index ac4b01a..0157a95 100644 --- a/pgvectorscale/src/access_method/upgrade_test.rs +++ b/pgvectorscale/src/access_method/upgrade_test.rs @@ -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, @@ -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