diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 520a7d8..04b2c1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,12 +30,31 @@ jobs: run: docker buildx build --build-arg PG_MAJOR=${{ matrix.postgres }} -t test . - name: Test run: docker run test cargo pgrx test pg${{ matrix.postgres }} + + test_next: + name: Test builds on the next version of Postgres + strategy: + fail-fast: false + matrix: + postgres: [18beta1] + runner: + - ubuntu-22.04 + - ubuntu-22.04-arm + runs-on: ${{ matrix.runner }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build + run: docker buildx build --build-arg PG_MAJOR=${{ matrix.postgres }} --build-arg NEXT=true -t test . + - name: Test + run: docker run test cargo pgrx test pg${{ matrix.postgres }} + lint: name: Linting (fmt + clippy) runs-on: ubuntu-latest steps: - name: Install rust - uses: dtolnay/rust-toolchain@1.81.0 + uses: dtolnay/rust-toolchain@1.85.0 with: components: rustfmt, clippy - name: Checkout @@ -52,6 +71,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install rust - uses: dtolnay/rust-toolchain@1.81.0 + uses: dtolnay/rust-toolchain@1.85.0 - name: Lockfile check run: cargo update -w --locked diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4161060..23a02de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,7 +42,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install rust - uses: dtolnay/rust-toolchain@1.81.0 + uses: dtolnay/rust-toolchain@1.85.0 - name: Install dependencies run: | # Add postgres package repo diff --git a/Cargo.toml b/Cargo.toml index 8cfe65e..85c21ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ publish = false version = "0.2.0" edition = "2021" -rust-version = "1.81.0" +rust-version = "1.82.0" [lib] crate-type = ["cdylib", "lib"] diff --git a/Dockerfile b/Dockerfile index 6a00d51..e90d94d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ ARG PG_MAJOR +ARG NEXT FROM postgres:${PG_MAJOR} @@ -25,13 +26,19 @@ RUN chown postgres:postgres /home/postgres USER postgres RUN \ - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain 1.81.0 && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain 1.85.0 && \ rustup --version && \ rustc --version && \ cargo --version -# pgrx -RUN cargo install cargo-pgrx --version 0.12.7 --locked +ARG NEXT +RUN if [ "$NEXT" = "true" ] ; then \ + echo "Installing pgrx from GitHub repository" && \ + cargo install --git https://github.com/pgcentralfoundation/pgrx --branch develop cargo-pgrx --locked ; \ + else \ + echo "Installing pgrx from crates.io" && \ + cargo install cargo-pgrx --version 0.12.7 --locked ; \ + fi RUN cargo pgrx init --pg${PG_MAJOR} $(which pg_config) @@ -39,6 +46,20 @@ USER root COPY . . +RUN if [ "$NEXT" = "true" ] ; then \ + # update Rust edition from what exists in Cargo.toml + sed -i 's/edition[[:space:]]*=[[:space:]]*"[^"]*"/edition = "2024"/g' Cargo.toml && \ + # update Rust version from what exists in Cargo.toml + sed -i 's/rust-version[[:space:]]*=[[:space:]]*"[^"]*"/rust-version = "1.85.0"/g' Cargo.toml && \ + # update pgrx versions from what exists in Cargo.toml + sed -i 's/pgrx[[:space:]]*=[[:space:]]*"[^"]*"/pgrx = "0.15.0"/g' Cargo.toml && \ + sed -i 's/pgrx-tests[[:space:]]*=[[:space:]]*"[^"]*"/pgrx-tests = "0.15.0"/g' Cargo.toml && \ + # add required features for next PG + sed -i '/pg17[[:space:]]*=[[:space:]]*\[.*\]/a pg18 = ["pgrx-tests/pg18", "pgrx/pg18"]' Cargo.toml && \ + echo "=== Updated Cargo.toml contents ===" && \ + cat Cargo.toml ; \ + fi + RUN cargo pgrx install RUN chown -R postgres:postgres /home/postgres diff --git a/src/lib.rs b/src/lib.rs index c0c14d6..b2c3a98 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,16 +4,17 @@ use pg_sys::Datum as SysDatum; use pgrx::callconv::{ArgAbi, BoxRet}; use pgrx::datum::Datum; use pgrx::{ - pg_shmem_init, pg_sys::Oid, prelude::*, rust_regtypein, shmem::*, PgLwLock, StringInfo, Uuid, + pg_shmem_init, pg_sys::Oid, prelude::*, rust_regtypein, PgLwLock, PgSharedMemoryInitialization, + StringInfo, Uuid, }; use std::time::{Duration, SystemTime}; ::pgrx::pg_module_magic!(); -static SHARED_ULID: PgLwLock = PgLwLock::new(); +static SHARED_ULID: PgLwLock = PgLwLock::new(c"pgx_ulid_shared"); #[pg_guard] -pub extern "C" fn _PG_init() { +pub extern "C-unwind" fn _PG_init() { pg_shmem_init!(SHARED_ULID); } @@ -69,7 +70,7 @@ impl FromDatum for ulid { where Self: Sized, { - let bytes: &[u8] = FromDatum::from_polymorphic_datum(datum, is_null, typoid)?; + let bytes: &[u8] = unsafe { FromDatum::from_polymorphic_datum(datum, is_null, typoid)? }; let mut len_bytes = [0u8; 16]; len_bytes.copy_from_slice(bytes);