From 589a7ee8884315ecc289ce62aaa6ec9fefc9f3df Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Sun, 25 Aug 2024 01:45:48 +0000 Subject: [PATCH 1/3] chore: Bump pgrx to 0.12.1 --- .github/workflows/lint-rust.yml | 2 +- .github/workflows/test-pg_analytics.yml | 2 +- Cargo.toml | 6 +++--- README.md | 2 +- src/api/time_bucket.rs | 2 +- src/fdw/handler.rs | 2 +- src/hooks/executor.rs | 7 ++++--- src/hooks/mod.rs | 5 +++-- src/hooks/query.rs | 2 +- src/lib.rs | 1 + 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint-rust.yml b/.github/workflows/lint-rust.yml index ca72ac6e..6f13579e 100644 --- a/.github/workflows/lint-rust.yml +++ b/.github/workflows/lint-rust.yml @@ -37,7 +37,7 @@ jobs: sudo apt-get update && sudo apt-get install -y postgresql-${{ matrix.pg_version }} postgresql-server-dev-${{ matrix.pg_version }} - name: Install pgrx - run: cargo install --locked cargo-pgrx --version 0.11.3 + run: cargo install --locked cargo-pgrx --version 0.12.1 - name: Initialize pgrx for Current PostgreSQL Version run: cargo pgrx init --pg${{ matrix.pg_version }}=/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config diff --git a/.github/workflows/test-pg_analytics.yml b/.github/workflows/test-pg_analytics.yml index b4fe97a4..1b3b49a0 100644 --- a/.github/workflows/test-pg_analytics.yml +++ b/.github/workflows/test-pg_analytics.yml @@ -95,7 +95,7 @@ jobs: - name: Install pgrx & llvm-tools-preview if: steps.check_skip.outputs.skip_remaining_steps != 'true' run: | - cargo install -j $(nproc) --locked cargo-pgrx --version 0.11.3 + cargo install -j $(nproc) --locked cargo-pgrx --version 0.12.1 rustup component add llvm-tools-preview cargo pgrx init "--pg${{ matrix.pg_version }}=/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config" diff --git a/Cargo.toml b/Cargo.toml index db4cbe8f..742fe920 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,13 +26,13 @@ duckdb = { git = "https://github.com/paradedb/duckdb-rs.git", features = [ "bundled", "extensions-full", ], rev = "e532dd6" } -pgrx = "0.11.3" +pgrx = "0.12.1" serde = "1.0.201" serde_json = "1.0.120" signal-hook = "0.3.17" signal-hook-async-std = "0.2.2" strum = { version = "0.26.3", features = ["derive"] } -supabase-wrappers = { git = "https://github.com/paradedb/wrappers.git", default-features = false, rev = "27af09b" } +supabase-wrappers = { git = "https://github.com/paradedb/wrappers.git", default-features = false, rev = "c6f5e79" } thiserror = "1.0.59" uuid = "1.9.1" @@ -44,7 +44,7 @@ bytes = "1.7.1" datafusion = "37.1.0" deltalake = { version = "0.17.3", features = ["datafusion"] } futures = "0.3.30" -pgrx-tests = "0.11.3" +pgrx-tests = "0.12.1" rstest = "0.19.0" serde_arrow = { version = "0.11.3", features = ["arrow-51"] } soa_derive = "0.13.0" diff --git a/README.md b/README.md index a27c62dc..b38e575b 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ Then, install and initialize `pgrx`: ```bash # Note: Replace --pg16 with your version of Postgres, if different (i.e. --pg15, --pg14, etc.) -cargo install --locked cargo-pgrx --version 0.11.3 +cargo install --locked cargo-pgrx --version 0.12.1 # macOS arm64 cargo pgrx init --pg16=/opt/homebrew/opt/postgresql@16/bin/pg_config diff --git a/src/api/time_bucket.rs b/src/api/time_bucket.rs index c64f19f2..399c57a4 100644 --- a/src/api/time_bucket.rs +++ b/src/api/time_bucket.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -use pgrx::*; +use pgrx::{datum::*, pg_extern}; const TIME_BUCKET_FALLBACK_ERROR: &str = "Function `time_bucket()` must be used with a DuckDB FDW. Native postgres does not support this function. If you believe this function should be implemented natively as a fallback please submit a ticket to https://github.com/paradedb/pg_analytics/issues."; diff --git a/src/fdw/handler.rs b/src/fdw/handler.rs index 26378c49..3fc30dea 100644 --- a/src/fdw/handler.rs +++ b/src/fdw/handler.rs @@ -49,7 +49,7 @@ impl From<*mut pg_sys::ForeignServer> for FdwHandler { let handler_oid = unsafe { (*fdw).fdwhandler }; let proc_tuple = unsafe { pg_sys::SearchSysCache1( - pg_sys::SysCacheIdentifier_PROCOID as i32, + pg_sys::SysCacheIdentifier::PROCOID as i32, handler_oid.into_datum().unwrap(), ) }; diff --git a/src/hooks/executor.rs b/src/hooks/executor.rs index 5ff20cb9..a57f9a24 100644 --- a/src/hooks/executor.rs +++ b/src/hooks/executor.rs @@ -32,14 +32,15 @@ macro_rules! fallback_warning { }; } +#[allow(deprecated)] pub async fn executor_run( query_desc: PgBox, - direction: pg_sys::ScanDirection, + direction: pg_sys::ScanDirection::Type, count: u64, execute_once: bool, prev_hook: fn( query_desc: PgBox, - direction: pg_sys::ScanDirection, + direction: pg_sys::ScanDirection::Type, count: u64, execute_once: bool, ) -> HookResult<()>, @@ -61,7 +62,7 @@ pub async fn executor_run( }); if rtable.is_null() - || query_desc.operation != pg_sys::CmdType_CMD_SELECT + || query_desc.operation != pg_sys::CmdType::CMD_SELECT || !is_duckdb_query // Tech Debt: Find a less hacky way to let COPY/CREATE go through || query.to_lowercase().starts_with("copy") diff --git a/src/hooks/mod.rs b/src/hooks/mod.rs index 30f51d4d..0bf5fff4 100644 --- a/src/hooks/mod.rs +++ b/src/hooks/mod.rs @@ -23,16 +23,17 @@ use pgrx::*; pub struct ExtensionHook; +#[allow(deprecated)] impl hooks::PgHooks for ExtensionHook { fn executor_run( &mut self, query_desc: PgBox, - direction: pg_sys::ScanDirection, + direction: pg_sys::ScanDirection::Type, count: u64, execute_once: bool, prev_hook: fn( query_desc: PgBox, - direction: pg_sys::ScanDirection, + direction: pg_sys::ScanDirection::Type, count: u64, execute_once: bool, ) -> HookResult<()>, diff --git a/src/hooks/query.rs b/src/hooks/query.rs index de77365c..2994a27c 100644 --- a/src/hooks/query.rs +++ b/src/hooks/query.rs @@ -68,7 +68,7 @@ pub fn get_query_relations(planned_stmt: *mut pg_sys::PlannedStmt) -> Vec Date: Sun, 25 Aug 2024 01:59:58 +0000 Subject: [PATCH 2/3] chore: Add bin --- Cargo.toml | 4 ++++ src/bin/pgrx_embed.rs | 1 + 2 files changed, 5 insertions(+) create mode 100644 src/bin/pgrx_embed.rs diff --git a/Cargo.toml b/Cargo.toml index 742fe920..9b44539e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,3 +60,7 @@ tempfile = "3.12.0" testcontainers = "0.16.7" testcontainers-modules = { version = "0.4.2", features = ["localstack"] } time = { version = "0.3.34", features = ["serde"] } + +[[bin]] +name = "pgrx_embed_pg_analytics" +path = "src/bin/pgrx_embed.rs" diff --git a/src/bin/pgrx_embed.rs b/src/bin/pgrx_embed.rs new file mode 100644 index 00000000..5f5c4d85 --- /dev/null +++ b/src/bin/pgrx_embed.rs @@ -0,0 +1 @@ +::pgrx::pgrx_embed!(); From 0463d82ab9b90f824fae45b77543dbb6067ae44b Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Sun, 25 Aug 2024 02:03:38 +0000 Subject: [PATCH 3/3] chore: Upate the version in ci --- .github/workflows/benchmark-pg_analytics.yml | 2 +- .github/workflows/publish-pg_analytics.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark-pg_analytics.yml b/.github/workflows/benchmark-pg_analytics.yml index d50b5742..28ad0a06 100644 --- a/.github/workflows/benchmark-pg_analytics.yml +++ b/.github/workflows/benchmark-pg_analytics.yml @@ -60,7 +60,7 @@ jobs: - name: Install pgrx & pg_analytics run: | - cargo install -j $(nproc) --locked cargo-pgrx --version 0.11.3 + cargo install -j $(nproc) --locked cargo-pgrx --version 0.12.1 cargo pgrx init --pg${{ matrix.pg_version }}=/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config cargo pgrx install --pg-config="/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config" --release diff --git a/.github/workflows/publish-pg_analytics.yml b/.github/workflows/publish-pg_analytics.yml index 7675c1f5..7a38a8d5 100644 --- a/.github/workflows/publish-pg_analytics.yml +++ b/.github/workflows/publish-pg_analytics.yml @@ -300,7 +300,7 @@ jobs: sudo dnf install -y postgresql${{ matrix.pg_version }} postgresql${{ matrix.pg_version }}-server postgresql${{ matrix.pg_version }}-devel - name: Install pgrx - run: cargo install -j $(nproc) --locked cargo-pgrx --version 0.11.3 + run: cargo install -j $(nproc) --locked cargo-pgrx --version 0.12.1 # Note: We need to specify bash as the shell to ensure that it doesn't default to /bin/sh on Debian, which doesn't support the `[[` syntax - name: Initialize pgrx for Current PostgreSQL Version