Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list specific versions in feature gates #1175

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pgrx-pg-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,13 @@ mod all_versions {
) -> pg_sys::MemoryContext {
// Postgres versions <16 don't export the "GetMemoryChunkContext" function. It's a "static inline"
// function in `memutils.h`, so we port it to Rust right here
#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
{
/*
* Try to detect bogus pointers handed to us, poorly though we can.
Expand Down
13 changes: 11 additions & 2 deletions pgrx-tests/src/tests/pg_try_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ fn crash() {
let mut node = PgList::<pg_sys::Node>::new();
node.push(PgList::<pg_sys::Node>::new().into_pg() as *mut pg_sys::Node);

#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
unsafe {
pg_sys::raw_expression_tree_walker(
node.into_pg() as *mut pg_sys::Node,
Expand All @@ -43,7 +49,10 @@ fn walker() -> bool {
panic!("panic in walker");
}

#[cfg(all(feature = "cshim", not(feature = "pg16")))]
#[cfg(all(
feature = "cshim",
any(feature = "pg11", feature = "pg12", feature = "pg13", feature = "pg14", feature = "pg15")
))]
#[pg_guard]
extern "C" fn walker() -> bool {
panic!("panic in walker");
Expand Down
16 changes: 14 additions & 2 deletions pgrx/src/datum/datetime_support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,13 @@ pub fn get_timezone_offset<Tz: AsRef<str>>(zone: Tz) -> Result<i32, DateTimeConv
.execute()
}

#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
pub fn get_timezone_offset<Tz: AsRef<str>>(zone: Tz) -> Result<i32, DateTimeConversionError> {
/*
* Look up the requested timezone. First we look in the timezone
Expand All @@ -586,7 +592,13 @@ pub fn get_timezone_offset<Tz: AsRef<str>>(zone: Tz) -> Result<i32, DateTimeConv
pg_sys::downcase_truncate_identifier(tzname.as_ptr(), zone.as_ref().len() as _, false);

tztype = {
#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
{
pg_sys::DecodeTimezoneAbbrev(0, lowzone, &mut val, &mut tzp) as u32
}
Expand Down
8 changes: 7 additions & 1 deletion pgrx/src/datum/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,13 @@ where
lower_bound.lower = true;

// PG will serialize these lower/upper RangeBounds to a *RangeType ptr/datum
#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
let range_type =
pg_sys::make_range(typecache, &mut lower_bound, &mut upper_bound, is_empty);

Expand Down
24 changes: 21 additions & 3 deletions pgrx/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@ pub unsafe fn register_hook(hook: &'static mut (dyn PgHooks)) {
if HOOKS.is_some() {
panic!("PgHook instance already registered");
}
#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
let prev_executor_check_perms_hook = pg_sys::ExecutorCheckPerms_hook
.replace(pgrx_executor_check_perms)
.or(Some(pgrx_standard_executor_check_perms_wrapper));
Expand Down Expand Up @@ -321,7 +327,13 @@ unsafe extern "C" fn pgrx_executor_end(query_desc: *mut pg_sys::QueryDesc) {
hook.executor_end(PgBox::from_pg(query_desc), prev);
}

#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
#[pg_guard]
unsafe extern "C" fn pgrx_executor_check_perms(
range_table: *mut pg_sys::List,
Expand Down Expand Up @@ -636,7 +648,13 @@ unsafe extern "C" fn pgrx_standard_executor_end_wrapper(query_desc: *mut pg_sys:
pg_sys::standard_ExecutorEnd(query_desc)
}

#[cfg(not(feature = "pg16"))]
#[cfg(any(
feature = "pg11",
feature = "pg12",
feature = "pg13",
feature = "pg14",
feature = "pg15"
))]
#[pg_guard]
unsafe extern "C" fn pgrx_standard_executor_check_perms_wrapper(
_range_table: *mut pg_sys::List,
Expand Down