Skip to content

Commit

Permalink
fix: Fix misleading the warning log and disable utility hook during i…
Browse files Browse the repository at this point in the history
…nitdb (#190)
  • Loading branch information
kysshsy authored Jan 5, 2025
1 parent a14415b commit 5f55538
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/hooks/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ pub async fn process_utility_hook(
) -> Result<()> {
let stmt_type = unsafe { (*pstmt.utilityStmt).type_ };

if !is_support_utility(stmt_type) {
// IsPostmasterEnvironment is false when it is false in a standalone process (bootstrap or
// standalone backend).
if !is_support_utility(stmt_type) || unsafe { !pg_sys::IsPostmasterEnvironment } {
prev_hook(
pstmt,
query_string,
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/utility/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ pub fn view_query(
if (*planned_stmt).commandType != pg_sys::CmdType::CMD_SELECT
|| !is_duckdb_query(&query_relations)
{
fallback_warning!("Some relations are not in DuckDB");
return Ok(true);
}
}
}

// Push down the view creation query to DuckDB
set_search_path_by_pg()?;
execute(query_string.to_str()?, [])?;
if let Err(e) = execute(query_string.to_str()?, []) {
fallback_warning!(e.to_string());
}

Ok(true)
}

0 comments on commit 5f55538

Please sign in to comment.