Skip to content

Commit

Permalink
tweaks for pg13
Browse files Browse the repository at this point in the history
  • Loading branch information
pgguru committed Oct 28, 2024
1 parent dbec8e9 commit 6a62466
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/arrow_parquet/arrow_to_pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 8 additions & 5 deletions src/pgrx_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6a62466

Please sign in to comment.