diff --git a/.github/docker/Dockerfile.alpine:3.16 b/.github/docker/Dockerfile.alpine:3.16 index 120aa69079..027bd05c28 100644 --- a/.github/docker/Dockerfile.alpine:3.16 +++ b/.github/docker/Dockerfile.alpine:3.16 @@ -2,7 +2,7 @@ # docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.alpine\:3.16 -t pgx-alpine . # # Example of how to run this container with tests after building the image: -# docker run pgx-alpine cargo test --no-default-features --features pg14 --locked +# docker run pgx-alpine cargo test --no-default-features --features "pg14" --locked # # Note that "PG_MAJOR_VER" build arg in the build step must match the # "--features pgXX" in the run step @@ -56,4 +56,4 @@ RUN cargo install --path cargo-pgx/ --locked # into the postgres:XX-alpine3.16 images, so it was easier to go with the grain RUN cargo pgx init --pg$PG_MAJOR=$(which pg_config) -CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"] +CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim"] diff --git a/.github/docker/Dockerfile.amazon:2 b/.github/docker/Dockerfile.amazon:2 index 82e6c6ee15..c3049162b7 100644 --- a/.github/docker/Dockerfile.amazon:2 +++ b/.github/docker/Dockerfile.amazon:2 @@ -2,7 +2,7 @@ # docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.alpine\:3.16 -t pgx-amazonlinux2 . # # Example of how to run this container with tests after building the image: -# docker run pgx-amazonlinux2 cargo test --no-default-features --features pg14 --locked +# docker run pgx-amazonlinux2 cargo test --no-default-features --features "pg14" --locked # # Note that "PG_MAJOR_VER" build arg in the build step must match the # "--features pgXX" in the run step @@ -77,7 +77,7 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y ENV PATH="/home/rust/.cargo/bin:${PATH}" RUN cargo install --path cargo-pgx/ --locked RUN cargo pgx init --pg$PG_MAJOR_VER=$(which pg_config) -CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"] +CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim"] # === Previous "amazon-linux-extras" steps, kept for historical purposes === # RUN amazon-linux-extras enable postgresql$PG_MAJOR_VER @@ -116,4 +116,4 @@ CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}" # ENV PATH="/home/rust/.cargo/bin:${PATH}" # RUN cargo install --path cargo-pgx/ # RUN cargo pgx init --pg$PG_MAJOR_VER=$(which pg_config) -# CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"] +# CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim"] diff --git a/.github/docker/Dockerfile.debian:bullseye b/.github/docker/Dockerfile.debian:bullseye index c8d910a148..6b10721e72 100644 --- a/.github/docker/Dockerfile.debian:bullseye +++ b/.github/docker/Dockerfile.debian:bullseye @@ -2,7 +2,7 @@ # docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.alpine\:3.16 -t pgx-debian. # # Example of how to run this container with tests after building the image: -# docker run pgx-debian cargo test --no-default-features --features pg14 --locked +# docker run pgx-debian cargo test --no-default-features --features "pg14" --locked # # Note that "PG_MAJOR_VER" build arg in the build step must match the # "--features pgXX" in the run step @@ -60,4 +60,4 @@ RUN cargo install --path cargo-pgx/ --locked # Initialize cargo pgx so that we can run the tests RUN cargo pgx init --pg$PG_MAJOR_VER=$(which pg_config) -CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"] +CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim"] diff --git a/.github/docker/Dockerfile.fedora:36 b/.github/docker/Dockerfile.fedora:36 index 288615c776..5becaafaef 100644 --- a/.github/docker/Dockerfile.fedora:36 +++ b/.github/docker/Dockerfile.fedora:36 @@ -2,7 +2,7 @@ # docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.alpine\:3.16 -t pgx-fedora . # # Example of how to run this container with tests after building the image: -# docker run pgx-fedora cargo test --no-default-features --features pg14 --locked +# docker run pgx-fedora cargo test --no-default-features --features "pg14" --locked # # Note that "PG_MAJOR_VER" build arg in the build step must match the # "--features pgXX" in the run step @@ -51,4 +51,4 @@ RUN cargo install --path cargo-pgx/ --locked # Initialize cargo pgx so that we can run the tests RUN cargo pgx init --pg$PG_MAJOR_VER=/usr/pgsql-$PG_MAJOR_VER/bin/pg_config -CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"] +CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim"] diff --git a/.github/docker/run-docker.sh b/.github/docker/run-docker.sh index 2b2f842e13..0a3744f9e9 100755 --- a/.github/docker/run-docker.sh +++ b/.github/docker/run-docker.sh @@ -11,4 +11,4 @@ docker build \ echo "Running PGX test suite using Postgres version $PG_MAJOR_VER in container $DOCKERFILE_ID" -docker run pgx cargo test --no-default-features --features pg$PG_MAJOR_VER --locked +docker run pgx cargo test --no-default-features --features "pg$PG_MAJOR_VER cshim" --locked diff --git a/nix/extension.nix b/nix/extension.nix index 6d2ed9650e..16641a5203 100644 --- a/nix/extension.nix +++ b/nix/extension.nix @@ -106,8 +106,8 @@ naersk.lib."${targetPlatform.system}".buildPackage rec { CARGO_BUILD_INCREMENTAL = "false"; RUST_BACKTRACE = "full"; - cargoBuildOptions = default: default ++ [ "--no-default-features" "--features \"pg${pgxPostgresMajor} ${builtins.toString additionalFeatures}\"" ]; - cargoTestOptions = default: default ++ [ "--no-default-features" "--features \"pg_test pg${pgxPostgresMajor} ${builtins.toString additionalFeatures}\"" ]; + cargoBuildOptions = default: default ++ [ "--no-default-features" "--features \"pg${pgxPostgresMajor} ${builtins.toString cshim additionalFeatures}\"" ]; + cargoTestOptions = default: default ++ [ "--no-default-features" "--features \"pg_test pg${pgxPostgresMajor} ${builtins.toString cshim additionalFeatures}\"" ]; doDoc = false; copyLibs = false; copyBins = false; diff --git a/pgx-pg-sys/Cargo.toml b/pgx-pg-sys/Cargo.toml index 4afcc88d2a..41739b83a6 100644 --- a/pgx-pg-sys/Cargo.toml +++ b/pgx-pg-sys/Cargo.toml @@ -11,17 +11,17 @@ readme = "README.md" edition = "2021" [features] -default = [ ] +default = [ "cshim" ] pg11 = [ ] pg12 = [ ] pg13 = [ ] pg14 = [ ] pg15 = [ ] postgrestd = [ ] -no-cshim = [ ] +cshim = [ ] [package.metadata.docs.rs] -features = ["pg14"] +features = ["pg14", "cshim"] no-default-features = true targets = ["x86_64-unknown-linux-gnu"] # Enable `#[cfg(docsrs)]` (https://docs.rs/about/builds#cross-compiling) diff --git a/pgx-pg-sys/build.rs b/pgx-pg-sys/build.rs index 4459ffcbc4..7e5c209d8f 100644 --- a/pgx-pg-sys/build.rs +++ b/pgx-pg-sys/build.rs @@ -90,7 +90,7 @@ fn main() -> eyre::Result<()> { } let compile_cshim = - std::env::var("CARGO_FEATURE_NO_CSHIM").unwrap_or_else(|_| "0".to_string()) == "0"; + std::env::var("CARGO_FEATURE_CSHIM").unwrap_or_else(|_| "0".to_string()) == "1"; let is_for_release = std::env::var("PGX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE").unwrap_or("0".to_string()) == "1"; diff --git a/pgx-pg-sys/src/lib.rs b/pgx-pg-sys/src/lib.rs index 4ec7ed481a..3d6bb99724 100644 --- a/pgx-pg-sys/src/lib.rs +++ b/pgx-pg-sys/src/lib.rs @@ -285,7 +285,7 @@ mod all_versions { pub const FirstNormalTransactionId: super::TransactionId = 3 as super::TransactionId; pub const MaxTransactionId: super::TransactionId = 0xFFFF_FFFF as super::TransactionId; - #[cfg(not(feature = "no-cshim"))] + #[cfg(feature = "cshim")] #[pgx_macros::pg_guard] extern "C" { pub fn pgx_list_nth(list: *mut super::List, nth: i32) -> *mut std::os::raw::c_void; @@ -451,7 +451,7 @@ mod all_versions { super::get_element_type(typoid) != InvalidOid } - #[cfg(not(feature = "no-cshim"))] + #[cfg(feature = "cshim")] #[pg_guard] extern "C" { #[link_name = "pgx_planner_rt_fetch"] @@ -465,7 +465,7 @@ mod all_versions { /// #define rt_fetch(rangetable_index, rangetable) \ /// ((RangeTblEntry *) list_nth(rangetable, (rangetable_index)-1)) /// ``` - #[cfg(not(feature = "no-cshim"))] + #[cfg(feature = "cshim")] #[inline] pub unsafe fn rt_fetch( index: super::Index, @@ -552,7 +552,7 @@ mod all_versions { ) -> bool; } - #[cfg(not(feature = "no-cshim"))] + #[cfg(feature = "cshim")] #[pgx_macros::pg_guard] extern "C" { #[link_name = "pgx_SpinLockInit"] diff --git a/pgx-tests/Cargo.toml b/pgx-tests/Cargo.toml index a74ff7c207..592bf742e9 100644 --- a/pgx-tests/Cargo.toml +++ b/pgx-tests/Cargo.toml @@ -14,14 +14,14 @@ edition = "2021" crate-type = [ "cdylib", "lib" ] [features] -default = [ ] +default = [ "cshim" ] pg11 = [ "pgx/pg11" ] pg12 = [ "pgx/pg12" ] pg13 = [ "pgx/pg13" ] pg14 = [ "pgx/pg14" ] pg15 = [ "pgx/pg15" ] pg_test = [ ] -no-cshim = [ "pgx/no-cshim" ] +cshim = [ "pgx/cshim" ] no-schema-generation = [ "pgx/no-schema-generation", "pgx-macros/no-schema-generation" ] [package.metadata.docs.rs] diff --git a/pgx-tests/src/tests/mod.rs b/pgx-tests/src/tests/mod.rs index acadae2c71..b7ab818db0 100644 --- a/pgx-tests/src/tests/mod.rs +++ b/pgx-tests/src/tests/mod.rs @@ -21,7 +21,7 @@ mod enum_type_tests; mod fcinfo_tests; mod guc_tests; mod heap_tuple; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] mod hooks_tests; mod inet_tests; mod internal_tests; diff --git a/pgx-tests/src/tests/pg_try_tests.rs b/pgx-tests/src/tests/pg_try_tests.rs index 6193779ba7..46b0520563 100644 --- a/pgx-tests/src/tests/pg_try_tests.rs +++ b/pgx-tests/src/tests/pg_try_tests.rs @@ -13,7 +13,7 @@ use pgx::prelude::*; // will crash postgres. If things are correct it'll simply raise an ERROR saying "panic in walker". #[pg_extern] fn crash() { - #[cfg(not(feature = "no-cshim"))] + #[cfg(feature = "cshim")] { use pgx::PgList; unsafe { @@ -28,7 +28,7 @@ fn crash() { } } - #[cfg(feature = "no-cshim")] + #[cfg(not(feature = "cshim"))] { walker(); } diff --git a/pgx/Cargo.toml b/pgx/Cargo.toml index 43307d6323..d85ffe6ed5 100644 --- a/pgx/Cargo.toml +++ b/pgx/Cargo.toml @@ -16,10 +16,10 @@ edition = "2021" crate-type = [ "rlib" ] [features] -default = [ ] -plrust = [ "postgrestd", "no-cshim" ] +default = [ "cshim" ] +plrust = [ "postgrestd" ] postgrestd = ["pgx-pg-sys/postgrestd"] -no-cshim = [ "pgx-pg-sys/no-cshim" ] +cshim = [ "pgx-pg-sys/cshim" ] pg11 = [ "pgx-pg-sys/pg11" ] pg12 = [ "pgx-pg-sys/pg12" ] pg13 = [ "pgx-pg-sys/pg13" ] @@ -29,7 +29,7 @@ time-crate = ["dep:time"] no-schema-generation = ["pgx-macros/no-schema-generation", "pgx-sql-entity-graph/no-schema-generation"] [package.metadata.docs.rs] -features = ["pg14"] +features = ["pg14", "cshim"] no-default-features = true # Enable `#[cfg(docsrs)]` (https://docs.rs/about/builds#cross-compiling) rustc-args = ["--cfg", "docsrs"] diff --git a/pgx/src/lib.rs b/pgx/src/lib.rs index 2ccbd231f4..4f3eeac78b 100644 --- a/pgx/src/lib.rs +++ b/pgx/src/lib.rs @@ -46,25 +46,25 @@ pub mod fcinfo; pub mod ffi; pub mod guc; pub mod heap_tuple; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] pub mod hooks; pub mod htup; pub mod inoutfuncs; pub mod itemptr; pub mod iter; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] pub mod list; pub mod lwlock; pub mod memcxt; pub mod misc; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] pub mod namespace; pub mod nodes; pub mod pgbox; pub mod rel; pub mod shmem; pub mod spi; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] pub mod spinlock; pub mod stringinfo; pub mod trigger_support; @@ -87,16 +87,16 @@ pub use datum::*; pub use enum_helper::*; pub use fcinfo::*; pub use guc::*; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] pub use hooks::*; pub use htup::*; pub use inoutfuncs::*; pub use itemptr::*; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] pub use list::*; pub use lwlock::*; pub use memcxt::*; -#[cfg(not(feature = "no-cshim"))] +#[cfg(feature = "cshim")] pub use namespace::*; pub use nodes::*; pub use pgbox::*; diff --git a/pgx/src/rel.rs b/pgx/src/rel.rs index cdb3ddeb3f..96ec4bc0aa 100644 --- a/pgx/src/rel.rs +++ b/pgx/src/rel.rs @@ -186,7 +186,7 @@ impl PgRelation { } /// Return an iterator of indices, as `PgRelation`s, attached to this relation - #[cfg(not(feature = "no-cshim"))] + #[cfg(feature = "cshim")] pub fn indices( &self, lockmode: pg_sys::LOCKMODE, diff --git a/update-versions.sh b/update-versions.sh index b68eef7427..a0ea5b4775 100755 --- a/update-versions.sh +++ b/update-versions.sh @@ -68,6 +68,6 @@ echo "Upgrading dependency versions" ./upgrade-deps.sh echo "Generating bindings -- this may take a few moments" -PGX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE=1 cargo test --no-run $CARGO_QUIET_FLAG --workspace --no-default-features --features "pg14" +PGX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE=1 cargo test --no-run $CARGO_QUIET_FLAG --workspace --no-default-features --features "pg14 cshim" echo "Done!"