Skip to content

Commit

Permalink
change the no-cshim feature into a default feature named cshim.
Browse files Browse the repository at this point in the history
  • Loading branch information
eeeebbbbrrrr committed Dec 14, 2022
1 parent a03fc3c commit f3442a0
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/docker/Dockerfile.alpine:3.16
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
6 changes: 3 additions & 3 deletions .github/docker/Dockerfile.amazon:2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions .github/docker/Dockerfile.debian:bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions .github/docker/Dockerfile.fedora:36
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion .github/docker/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions nix/extension.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions pgx-pg-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pgx-pg-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 4 additions & 4 deletions pgx-pg-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"]
Expand All @@ -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,
Expand Down Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions pgx-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pgx-tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pgx-tests/src/tests/pg_try_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,7 +28,7 @@ fn crash() {
}
}

#[cfg(feature = "no-cshim")]
#[cfg(not(feature = "cshim"))]
{
walker();
}
Expand Down
8 changes: 4 additions & 4 deletions pgx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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"]
Expand Down
14 changes: 7 additions & 7 deletions pgx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion pgx/src/rel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion update-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"

0 comments on commit f3442a0

Please sign in to comment.