From 6a62466514d2643f6a04a256e7e529a8cd3f6fcd Mon Sep 17 00:00:00 2001 From: David Christensen Date: Mon, 28 Oct 2024 14:06:55 -0400 Subject: [PATCH] tweaks for pg13 --- src/arrow_parquet/arrow_to_pg.rs | 4 ++-- src/lib.rs | 1 + src/pgrx_utils.rs | 13 ++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/arrow_parquet/arrow_to_pg.rs b/src/arrow_parquet/arrow_to_pg.rs index ac619c3..c3e2f3f 100644 --- a/src/arrow_parquet/arrow_to_pg.rs +++ b/src/arrow_parquet/arrow_to_pg.rs @@ -17,8 +17,8 @@ use pgrx::{ use crate::{ pgrx_utils::{ array_element_typoid, collect_valid_attributes, domain_array_base_elem_typoid, - is_array_type, is_composite_type, is_supported_array_element_type, is_supported_composite_type, - tuple_desc, + is_array_type, is_composite_type, is_supported_array_element_type, + is_supported_composite_type, tuple_desc, }, type_compat::{ fallback_to_text::{reset_fallback_to_text_context, FallbackToText}, diff --git a/src/lib.rs b/src/lib.rs index 1c081a3..5122154 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2353,6 +2353,7 @@ mod tests { Spi::run(parquet_metadata_command).unwrap(); } + #[cfg(not(feature = "pg13"))] #[pg_test] #[should_panic( expected = "type mismatch for column \"location\" between table and parquet file" diff --git a/src/pgrx_utils.rs b/src/pgrx_utils.rs index 8e30e25..0f3e2fa 100644 --- a/src/pgrx_utils.rs +++ b/src/pgrx_utils.rs @@ -59,16 +59,19 @@ pub(crate) fn is_array_type(typoid: Oid) -> bool { unsafe { type_is_array(typoid) } } -pub(crate) fn is_supported_array_element_type(array_element_id: Oid) -> bool { +pub(crate) fn is_supported_array_element_type(_array_element_id: Oid) -> bool { #[cfg(feature = "pg13")] - return u32::from(array_element_id) < FirstNormalObjectId; - #[cfg(not(feature = "pg13"))] + if u32::from(_array_element_id) >= FirstNormalObjectId { + // we don't support arrays of user-defined composite types in pg 13 + return !is_composite_type(_array_element_id); + } + true } -pub(crate) fn is_supported_composite_type(composite_id: Oid) -> bool { +pub(crate) fn is_supported_composite_type(_composite_id: Oid) -> bool { #[cfg(feature = "pg13")] - return u32::from(composite_id) < FirstNormalObjectId; + return !u32::from(_composite_id) >= FirstNormalObjectId; #[cfg(not(feature = "pg13"))] true }