![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Public surface of the safe-query (hierarchical-CQ) rewriter. More...


Go to the source code of this file.
Functions | |
| Query * | try_safe_query_rewrite (const constants_t *constants, Query *q) |
| Top-level entry point for the hierarchical-CQ rewriter. | |
| void | strip_group_rte_pg18 (Query *q) |
PG 18 helper: strip the synthetic RTE_GROUP entry from q in place, resolving every grouped Var back to its base-table expression. | |
Variables | |
| bool | provsql_boolean_provenance |
GUC: opt-in safe-query optimisation, declared in provsql.c. | |
Public surface of the safe-query (hierarchical-CQ) rewriter.
The implementation lives in safe_query.c. ProvSQL's main planner hook (process_query in provsql.c) calls try_safe_query_rewrite between the AGG-DISTINCT rewrite and get_provenance_attributes, but only when the provsql.boolean_provenance GUC is on. Returning a non-NULL Query feeds the rewriter's output back through process_query from the top; returning NULL makes the caller fall through to the existing pipeline.
Definition in file safe_query.h.
|
extern |
PG 18 helper: strip the synthetic RTE_GROUP entry from q in place, resolving every grouped Var back to its base-table expression.
Defined in provsql.c.
Idempotent: a no-op on earlier PostgreSQL versions and when q->hasGroupRTE is already false. The safe-query rewriter applies it before the union-find pass so the range table is flat.

|
extern |
Top-level entry point for the hierarchical-CQ rewriter.
Runs the shape gate, then the hierarchy detector. When both accept, applies the rewrite and returns the rewritten Query (the caller is expected to re-enter process_query on the result). Returns NULL when q is outside the safe-query scope.
| constants | Cached extension OIDs (from get_constants). |
| q | Input Query, modified in place by side-effect-free helpers but not consumed; the rewriter copyObject's it before mutating. |
Query, or NULL to fall through.Top-level entry point for the hierarchical-CQ rewriter.
Runs the shape gate then the hierarchy detector. If both accept, applies the single-level rewrite and returns the rewritten Query; the caller (process_query) feeds it back from the top so that inner subqueries are themselves re-considered (multi-level recursion via Choice A). Returns NULL to fall through to the existing pipeline.
Definition at line 4674 of file safe_query.c.


|
extern |