Skip to content

Full-query pushdown support for FDW#615

Open
bnjjj wants to merge 4 commits into
mainfrom
bnjjj/remote_query
Open

Full-query pushdown support for FDW#615
bnjjj wants to merge 4 commits into
mainfrom
bnjjj/remote_query

Conversation

@bnjjj

@bnjjj bnjjj commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Implement full-query pushdown support for FDWs built on supabase-wrappers.
The goal is to let an FDW act as a thin bridge to a remote execution engine: PostgreSQL can still participate in planning, but the selected query can be sent as one remote SQL statement instead of being decomposed into scan callbacks and partially executed locally.
This enables wrappers-based FDWs to delegate complete query execution, including joins, aggregates, projections, filters, ordering, limits, and parameters, while PostgreSQL only receives the final result rows.

bnjjj added 3 commits June 12, 2026 11:28
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds “full-query pushdown” plumbing to supabase-wrappers, allowing wrappers-based FDWs to execute an entire planned SQL statement remotely (including joins/upper ops) and return only final rows to PostgreSQL.

Changes:

  • Introduces full-query remote execution state (FullQuery, relations, parameters, policy/context) and wires it into planner join/upper paths plus executor scan dispatch.
  • Reworks FDW plan state handling to avoid storing transient planner pointers in cached plans (JSON snapshot for full-query plans; cloned plan templates for legacy scans).
  • Adds serde/serde_json dependencies to support serializing full-query plan snapshots.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
supabase-wrappers/src/utils.rs Makes list deserialization safer by avoiding an unconditional unwrap.
supabase-wrappers/src/upper.rs Adds a full-query upper-path option and improves null-safety in planner extraction helpers.
supabase-wrappers/src/scan.rs Implements full-query planning/execution path, plan snapshot serialization, and parameter capture for remote queries.
supabase-wrappers/src/interface.rs Adds full-query types and introduces remote_query_policy / begin_remote_query hooks for FDWs.
supabase-wrappers/Cargo.toml Adds serde + serde_json dependencies needed for plan snapshotting.
Cargo.lock Locks new serde-related dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1650 to +1653
match param.eval_value.lock() {
Ok(mut eval_value) => *eval_value = current_value,
Err(_) => debug2!("parameter evaluation cache lock was poisoned"),
}
Comment on lines +1708 to +1714
let value = match param.eval_value.lock() {
Ok(value) => value.clone(),
Err(_) => {
debug2!("remote-query parameter cache lock was poisoned");
None
}
};
Comment thread supabase-wrappers/src/interface.rs Outdated
Comment on lines +1063 to +1065
/// If enabled, wrappers may add foreign join or upper paths that call
/// [`begin_full_query_scan`] instead of decomposing the query into base
/// scans, filters, joins, aggregates, and projections executed by Postgres.
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants