Skip to content

Commit d5ce2a3

Browse files
authored
prep v0.22 (#216)
* prep v0.22 * remove branch from ci * install pgrx 0.12.5 on older vectorize * Update Makefile * Update Makefile * check if exists before drop * replace instead of drop fn
1 parent 02abe1d commit d5ce2a3

File tree

19 files changed

+104
-161
lines changed

19 files changed

+104
-161
lines changed

.github/actions/pgx-init/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ runs:
2727
echo "pgrx is not a dependency: skipping"
2828
echo "skip=true" >> $GITHUB_OUTPUT
2929
else
30-
cargo install --version ${pgrx_version} cargo-pgrx
30+
cargo install --version ${pgrx_version} cargo-pgrx --locked
3131
echo "skip=false" >> $GITHUB_OUTPUT
3232
fi
3333
- name: pgrx init

.github/workflows/extension_ci.yml

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,6 @@ on:
2323
types:
2424
- created
2525
jobs:
26-
dependencies:
27-
name: Install dependencies
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v4
31-
32-
# rust needed to install trunk
33-
- name: Install Rust stable toolchain
34-
uses: dtolnay/rust-toolchain@stable
35-
36-
- name: Install stoml and pg-trunk
37-
shell: bash
38-
run: |
39-
set -xe
40-
wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 &> /dev/null
41-
mv stoml_linux_amd64 stoml
42-
chmod +x stoml
43-
sudo mv stoml /usr/local/bin/
44-
cargo install pg-trunk
45-
46-
- name: Cache binaries
47-
uses: actions/cache@v4
48-
with:
49-
path: |
50-
/usr/local/bin/stoml
51-
~/.cargo/bin/trunk
52-
key: ${{ runner.os }}-bins-${{ github.sha }}
53-
restore-keys: |
54-
${{ runner.os }}-bins-
55-
5626
lint:
5727
name: Run linters
5828
runs-on: ubuntu-latest
@@ -103,7 +73,7 @@ jobs:
10373
10474
- name: Test Core - Integration
10575
# skip when on external forks
106-
if: github.event.pull_request.head.repo.full_name == github.repository
76+
if: github.repository_owner == 'tembo-io'
10777
env:
10878
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
10979
CO_API_KEY: ${{ secrets.CO_API_KEY }}
@@ -115,8 +85,7 @@ jobs:
11585
11686
test:
11787
name: Run tests
118-
needs: dependencies
119-
runs-on: ubuntu-24.04
88+
runs-on: ubuntu-latest
12089
services:
12190
# Label used to access the service container
12291
vector-serve:
@@ -129,27 +98,17 @@ jobs:
12998
uses: dtolnay/rust-toolchain@stable
13099
- uses: Swatinem/rust-cache@v2
131100
with:
132-
prefix-key: "extension-test"
133101
workspaces: |
134102
vectorize
135103
# Additional directories to cache
136104
cache-directories: |
137105
/home/runner/.pgrx
138106
- name: Install sys dependencies
139107
run: |
140-
sudo apt-get update && sudo apt-get install -y postgresql-server-dev-16 libopenblas-dev libreadline-dev
108+
sudo apt-get update && sudo apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libclang-dev postgresql-client libicu-dev make wget pkg-config libssl-dev git gcc libopenblas-dev
141109
- uses: ./.github/actions/pgx-init
142110
with:
143111
working-directory: ./extension
144-
- name: Restore cached binaries
145-
uses: actions/cache@v4
146-
with:
147-
path: |
148-
/usr/local/bin/stoml
149-
~/.cargo/bin/trunk
150-
key: ${{ runner.os }}-bins-${{ github.sha }}
151-
restore-keys: |
152-
${{ runner.os }}-bins-
153112
- name: setup-tests
154113
run: |
155114
make setup
@@ -158,7 +117,7 @@ jobs:
158117
echo "\q" | make run
159118
make test-unit
160119
- name: integration-test
161-
if: github.event.pull_request.head.repo.full_name == github.repository
120+
if: github.repository_owner == 'tembo-io'
162121
env:
163122
HF_API_KEY: ${{ secrets.HF_API_KEY }}
164123
CO_API_KEY: ${{ secrets.CO_API_KEY }}

.github/workflows/extension_upgrade.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
trunk install vectorize --version 0.20.0 --pg-config $(cargo pgrx info pg-config pg17)
6161
git fetch --tags
6262
git checkout tags/v0.20.0
63+
# pgrx=0.12.5 required for v0.20.0
64+
cargo install cargo-pgrx --version 0.12.5 --locked
6365
make test-integration
6466
- name: Test branch's version
6567
env:

.github/workflows/pg-image-build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
run: |
5252
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
5353
echo "TAG_VER=$(/usr/local/bin/stoml extension/Cargo.toml package.version)" >> $GITHUB_OUTPUT
54+
echo "PGRX_VER=$(/usr/local/bin/stoml extension/Cargo.toml dependencies.pgrx | tr -d '="')" >> $GITHUB_OUTPUT
5455
5556
- name: Set up Docker Buildx
5657
uses: docker/setup-buildx-action@v3
@@ -66,6 +67,7 @@ jobs:
6667
if: github.event_name != 'release'
6768
run: |
6869
docker build \
70+
--build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \
6971
-f ./images/vectorize-pg/Dockerfile \
7072
-t quay.io/tembo/vectorize-pg:${{ steps.versions.outputs.SHORT_SHA }}-amd64 .
7173
docker push quay.io/tembo/vectorize-pg:${{ steps.versions.outputs.SHORT_SHA }}-amd64
@@ -74,6 +76,7 @@ jobs:
7476
if: github.event_name == 'release'
7577
run: |
7678
docker build \
79+
--build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \
7780
-f ./images/vectorize-pg/Dockerfile \
7881
-t quay.io/tembo/vectorize-pg:v${{ steps.versions.outputs.TAG_VER }}-amd64 \
7982
-t quay.io/tembo/vectorize-pg:latest-amd64 .
@@ -109,6 +112,7 @@ jobs:
109112
run: |
110113
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
111114
echo "TAG_VER=$(/usr/local/bin/stoml extension/Cargo.toml package.version)" >> $GITHUB_OUTPUT
115+
echo "PGRX_VER=$(/usr/local/bin/stoml extension/Cargo.toml dependencies.pgrx | tr -d '="')" >> $GITHUB_OUTPUT
112116
113117
- name: Set up Docker Buildx
114118
uses: docker/setup-buildx-action@v3
@@ -125,6 +129,7 @@ jobs:
125129
if: github.event_name != 'release'
126130
run: |
127131
docker build \
132+
--build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \
128133
-f ./images/vectorize-pg/Dockerfile \
129134
--platform linux/arm64 \
130135
-t quay.io/tembo/vectorize-pg:${{ steps.versions.outputs.SHORT_SHA }}-arm64 .
@@ -134,6 +139,7 @@ jobs:
134139
if: github.event_name == 'release'
135140
run: |
136141
docker build \
142+
--build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \
137143
-f ./images/vectorize-pg/Dockerfile \
138144
--platform linux/arm64 \
139145
-t quay.io/tembo/vectorize-pg:v${{ steps.versions.outputs.TAG_VER }}-arm64 \

extension/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vectorize"
3-
version = "0.21.1"
3+
version = "0.22.0"
44
edition = "2021"
55
publish = false
66

@@ -25,7 +25,7 @@ chrono = {version = "0.4.26", features = ["serde"] }
2525
handlebars = "5.1.0"
2626
log = "0.4.21"
2727
pgmq = "0.29"
28-
pgrx = "=0.12.5"
28+
pgrx = "=0.13.1"
2929
reqwest = {version = "0.11.18", features = ["json"] }
3030
serde = { version = "1.0.173", features = ["derive"] }
3131
serde_json = "1.0.103"
@@ -42,7 +42,7 @@ url = "2.4.0"
4242
vectorize_core = { path = "../core", package = "vectorize-core" }
4343

4444
[dev-dependencies]
45-
pgrx-tests = "=0.12.5"
45+
pgrx-tests = "=0.13.1"
4646
rand = "0.8.5"
4747
whoami = "1.4.1"
4848

extension/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ DISTVERSION = $(shell grep -m 1 '^version' Trunk.toml | sed -e 's/[^"]*"\([^"]*
44
PG_VERSION:=17
55
DATABASE_URL:=postgres://${USER}:${USER}@localhost:288${PG_VERSION}/postgres
66
PGRX_PG_CONFIG:=$(shell cargo pgrx info pg-config pg${PG_VERSION})
7+
PGRX_VERSION := $(shell grep -E "^pgrx\s*=" Cargo.toml | cut -d'"' -f2 | tr -d '=')
78
UPGRADE_FROM_VER:=0.16.0
89
BRANCH:=$(git rev-parse --abbrev-ref HEAD)
910
RUST_LOG:=debug
@@ -86,15 +87,17 @@ install-vectorscale:
8687
fi; \
8788
git clone https://github.com/timescale/pgvectorscale.git && \
8889
cd pgvectorscale/pgvectorscale && \
90+
cargo install cargo-pgrx --locked --version $$(grep -E "^pgrx\s*=" Cargo.toml | cut -d'"' -f2 | tr -d '=') && \
8991
cargo pgrx install --pg-config=${PGRX_PG_CONFIG} && \
9092
cd ../.. && rm -rf pgvectorscale
93+
cargo install cargo-pgrx --locked --version ${PGRX_VERSION}
9194

9295
test-integration:
9396
echo "\q" | make run
9497
cargo test ${TEST_NAME} -- --ignored --test-threads=1 --nocapture
9598

9699
test-unit:
97-
cargo test -- --test-threads=1
100+
cargo test ${TEST_NAME} -- --test-threads=1
98101

99102
test-version:
100103
git fetch --tags
@@ -104,6 +107,7 @@ test-version:
104107
cargo test -- --ignored --test-threads=1
105108

106109
test-update:
110+
cargo install cargo-pgrx --locked --version ${PGRX_VERSION}
107111
echo "\q" | make run
108112
psql ${DATABASE_URL} -c "CREATE EXTENSION IF NOT EXISTS vectorscale"
109113
psql ${DATABASE_URL} -c "ALTER EXTENSION vectorize UPDATE"

extension/Trunk.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description = "The simplest way to orchestrate vector search on Postgres."
66
homepage = "https://github.com/tembo-io/pg_vectorize"
77
documentation = "https://github.com/tembo-io/pg_vectorize"
88
categories = ["orchestration", "machine_learning"]
9-
version = "0.21.1"
9+
version = "0.22.0"
1010
loadable_libraries = [{ library_name = "vectorize", requires_restart = true }]
1111

1212
[build]

extension/sql/vectorize--0.21.1--0.22.0.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LANGUAGE c /* Rust */
3434
AS 'MODULE_PATHNAME', 'table_wrapper';
3535
/* </end connected objects> */
3636

37-
DROP FUNCTION vectorize."table_from";
37+
DROP FUNCTION IF EXISTS vectorize."table_from";
3838
-- src/api.rs:380
3939
-- vectorize::api::table_from
4040
CREATE FUNCTION vectorize."table_from"(
@@ -67,8 +67,7 @@ SET params = jsonb_set(
6767
WHERE params ? 'table';
6868

6969
-- Update the function to reference "relation" instead of "table"
70-
DROP FUNCTION vectorize."handle_table_drop";
71-
CREATE FUNCTION vectorize.handle_table_drop()
70+
CREATE OR REPLACE FUNCTION vectorize.handle_table_drop()
7271
RETURNS event_trigger AS $$
7372
DECLARE
7473
obj RECORD;

extension/src/api.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,7 @@ fn chunk_table(
6767
);
6868
Spi::run_with_args(
6969
&insert_query,
70-
Some(vec![
71-
(
72-
pgrx::PgOid::Custom(pgrx::pg_sys::INT4OID),
73-
original_id.into_datum(),
74-
), // OID for integer
75-
(
76-
pgrx::PgOid::Custom(pgrx::pg_sys::INT4OID),
77-
chunk_index.into_datum(),
78-
), // OID for integer
79-
(
80-
pgrx::PgOid::Custom(pgrx::pg_sys::TEXTOID),
81-
chunk.into_datum(),
82-
), // OID for text
83-
]),
70+
&[original_id.into(), chunk_index.into(), chunk.into()],
8471
)?;
8572
}
8673

@@ -271,11 +258,8 @@ fn generate(
271258

272259
#[pg_extern]
273260
fn env_interpolate_guc(guc_name: &str) -> Result<String> {
274-
let g: String = Spi::get_one_with_args(
275-
"SELECT current_setting($1)",
276-
vec![(PgBuiltInOids::TEXTOID.oid(), guc_name.into_datum())],
277-
)?
278-
.unwrap_or_else(|| panic!("no value set for guc: {guc_name}"));
261+
let g: String = Spi::get_one_with_args("SELECT current_setting($1)", &[guc_name.into()])?
262+
.unwrap_or_else(|| panic!("no value set for guc: {guc_name}"));
279263
env_interpolate_string(&g)
280264
}
281265

@@ -366,10 +350,7 @@ fn import_embeddings(
366350
"DELETE FROM pgmq.q_{} WHERE message->>'job_name' = $1",
367351
VECTORIZE_QUEUE
368352
);
369-
Spi::run_with_args(
370-
&delete_q,
371-
Some(vec![(PgBuiltInOids::TEXTOID.oid(), job_name.into_datum())]),
372-
)?;
353+
Spi::run_with_args(&delete_q, &[job_name.into()])?;
373354
}
374355

375356
Ok(format!(

extension/src/bin/pgrx_embed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// https://github.com/pgcentralfoundation/pgrx/issues/1888
2+
#![allow(unexpected_cfgs)]
23
::pgrx::pgrx_embed!();

0 commit comments

Comments
 (0)