From 2936a79b7fb70fa804f15b89997a3ac3a214d209 Mon Sep 17 00:00:00 2001 From: "Eric B. Ridge" Date: Wed, 14 Dec 2022 10:48:30 -0500 Subject: [PATCH] change the `no-cshim` feature into a default feature named `cshim`. --- .github/docker/Dockerfile.alpine:3.16 | 2 +- .github/docker/Dockerfile.amazon:2 | 4 ++-- .github/docker/Dockerfile.debian:bullseye | 2 +- .github/docker/Dockerfile.fedora:36 | 2 +- nix/extension.nix | 4 ++-- pgx-pg-sys/Cargo.toml | 6 +++--- pgx-pg-sys/build.rs | 2 +- pgx-pg-sys/src/lib.rs | 8 ++++---- pgx-tests/Cargo.toml | 4 ++-- pgx-tests/src/tests/mod.rs | 2 +- pgx-tests/src/tests/pg_try_tests.rs | 4 ++-- pgx/Cargo.toml | 8 ++++---- pgx/src/lib.rs | 14 +++++++------- pgx/src/rel.rs | 2 +- update-versions.sh | 2 +- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/docker/Dockerfile.alpine:3.16 b/.github/docker/Dockerfile.alpine:3.16 index 3a729118c..6fb955a11 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 diff --git a/.github/docker/Dockerfile.amazon:2 b/.github/docker/Dockerfile.amazon:2 index 7b5410922..54e949adf 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.amazon\:2 -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 @@ -127,4 +127,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 3b921b253..d8fec8200 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.debian\:bullseye -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 diff --git a/.github/docker/Dockerfile.fedora:36 b/.github/docker/Dockerfile.fedora:36 index fe748f334..6de618c23 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.fedora\:36 -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 diff --git a/nix/extension.nix b/nix/extension.nix index 6d2ed9650..16641a520 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 4afcc88d2..41739b83a 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 4459ffcbc..7e5c209d8 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 4ec7ed481..3d6bb9972 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 c1e6d5c1e..5864a22db 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 acadae2c7..b7ab818db 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 6193779ba..46b052056 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 43307d632..d85ffe6ed 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 2ccbd231f..4f3eeac78 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 cdb3ddeb3..96ec4bc0a 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 b68eef742..a0ea5b477 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!"