Skip to content

Commit

Permalink
only use current schema query on pg13
Browse files Browse the repository at this point in the history
  • Loading branch information
pert5432 committed Oct 8, 2024
1 parent cc41a00 commit 0900565
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/fdw/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ unsafe fn auto_create_schema_impl(fcinfo: pg_sys::FunctionCallInfo) -> Result<()
// Get relation name, oid, etc. that triggered the event
let relation = create_stmt.relation;

#[cfg(feature = "pg13")]
// Fetch the current schema name if the pointer to it is null
// This pointer is null in pg13 when the user doesn't specify the schema in the CREATE FOREIGN TABLE statement
let schema_name = match ((*relation).schemaname as *const c_char).is_null() {
Expand All @@ -108,6 +109,9 @@ unsafe fn auto_create_schema_impl(fcinfo: pg_sys::FunctionCallInfo) -> Result<()
false => CStr::from_ptr((*relation).schemaname).to_str()?,
};

#[cfg(not(feature = "pg13"))]
let schema_name = CStr::from_ptr((*relation).schemaname).to_str()?;

let table_name = CStr::from_ptr((*relation).relname).to_str()?;
let oid = pg_sys::RangeVarGetRelidExtended(
relation,
Expand Down

0 comments on commit 0900565

Please sign in to comment.