← ClaudeAtlas

custom-scan-apilisted

PostgreSQL's Custom Scan / Custom Path API — the pluggable executor node interface that lets extensions add new physical operators (custom joins, custom aggregates, custom scan providers like columnar backends). Covers `CustomScanMethods` + `CustomExecMethods` + `CustomPathMethods` in `src/backend/executor/nodeCustom.c` + `src/backend/optimizer/util/plannodes.c` (for CustomPath / CustomScan). Loads when the user asks about custom scan providers, how citus / timescaledb / greenplum-style columnar backends integrate, CustomPath cost registration, `RegisterCustomScanMethods`, or "how does the planner know about my extension's node type". Skip when the ask is about extending the built-in AM (table AM / index AM — different pluggable interface) or about GetForeignPaths (FDW — sibling but has its own skill).
matejformanek/postgres-claude · ★ 0 · API & Backend · score 70
Install: claude install-skill matejformanek/postgres-claude
# custom-scan-api — plug new executor nodes into the planner Custom Scan lets you register a NEW EXECUTOR NODE from an extension. Unlike an FDW (which handles "foreign data"), Custom Scan is for entirely new operations: parallelization strategies, columnar processing, hardware acceleration (GPU joins), specialized aggregates. citus (distributed queries) and timescaledb (chunk elimination) both use it heavily. Two-part registration: - **CustomPath** — planner side. Register a Path shape the planner can consider during path generation. - **CustomScan / CustomScanState** — executor side. Turn the picked Path into a runnable node. ## The file map | File | Role | |---|---| | `src/backend/optimizer/util/pathnode.c` | Path construction — `create_customscan_path` for extensions. | | `src/backend/optimizer/plan/createplan.c` | `create_customscan_plan` — converts CustomPath → CustomScan Plan node. | | `src/backend/executor/nodeCustom.c` | Runtime — `ExecInitCustomScan` / `ExecCustomScan` / `ExecEndCustomScan` — dispatches to the extension's methods. | | `src/include/commands/customexpr.h` | Public API — CustomPathMethods, CustomScanMethods, CustomExecMethods structs. | | `src/backend/nodes/copyfuncs.c` / `readfuncs.c` / `outfuncs.c` | Serialization support for CustomPath / CustomScan. | ## The three method structs ### `CustomPathMethods` — planner-side ```c typedef struct CustomPathMethods { const char *CustomName; /* Called when converting Path to Plan */ Plan *(*