Skip to content

Commit

Permalink
feat: Support multilevel partition tables and foreign tables in Execu…
Browse files Browse the repository at this point in the history
…tor hook for DuckDB

Signed-off-by: shamb0 <r.raajey@gmail.com>
  • Loading branch information
shamb0 committed Aug 29, 2024
1 parent f9a3eeb commit 4d664ed
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/hooks/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,40 +570,3 @@ fn get_postgres_search_path() -> Vec<String> {
schema_vec
}

pub fn set_search_path_by_pg() -> Result<()> {
let mut search_path = get_postgres_search_path();
let duckdb_schemas = connection::get_available_schemas()?;

// Filter schemas. If one of schemas doesn't exist, it will cause the DuckDB 'SET search_path' to fail.
search_path.retain(|schema| duckdb_schemas.contains(schema));

// Set duckdb catalog search path
connection::set_search_path(search_path)?;

Ok(())
}

fn get_postgres_search_path() -> Vec<String> {
let active_schemas =
unsafe { PgList::<pg_sys::Oid>::from_pg(pg_sys::fetch_search_path(false)) };

let mut schema_vec: Vec<String> = Vec::with_capacity(active_schemas.len());
for schema_oid in active_schemas.iter_oid() {
let tuple = unsafe {
pg_sys::SearchSysCache1(
pg_sys::SysCacheIdentifier::NAMESPACEOID as i32,
schema_oid.into_datum().unwrap(),
)
};

if !tuple.is_null() {
let pg_namespace = unsafe { pg_sys::GETSTRUCT(tuple) as pg_sys::Form_pg_namespace };
let name = pg_sys::name_data_to_str(unsafe { &(*pg_namespace).nspname });
schema_vec.push(name.to_string());

unsafe { pg_sys::ReleaseSysCache(tuple) };
}
}

schema_vec
}

0 comments on commit 4d664ed

Please sign in to comment.