Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions graph/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub(crate) use graphs::{
GraphMetadata, GraphPrivilege, GraphQuota, GraphQuotaUsage,
};
pub(crate) use read::{
catalog_fingerprint, current_catalog_state, current_catalog_state_from_rows, read_catalog,
read_catalog_for_graph,
catalog_fingerprint, current_catalog_state, current_catalog_state_for_graph,
current_catalog_state_from_rows, read_catalog, read_catalog_for_graph,
};
#[cfg(feature = "pg_test")]
pub(crate) use validate::validate_numeric_column;
Expand Down
17 changes: 17 additions & 0 deletions graph/src/catalog/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,23 @@ pub(crate) fn current_catalog_state() -> safety::GraphResult<(u64, Option<String
current_catalog_state_from_rows(&tables, &edges, &filter_columns)
}

/// Same as [`current_catalog_state`] but reuses an already-resolved graph id.
///
/// `read_catalog()` re-resolves the selected graph through a definer SPI call.
/// Query paths such as `ensure_current_graph()` have already resolved that graph
/// metadata, so going through `current_catalog_state()` pays for a duplicate
/// catalog lookup on every traversal call.
///
/// # Errors
///
/// Returns [`safety::GraphError::Internal`] for SPI failures.
pub(crate) fn current_catalog_state_for_graph(
graph_id: &str,
) -> safety::GraphResult<(u64, Option<String>)> {
let (tables, edges, filter_columns) = read_catalog_for_graph(graph_id)?;
current_catalog_state_from_rows(&tables, &edges, &filter_columns)
}

pub(crate) fn current_catalog_state_from_rows(
tables: &[builder::RegisteredTable],
edges: &[builder::RegisteredEdge],
Expand Down
2 changes: 1 addition & 1 deletion graph/src/sql_facade/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ pub(crate) fn ensure_current_graph() -> safety::GraphResult<()> {
let sync_mode = current_sync_mode()?;

let disabled = disabled_graph_trigger_count()?;
let catalog_state = current_catalog_state()?;
let catalog_state = catalog::current_catalog_state_for_graph(&graph.graph_id)?;
let applied_sync_id = ENGINE.with(|e| e.borrow().applied_sync_id);
let pending = pending_sync_rows(applied_sync_id)?;
ENGINE.with(|e| {
Expand Down